Adding custom TZ support.

This commit is contained in:
Matthew Green 2025-04-08 18:24:40 -05:00
parent 63ee39a599
commit c41b3ed134
4 changed files with 16 additions and 1 deletions

View file

@ -8,6 +8,8 @@ ENV CONFIG_TEMPLATES_DIR=${INSTALL_DIR}/config-templates
# Default UID/GID that can be overridden at runtime # Default UID/GID that can be overridden at runtime
ENV UID=1000 ENV UID=1000
ENV GID=1000 ENV GID=1000
# Default timezone is UTC
ENV TZ=Etc/UTC
# Install dependencies # Install dependencies
RUN apt-get update && \ RUN apt-get update && \

View file

@ -1,6 +1,6 @@
# Configuration # Configuration
IMAGE_NAME := greenmatthew/scp-secret-laboratory-server IMAGE_NAME := greenmatthew/scp-secret-laboratory-server
VERSION := 1.0.0 VERSION := 1.0.1
CONTAINER_NAME := scp-sl-server CONTAINER_NAME := scp-sl-server
PORT := 7777 PORT := 7777
SHELL := /bin/sh SHELL := /bin/sh
@ -24,6 +24,7 @@ run: build
docker run -d --name $(CONTAINER_NAME) \ docker run -d --name $(CONTAINER_NAME) \
-p $(PORT):$(PORT)/udp \ -p $(PORT):$(PORT)/udp \
-v $(PWD)/config:/home/steam/.config \ -v $(PWD)/config:/home/steam/.config \
-e TZ=America/Chicago \
-e UID=1001 \ -e UID=1001 \
-e GID=1001 \ -e GID=1001 \
--restart unless-stopped \ --restart unless-stopped \

View file

@ -21,6 +21,8 @@ services:
environment: environment:
- UID=1000 - UID=1000
- GID=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 restart: unless-stopped
``` ```
@ -55,6 +57,8 @@ docker run -d \
-v ./config:/home/steam/.config \ -v ./config:/home/steam/.config \
-e UID=1000 \ -e UID=1000 \
-e GID=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 \ --restart unless-stopped \
greenmatthew/scp-secret-laboratory-server:latest 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) - `UID`: User ID to run the server as (default: 1000)
- `GID`: Group 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 ## Port Configuration

View file

@ -1,6 +1,13 @@
#!/bin/sh #!/bin/sh
set -e 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}" echo "Setting up container with UID:${UID} and GID:${GID}"
# Check if group with GID exists # Check if group with GID exists