Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tty-clock
tty-clock.dSYM/
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this just a TZ environment that can be passed by the docker run caller?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that works too, you can set the default for the container with the build argument, as well as override it at runtime with the environment TZ. I could remove the default, but I think its nice to be able to set it and not have to specify it again.


7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"