abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
768 stars 315 forks source link

Timezone setting #189

Closed pointbre closed 5 years ago

pointbre commented 5 years ago

Hi,

In order to set the proper timezone with Caddy, I've made a change to Dockerfile like the following:

...
# install process wrapper
COPY --from=builder /go/bin/parent /bin/parent

# Add timezone
RUN apk add tzdata

ENTRYPOINT ["/bin/parent", "caddy"]
...

Docker image building went ok.

When running the caddy-docker image, I've set TZ=Pacific/Auckland and I could see my local time in Caddy's access log. Please make the change so that everybody can set timezone.

Thanks

abiosoft commented 5 years ago

@pointbre thanks. You mean you only had to set the TZ env var?

That is a straightforward change. I'll add it to the container.

pointbre commented 5 years ago

RUN apk add tzdata to Dockerfile and TZ env var to container, that's all. Tested with NZ timezone on Ubuntu 18.04. Thanks.

FinalFrag commented 5 years ago

Another option is to add this to your docker-compose.yml when using the container

volumes:    
    - "/etc/localtime:/etc/localtime:ro"
nurtext commented 5 years ago

Snippet I'm using in almost all my alpine containers:

# Timezone
ENV TIMEZONE Europe/Berlin

# Install timezone data and setup timezone
RUN apk --update add --no-cache --virtual .tz-deps tzdata \
    && cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
    && echo ${TIMEZONE} > /etc/timezone \
    && apk del .tz-deps
abiosoft commented 5 years ago

Fixed with https://github.com/abiosoft/caddy-docker/pull/202