Skip to content

Support TZ environment variable for timezone configuration#10

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/set-time-zone-docker-compose
Closed

Support TZ environment variable for timezone configuration#10
Copilot wants to merge 4 commits intomainfrom
copilot/set-time-zone-docker-compose

Conversation

Copy link

Copilot AI commented Jan 23, 2026

The Go backend ignores the TZ environment variable. All timestamps default to UTC regardless of Docker configuration.

Changes

  • Dockerfile: Install tzdata package (required on Alpine for timezone database)
  • server/main.go: Read TZ environment variable at startup and set time.Local
    if tzEnv := os.Getenv("TZ"); tzEnv != "" {
        loc, err := time.LoadLocation(tzEnv)
        if err != nil {
            log.Printf("Warning: Failed to load timezone '%s': %v", tzEnv, err)
        } else {
            time.Local = loc
        }
    }
  • Documentation: Add TZ environment variable usage to README and docker-compose.yml

Impact

All time.Now() calls throughout the application (backup logs, file metadata, naming rules) now respect the configured timezone instead of defaulting to UTC.

Usage:

environment:
  - TZ=Asia/Bangkok

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • go.googlesource.com
    • Triggering command: /update-job-proxy /update-job-proxy server --proxy-cert /home/REDACTED/work/_temp/runtime-logs/mkcert/rootCA.pem --updater-env NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/dbot-ca.crt (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-48ce6d8ec231 -j DOCKER-ISOLATION-STAGE-2 07986c7.0 git (dns block)
  • google.golang.org
    • Triggering command: /update-job-proxy /update-job-proxy server --proxy-cert /home/REDACTED/work/_temp/runtime-logs/mkcert/rootCA.pem --updater-env NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/dbot-ca.crt (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-48ce6d8ec231 -j DOCKER-ISOLATION-STAGE-2 07986c7.0 git (dns block)
  • gopkg.in
    • Triggering command: /update-job-proxy /update-job-proxy server --proxy-cert /home/REDACTED/work/_temp/runtime-logs/mkcert/rootCA.pem --updater-env NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/dbot-ca.crt (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-48ce6d8ec231 -j DOCKER-ISOLATION-STAGE-2 07986c7.0 git (dns block)
  • gorm.io
    • Triggering command: /update-job-proxy /update-job-proxy server --proxy-cert /home/REDACTED/work/_temp/runtime-logs/mkcert/rootCA.pem --updater-env NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/dbot-ca.crt (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-48ce6d8ec231 -j DOCKER-ISOLATION-STAGE-2 07986c7.0 git (dns block)
  • nullprogram.com
    • Triggering command: /update-job-proxy /update-job-proxy server --proxy-cert /home/REDACTED/work/_temp/runtime-logs/mkcert/rootCA.pem --updater-env NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/dbot-ca.crt (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-48ce6d8ec231 -j DOCKER-ISOLATION-STAGE-2 07986c7.0 git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>set time zone when use docker compose</issue_title>
<issue_description>Please config to add environment for setting time zone
I use this compose file it can't change time in backend

  backapp:
    image: ghcr.io/dennis960/backapp:latest
    container_name: ${NAME:-backapp}-backapp
    restart: unless-stopped
    hostname: backapp
    environment:
      - TZ=Asia/Bangkok
    volumes:
      # custom configurations
      - backapp-data:/data
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    networks:
      - default
    # ports:
    #   - "${PORT:-8080}:8080"

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add environment configuration for setting time zone in Docker Compose Support TZ environment variable for timezone configuration Jan 23, 2026
Copilot AI requested a review from Dennis960 January 23, 2026 13:44
@Dennis960 Dennis960 force-pushed the copilot/set-time-zone-docker-compose branch from 5ac47ad to f6a07be Compare January 23, 2026 13:54
Copilot AI and others added 4 commits January 23, 2026 14:56
- Install tzdata package in Docker image for timezone data
- Load TZ environment variable at application startup
- Set Go's time.Local to configured timezone
- Log timezone configuration for debugging

Co-authored-by: Dennis960 <66166638+Dennis960@users.noreply.github.com>
- Document TZ environment variable in README
- Add commented example in docker-compose.yml

Co-authored-by: Dennis960 <66166638+Dennis960@users.noreply.github.com>
Co-authored-by: Dennis960 <66166638+Dennis960@users.noreply.github.com>
@Dennis960 Dennis960 closed this Jan 23, 2026
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.

set time zone when use docker compose

2 participants