Skip to content

Conversation

@EnigmaCurry
Copy link

This adds a Dockerfile and a make docker target to build tty-clock in an alpine container image.

With the Dockerfile colocated with the source code in git, you can build the image all with one command:

## Build using my fork (replace /xorg62 if merged):
docker build https://github.com/EnigmaCurry/tty-clock.git#master -t localhost/tty-clock

## To run the image:
docker run --rm -it localhost/tty-clock tty-clock -u -c -s -C 3 -b

@EnigmaCurry
Copy link
Author

I forgot that inside the container it was always thinking the timezone was UTC, so I added the TIMEZONE build argument to set it how you like.

DOCKER_TIMEZONE=America/Los_Angeles DOCKER_IMAGE=xorg62/tty-clock make docker

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants