Compare commits
3 Commits
62deeebe63
...
master
Author | SHA1 | Date | |
---|---|---|---|
7d46e3f7a6 | |||
2a22708350 | |||
ed93535d1b |
24
Dockerfile
Normal file
24
Dockerfile
Normal 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" ]
|
@ -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
|
31
the-worlds-least-useful-clock.c
Normal file
31
the-worlds-least-useful-clock.c
Normal 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(×tamp);
|
||||
timeinfo = localtime(×tamp);
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user