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

add timezone for docker install #307

Merged
merged 2 commits into from Jun 2, 2022

Conversation

ksurl
Copy link
Contributor

@ksurl ksurl commented Jun 2, 2022

add support for timezone

@binwiederhier binwiederhier merged commit d65ca9b into binwiederhier:main Jun 2, 2022
@binwiederhier
Copy link
Owner

I reverted this change because it fails the build pipeline for ARM. My assumption is that the alpine:latest image is an amd64 image and it cannot run apk. I think there is a way to solve this, but for this hotfix release I didn't have time.

Failed pipeline: https://github.com/binwiederhier/ntfy/runs/6718645921?check_suite_focus=true

@ksurl
Copy link
Contributor Author

ksurl commented Jun 3, 2022

hmm that's odd. I am using buildx for multi arch builds and my image also has tzdata install with no issues but I am not using goreleaser. just direct docker buildx action.

@binwiederhier
Copy link
Owner

Goreleaser can do buildx apparently. https://goreleaser.com/customization/docker/

And you can set the platform flag too i think.

@binwiederhier
Copy link
Owner

You may be able to do something like this: https://github.com/zinclabs/zinc/blob/main/Dockerfile#L6

@egooner
Copy link

egooner commented Apr 11, 2023

Any progress on this - using Delay send with absolute time not simple in Docker as it is using UTC and I am not in UTC!! Delay with offset is fine but would be nice to be able to use absolute time also.

@kruton
Copy link

kruton commented May 25, 2023

I was really confused because the docs were not reverted.

@ksurl ksurl deleted the docs-timezone branch September 4, 2023 03:17
@Ishrathh
Copy link

Ishrathh commented Sep 5, 2023

Time zone can be added using docker-compose, let me know if you would like me to share @egooner @kruton

@egooner
Copy link

egooner commented Sep 8, 2023

I have the following already set ... but to be honest cannot recall whether this did the trick or not but if I issue date in the console I get this so I think not!!


Fri Sep 8 18:46:27 UTC 2023


environment:
- "TZ=Europe/London"
volumes:
- "/etc/localtime:/etc/localtime:ro"

@Ishrathh
Copy link

Ishrathh commented Sep 9, 2023

You can check for the correct time zone and there are 2 issues, both the machine running the container as well as the container have to be on the correct time zone. I believe you can manage it for your machine but for the docker instance here are my instructions:

docker-compose.yml

version: "2.3"

services:
  ntfy:
    build: . # This will build dockerfile in current dir
    container_name: ntfy
    command:
      - /usr/bin/ntfy
      - serve
    volumes:
      - /var/cache/ntfy:/var/cache/ntfy
      - /etc/ntfy:/etc/ntfy
      - /etc/letsencrypt:/etc/letsencrypt
    ports:
      - 8080:80
    healthcheck: # optional: remember to adapt the host:port to your environment
        test: ["CMD-SHELL", "wget -q --no-check-certificate --tries=1 https://localhost:80/v1/health -O - | grep -Eo '\"healthy\"\\s*:\\s*true' || exit 1"]
        interval: 60s
        timeout: 10s
        retries: 3
        start_period: 40s
    restart: unless-stopped

Dockerfile

# Use the original ntfy image as the base
FROM binwiederhier/ntfy

# Install tzdata and tini packages
RUN apk update && apk add tzdata tini

# Set the timezone
ENV TZ=Asia/Colombo

# Use tini as the entrypoint
ENTRYPOINT ["/sbin/tini", "--"]

This is what I used, change the time zone to yours as needed. I also had to use tini which reaps zombie processes that were accumulated by 'ssl_client' process of ntfy. Also note that you can set the time zone in docker-compose as an environment variable OR in the Dockerfile. Dockerfile is easier if you don't plan on changing the time zone often

To check if the time zone of the container is correct you can do the following:

# sudo docker exec -it ntfy /bin/sh
# date

@egooner
Copy link

egooner commented Sep 23, 2023

Thanks for that @Ishrathh - I did your docker build example with the exception of the tini which did not seem to work for me!!
Would be good to see Timezone built into the system rather than having to do this!! @binwiederhier - any chance of incorporating the tzdata package into the build and supporting passing the TZ in the Environment variable. The solution above works but creates more effort on behalf of the users to do this.

@Ishrathh
Copy link

Your welcome @egooner, if you would like me to assist you with the setup of tzdata without the tini part let me know :D

I reverted this change because it fails the build pipeline for ARM. My assumption is that the alpine:latest image is an amd64 image and it cannot run apk. I think there is a way to solve this, but for this hotfix release I didn't have time.

Failed pipeline: https://github.com/binwiederhier/ntfy/runs/6718645921?check_suite_focus=true

@binwiederhier Would be awesome if we can get the time zone released on arch's that support it

@binwiederhier
Copy link
Owner

How are we supposed to do that? Different docker files just because of this? That's seems little ridiculous.

@egooner
Copy link

egooner commented Sep 24, 2023

Not sure how your build process works @binwiederhier (not very good on docker build etc) but I spotted this on conditional docker build not sure if it helps. Docker File Conditions

@binwiederhier
Copy link
Owner

Re-added for linux/amd64 in 8adb9ee, see #894

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.

None yet

5 participants