From c41b3ed134c48ecc14adfbd3c1805618f929ade5 Mon Sep 17 00:00:00 2001 From: Matthew Green Date: Tue, 8 Apr 2025 18:24:40 -0500 Subject: [PATCH] Adding custom TZ support. --- Dockerfile | 2 ++ Makefile | 3 ++- README.md | 5 +++++ entrypoint.sh | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2080be9..bf4d676 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ ENV CONFIG_TEMPLATES_DIR=${INSTALL_DIR}/config-templates # Default UID/GID that can be overridden at runtime ENV UID=1000 ENV GID=1000 +# Default timezone is UTC +ENV TZ=Etc/UTC # Install dependencies RUN apt-get update && \ diff --git a/Makefile b/Makefile index ef43e74..ba1ad72 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Configuration IMAGE_NAME := greenmatthew/scp-secret-laboratory-server -VERSION := 1.0.0 +VERSION := 1.0.1 CONTAINER_NAME := scp-sl-server PORT := 7777 SHELL := /bin/sh @@ -24,6 +24,7 @@ run: build docker run -d --name $(CONTAINER_NAME) \ -p $(PORT):$(PORT)/udp \ -v $(PWD)/config:/home/steam/.config \ + -e TZ=America/Chicago \ -e UID=1001 \ -e GID=1001 \ --restart unless-stopped \ diff --git a/README.md b/README.md index 036bb84..b08940a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ services: environment: - UID=1000 - GID=1000 + # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). + # - TZ=Etc/UTC restart: unless-stopped ``` @@ -55,6 +57,8 @@ docker run -d \ -v ./config:/home/steam/.config \ -e UID=1000 \ -e GID=1000 \ + # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). + # -e TZ=Etc/UTC \ --restart unless-stopped \ greenmatthew/scp-secret-laboratory-server:latest ``` @@ -74,6 +78,7 @@ Mounting the .config directory allows you to configure any server setting and ha - `UID`: User ID to run the server as (default: 1000) - `GID`: Group ID to run the server as (default: 1000) +- `TZ`: [Timezone identifier](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) for the container (default: Etc/UTC). Examples: `America/Chicago`, `Europe/London`, `Asia/Tokyo` ## Port Configuration diff --git a/entrypoint.sh b/entrypoint.sh index e159d16..25f8b76 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,13 @@ #!/bin/sh set -e +# Set timezone +if [ ! -z "$TZ" ]; then + echo "Setting timezone to $TZ" + ln -snf /usr/share/zoneinfo/$TZ /etc/localtime + echo $TZ > /etc/timezone +fi + echo "Setting up container with UID:${UID} and GID:${GID}" # Check if group with GID exists