diff --git a/Dockerfile b/Dockerfile index 3131264..d59a0fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,9 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/bin/goencode ./cmd/go # Final stage FROM debian:bookworm-slim -# Install ffmpeg and ca-certificates +# Install ffmpeg, ca-certificates, and tzdata for timezone support RUN apt-get update && \ - apt-get install -y --no-install-recommends ffmpeg ca-certificates && \ + apt-get install -y --no-install-recommends ffmpeg ca-certificates tzdata && \ rm -rf /var/lib/apt/lists/* WORKDIR /app diff --git a/README.md b/README.md index 7e201cf..3ea792b 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ services: # Web Server Configuration - GOENCODE_SERVER_LISTEN=0.0.0.0 - GOENCODE_SERVER_PORT=8080 + - TZ=Europe/London # Web UI Authentication (Optional) - GOENCODE_AUTH_USER=admin @@ -89,6 +90,7 @@ GoEncode can be configured via `goencode.yaml` or entirely via environment varia | `GOENCODE_DB_NAME` | Database name | `goencode` | | `GOENCODE_SERVER_LISTEN` | IP to bind the web interface | `0.0.0.0` | | `GOENCODE_SERVER_PORT` | Port for the web interface | `8080` | +| `TZ` | Container TimeZone | `UTC` | | `GOENCODE_AUTH_USER` | Username for the web UI | | | `GOENCODE_AUTH_PASS` | Password for the web UI | | | `GOENCODE_ENCODER_TEMP`| Temp directory for processing jobs | `/tmp/goencode` | diff --git a/goencode.yaml b/goencode.yaml index fbc3cba..d891665 100644 --- a/goencode.yaml +++ b/goencode.yaml @@ -1,6 +1,7 @@ server: port: 8080 listen_addr: "0.0.0.0" + timezone: "UTC" auth: username: "admin" diff --git a/internal/config/config.go b/internal/config/config.go index d16ddda..a2cb45a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -27,6 +27,7 @@ func getEnvInt(key string, defaultVal int) int { type ServerConfig struct { Port int `yaml:"port"` ListenAddr string `yaml:"listen_addr"` + TimeZone string `yaml:"timezone"` } type DatabaseConfig struct { @@ -95,5 +96,14 @@ func LoadConfig(path string) (*Config, error) { cfg.Database.Port = 3306 } + if envTZ := os.Getenv("TZ"); envTZ != "" { + cfg.Server.TimeZone = envTZ + } + + // Apply timezone if set + if cfg.Server.TimeZone != "" { + os.Setenv("TZ", cfg.Server.TimeZone) + } + return &cfg, nil }