diff --git a/CoreDatabase/CoreDatabase.csproj b/CoreDatabase/CoreDatabase.csproj
index 6cb55aa8b5..5dc237c584 100644
--- a/CoreDatabase/CoreDatabase.csproj
+++ b/CoreDatabase/CoreDatabase.csproj
@@ -16,6 +16,7 @@
false
false
false
+ false
DEBUG;TRACE
diff --git a/CoreServer/CoreServer.csproj b/CoreServer/CoreServer.csproj
index d093bf9085..7f186237c8 100644
--- a/CoreServer/CoreServer.csproj
+++ b/CoreServer/CoreServer.csproj
@@ -19,6 +19,7 @@
false
true
true
+ false
DEBUG;TRACE
diff --git a/Dockerfile b/Dockerfile
index ee4c0d92a3..ad5f93955e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,21 +9,19 @@ WORKDIR /build
# Copy the source code to the build container
COPY . .
-# Install required tools: unzip, git, and the text processing utilities we might need
+# Install required tools and clone the database repository
RUN apt-get update && \
- apt-get install -y unzip git sed
-
-# Clone the database repository
-RUN git config --global http.sslVerify false
-RUN git clone https://github.com/OpenDAoC/OpenDAoC-Database.git /tmp/opendaoc-db
+ apt-get install -y unzip git sed && \
+ git config --global http.sslVerify false && \
+ git clone https://github.com/OpenDAoC/OpenDAoC-Database.git /tmp/opendaoc-db && \
+ rm -rf /var/lib/apt/lists/*
# Combine the SQL files
WORKDIR /tmp/opendaoc-db/opendaoc-db-core
RUN cat *.sql > combined.sql
-# Restore NuGet packages
+# Set the working directory back to the build container
WORKDIR /build
-RUN dotnet restore DOLLinux.sln
# Copy serverconfig.example.xml to serverconfig.xml
RUN cp /build/CoreServer/config/serverconfig.example.xml /build/CoreServer/config/serverconfig.xml
@@ -31,20 +29,22 @@ RUN cp /build/CoreServer/config/serverconfig.example.xml /build/CoreServer/confi
# Build the application in Release mode
RUN dotnet build DOLLinux.sln -c Release
-# Use the official .NET 8.0 Runtime image as the base for the final image
-FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
+# ---- final ----
+# Use the official .NET 8.0 Alpine Runtime image as the base for the final image
+FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
LABEL stage=final
-# Install a few packages useful for debugging
-RUN apt-get update && \
- apt-get upgrade -y && \
- apt-get install -y mariadb-client iproute2
+# Copy gosu
+COPY --from=tianon/gosu /gosu /usr/local/bin/
+
+## Install ICU libraries
+RUN apk add --no-cache icu-libs
# Set the working directory in the container
WORKDIR /app
# Copy the build output from the build stage
-COPY --from=build /build/Release .
+COPY --from=build /build/Release /app
# Copy the combined.sql file from the build stage
COPY --from=build /tmp/opendaoc-db/opendaoc-db-core/combined.sql /tmp/opendaoc-db/combined.sql
@@ -52,5 +52,8 @@ COPY --from=build /tmp/opendaoc-db/opendaoc-db-core/combined.sql /tmp/opendaoc-d
# Copy the entrypoint script
COPY --from=build /build/entrypoint.sh /app
+# Make the entrypoint script executable
+RUN chmod +x /app/entrypoint.sh
+
# Set the entrypoint
-ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]
+ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index 322af4abd4..a259e5406f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,14 +1,17 @@
-version: "3.3"
-
-networks:
+networks:
opendaoc-network:
driver: bridge
+volumes:
+ opendaoc-db-data:
+ base-db:
+
services:
db:
image: mariadb:10.6
- stdin_open: true # docker run -i
- tty: true # docker run -t
+ container_name: opendaoc-db
+ stdin_open: true
+ tty: true
command: --default-authentication-plugin=mysql_native_password --lower_case_table_names=1 --character-set-server=utf8mb3 --collation-server=utf8mb3_general_ci --innodb_large_prefix=1 --innodb_file_format=Barracuda --innodb_file_per_table=1
restart: always
environment:
@@ -21,46 +24,43 @@ services:
- opendaoc-network
gameserver:
- stdin_open: true # docker run -i
- tty: true # docker run -t
- image: ghcr.io/opendaoc/opendaoc-core/opendaoc:latest
+ image: ghcr.io/opendaoc/opendaoc-core:latest
+ container_name: opendaoc-server
+ stdin_open: true
+ tty: true
ports:
- "10300:10300"
- "10400:10400"
depends_on:
- db
environment:
+ UID: "1000"
+ GID: "1000"
+ AUTO_ACCOUNT_CREATION: "True"
+ CHEAT_LOGGER_NAME: "cheats"
+ CPU_USE: "8"
+ DB_AUTOSAVE: "True"
+ DB_AUTOSAVE_INTERVAL: "10"
DB_CONNECTION_STRING: "server=db;port=3306;database=opendaoc;userid=root;password=my-secret-pw;treattinyasboolean=true"
- SERVER_PORT: "10300"
- SERVER_IP: "0.0.0.0"
- REGION_IP: "0.0.0.0"
- REGION_PORT: "10400"
- UDP_IP: "0.0.0.0"
- UDP_PORT: "10400"
- ENABLE_UPNP: "False"
+ DB_TYPE: "MYSQL"
DETECT_REGION_IP: "True"
- SERVER_NAME: "OpenDAoC"
- SERVER_NAME_SHORT: "OPENDAOC"
- LOG_CONFIG_FILE: "./config/logconfig.xml"
- SCRIPT_COMPILATION_TARGET: "./lib/GameServerScripts.dll"
- SCRIPT_ASSEMBLIES: ""
ENABLE_COMPILATION: "True"
- AUTO_ACCOUNT_CREATION: "True"
+ ENABLE_UPNP: "False"
GAME_TYPE: "Normal"
- CHEAT_LOGGER_NAME: "cheats"
GM_ACTION_LOGGER_NAME: "gmactions"
INVALID_NAMES_FILE: "./config/invalidnames.txt"
- DB_TYPE: "MYSQL"
- DB_AUTOSAVE: "True"
- DB_AUTOSAVE_INTERVAL: "10"
- CPU_USE: "8"
-
+ LOG_CONFIG_FILE: "./config/logconfig.xml"
+ REGION_IP: "0.0.0.0"
+ REGION_PORT: "10400"
+ SCRIPT_ASSEMBLIES: ""
+ SCRIPT_COMPILATION_TARGET: "./lib/GameServerScripts.dll"
+ SERVER_IP: "0.0.0.0"
+ SERVER_NAME: "OpenDAoC"
+ SERVER_NAME_SHORT: "OPENDAOC"
+ SERVER_PORT: "10300"
+ UDP_IP: "0.0.0.0"
+ UDP_PORT: "10400"
volumes:
- base-db:/tmp/opendaoc-db
-
networks:
- - opendaoc-network
-
-volumes:
- opendaoc-db-data:
- base-db:
\ No newline at end of file
+ - opendaoc-network
\ No newline at end of file
diff --git a/entrypoint.sh b/entrypoint.sh
index a157da8629..f08b298e07 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,6 +1,36 @@
-#!/bin/bash
+#!/bin/sh
-# Delete the existing serverconfig.xml and create it from scratch
+# Default values for UID and GID if not provided
+APP_UID=${UID:-1000}
+APP_GID=${GID:-1000}
+
+# Check if running as root
+if [ "$(id -u)" != "0" ]; then
+ >&2 echo "ERROR: Not running as root. Please run as root, and pass HOST_UID and HOST_GID."
+ exit 120
+elif [ "${APP_UID}" = "" ]; then
+ >&2 echo "ERROR: HOST_UID is not set. Please run as root, and pass HOST_UID and HOST_GID."
+ exit 121
+elif [ "${APP_GID}" = "" ]; then
+ >&2 echo "ERROR: HOST_GID is not set. Please run as root, and pass HOST_UID and HOST_GID."
+ exit 122
+fi
+
+# Handle existing group with the same GID
+EXISTING_GROUP_NAME=$(getent group "${APP_GID}" | cut -d: -f1)
+if [ "${EXISTING_GROUP_NAME}" != "" ]; then
+ delgroup "${EXISTING_GROUP_NAME}"
+fi
+
+# (Re)create the group 'appgroup'
+delgroup appgroup 2>/dev/null || true
+addgroup -g "${APP_GID}" appgroup
+
+# (Re)create the user 'appuser'
+deluser appuser 2>/dev/null || true
+adduser -D -H -u "${APP_UID}" -G appgroup appuser
+
+# Delete the existing serverconfig.xml
rm -f /app/config/serverconfig.xml
# Create serverconfig.xml with environment variables
@@ -36,6 +66,8 @@ cat << EOF > /app/config/serverconfig.xml
EOF
-# Start the AtlasCore application
-cd /app && exec dotnet CoreServer.dll
+# Change ownership of the /app directory
+chown -R appuser:appgroup /app
+# Switch to the non-root user and start the server
+exec gosu appuser sh -c "cd /app && exec dotnet CoreServer.dll"