Compare commits

...

3 Commits

3 changed files with 57 additions and 2 deletions

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1
FROM alpine:latest as base
# Build Stage:
FROM base AS build
RUN apk add git build-base
RUN git clone https://undercroft.ocathain.ie/barra/the-worlds-least-useful-clock.git
RUN gcc the-worlds-least-useful-clock/the-worlds-least-useful-clock.c
# Final Stage:
FROM base AS final
COPY --from=build a.out /bin/useless-clock
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
USER appuser
COPY --from=build a.out /bin/useless-clock
ENTRYPOINT [ "/bin/useless-clock" ]

View File

@ -1,3 +1,3 @@
# the-worlds-least-useful-clock
* the-worlds-least-useful-clock
An example application for use in demonstrating Docker images and the Openshift Image Registry

View File

@ -0,0 +1,31 @@
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
int main (int argc, char ** argv)
{
time_t timestamp;
struct tm * timeinfo;
srand(time(NULL));
while (true)
{
time(&timestamp);
timeinfo = localtime(&timestamp);
if ((rand() % 10) == 0)
{
printf("The time is now for coffee. Coffee time it is.\n");
}
else
{
printf("The time is now: %s", asctime(timeinfo));
}
fflush(stdout);
sleep(rand() % 12);
}
return 0;
}