Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Dockerfile #105

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
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
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 ${DOCKER_IMAGE} tty-clock --help"