diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ea4e594 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +tty-clock +tty-clock.dSYM/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0087657 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM docker.io/alpine:3.15 +RUN apk add -U build-base ncurses-dev +WORKDIR /src +ADD . /src +RUN make + +FROM docker.io/alpine:3.15 +ARG TIMEZONE=UTC +COPY --from=0 /src/tty-clock /usr/bin/tty-clock +CMD ['/usr/bin/tty-clock'] +RUN apk add -U ncurses-libs tzdata && \ + cp -rf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime + diff --git a/Makefile b/Makefile index 9428506..f4d9df1 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ BIN ?= tty-clock PREFIX ?= /usr/local INSTALLPATH ?= ${DESTDIR}${PREFIX}/bin MANPATH ?= ${DESTDIR}${PREFIX}/share/man/man1 +DOCKER ?= docker +DOCKER_IMAGE ?= localhost/tty-clock +DOCKER_TIMEZONE ?= UTC ifeq ($(shell sh -c 'which ncurses6-config>/dev/null 2>/dev/null && echo y'), y) CFLAGS += -Wall -g $$(ncurses6-config --cflags) @@ -57,3 +60,7 @@ clean : @rm -f ${BIN} @echo "${BIN} cleaned" +docker : + + ${DOCKER} build --build-arg=TIMEZONE=${DOCKER_TIMEZONE} -t ${DOCKER_IMAGE} . + @echo "Run the container: ${DOCKER} run --rm -it -e TZ=${DOCKER_TIMEZONE} ${DOCKER_IMAGE} tty-clock --help"