diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b2d951c..6607c48 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,8 +3,6 @@ name: Docker Image CI on: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] jobs: diff --git a/.github/workflows/pull_request_test.yml b/.github/workflows/pull_request_test.yml new file mode 100644 index 0000000..7ae8606 --- /dev/null +++ b/.github/workflows/pull_request_test.yml @@ -0,0 +1,17 @@ +name: Docker Image CI + +on: + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Build the Docker image + run: docker build . --file Dockerfile --tag fuzzystatic/nitrox-server:latest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b54934 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +config/ \ No newline at end of file diff --git a/README.md b/README.md index feb50b5..1c24873 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ Here are some example snippets to help you get started creating a container. To run the image using docker-compose, adjust this docker-compose file to your needs: -```docker +```yaml version: "1.0" services: nitrox: - image: docker.io/fuzzystatic/nitrox-server:latest + image: fuzzystatic/nitrox-server:latest container_name: nitrox-server volumes: - "/path/to/nitrox:/config" # Stores your server data, such as the configuration and world data @@ -23,8 +23,8 @@ services: - "PUID=1000" # The ID of the group to run Nitrox as (default=1000) - "PGID=1000" # The ID of the user to run Nitrox as (default=1000) - "TZ=Etc/UTC" # The timezone to run Nitrox with (default=Etc/UTC) - - "SUBNAUTICA_INSTALLATION_PATH=/subnautica" # The timezone to run Nitrox with (default=/subnautica) - - "SUBNAUTICA_SAVE=My World" # Set this to your desired save name (default=My World) (Optional) + - "SUBNAUTICA_INSTALLATION_PATH=/subnautica" # The path on the container where 'Subnautica_Data' directory is (default=/subnautica) + - "SUBNAUTICA_SAVE=My World" # Set this to your desired save name (default=My World) - "CUSTOM_NITROX_REPOSITORY=SubnauticaNitrox/Nitrox" # Set this to the fork you want to use (default=SubnauticaNitrox/Nitrox) ports: - "11000:11000/udp" # Nitrox @@ -51,15 +51,15 @@ docker run -d \ Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `:` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container. -| Parameter | Function | -| :----: | --- | -| `-p 11000/udp` | server port - port forwarding may be required to host on the internet. | -| `-e PUID=1000` | for UserID - see below for explanation | -| `-e PGID=1000` | for GroupID - see below for explanation | -| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | -| `-e SUBNAUTICA_INSTALLATION_PATH=/subnautica` | Subnautica game data. | -| `-v /config` | Nitrox server data storage location. | -| `-v /subnautica` | Subnautica game data goes here. | +| Parameter | Function | +|:---------------------------------------------:|----------------------------------------------------------------------------------------------------------------| +| `-p 11000/udp` | server port - port forwarding may be required to host on the internet. | +| `-e PUID=1000` | for UserID - see below for explanation | +| `-e PGID=1000` | for GroupID - see below for explanation | +| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | +| `-e SUBNAUTICA_INSTALLATION_PATH=/subnautica` | Subnautica game data (on the container). | +| `-v /config` | Nitrox server data storage location. | +| `-v /subnautica` | Subnautica game data goes here. | ## User / Group Identifiers diff --git a/install-nitrox.sh b/install-nitrox.sh index 0532631..a4ef85c 100755 --- a/install-nitrox.sh +++ b/install-nitrox.sh @@ -4,7 +4,7 @@ echo "Downloading latest Nitrox release..." mkdir --parents /config/packages cd /config/packages -curl --silent https://api.github.com/repos/${CUSTOM_NITROX_REPOSITORY:-"SubnauticaNitrox/Nitrox"}/releases/latest \ +curl --silent https://api.github.com/repos/"${CUSTOM_NITROX_REPOSITORY:-"SubnauticaNitrox/Nitrox"}"/releases/latest \ | grep -wo "https.*linux_x64.zip" \ | wget --output-document ./nitrox.zip --quiet --input-file - @@ -15,11 +15,11 @@ unzip -u /config/packages/nitrox.zip -d ./ # Fix the permissions echo "Fixing Nitrox permissions..." -chmod +x ./*.exe +chmod +x Nitrox.Launcher Nitrox.Server.Subnautica # *.exe did nothing because this is linux # Fix bug due to Linux file name case sensitivity echo "Fixing Nitrox case sensitive filenames..." -ln --symbolic --force /subnautica/Subnautica_Data/Managed/LitJson.dll ./LitJSON.dll +ln --symbolic --force "${SUBNAUTICA_INSTALLATION_PATH:-"/subnautica"}"/Subnautica_Data/Managed/LitJson.dll ./LitJSON.dll # Set the path to Subnautica -echo "/subnautica" > ./path.txt +echo "${SUBNAUTICA_INSTALLATION_PATH:-"/subnautica"}" > ./path.txt diff --git a/run-nitrox.sh b/run-nitrox.sh index 357c3de..3c3d0b6 100755 --- a/run-nitrox.sh +++ b/run-nitrox.sh @@ -1,15 +1,15 @@ -#!/bin/bash +#!/bin/sh # Check if the game files are available while true do echo "Looking for Subnautica's game files..." - if [ -d "/subnautica/Subnautica_Data" ] + if [ -d "${SUBNAUTICA_INSTALLATION_PATH:-"/subnautica"}/Subnautica_Data" ] then - echo "Subnautica's game files were found at /subnautica" + echo "Subnautica's game files were found at ${SUBNAUTICA_INSTALLATION_PATH:-"/subnautica"}" break else - echo "Subnautica's game files could not be found, please make sure to mount your Subnautica game directory at /subnautica inside the container" + echo "Subnautica's game files could not be found, please make sure to mount your Subnautica game directory at ${SUBNAUTICA_INSTALLATION_PATH:-"/subnautica"} inside the container" echo "Waiting 10 seconds before attempting again..." sleep 10 fi diff --git a/setup-timezone.sh b/setup-timezone.sh index e84a45e..5929f3d 100755 --- a/setup-timezone.sh +++ b/setup-timezone.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/sh # Configures the timezone -echo "Setting timezone to ${TZ}..." -ln --symbolic --no-dereference --force /usr/share/zoneinfo/${TZ} /etc/localtime -echo ${TZ} > /etc/timezone +echo "Setting timezone to ${TZL:-"Etc/UTC"}..." +ln --symbolic --no-dereference --force /usr/share/zoneinfo/"${TZ:-"Etc/UTC"}" /etc/localtime +echo "${TZ:-"Etc/UTC"}" > /etc/timezone diff --git a/setup-user.sh b/setup-user.sh index de7ea0c..d5fd475 100755 --- a/setup-user.sh +++ b/setup-user.sh @@ -1,17 +1,17 @@ -#!/bin/bash +#!/bin/sh # Remove existing user echo "Removing existing user..." -userdel nitrox || true -groupdel nitrox || true +userdel nitrox >/dev/null 2>&1 || true # Actually makes the errors quiet +groupdel nitrox >/dev/null 2>&1 || true # Create the user group -echo "Creating Nitrox user group with ID ${PGID}..." -groupadd --gid ${PGID} nitrox +echo "Creating Nitrox user group with ID ${PGID:-1000}..." +groupadd --gid "${PGID:-1000}" nitrox # Create the user -echo "Creating Nitrox user account with ID ${PUID}..." -useradd --gid ${PGID} --uid ${PUID} --home-dir /config nitrox +echo "Creating Nitrox user account with ID ${PUID:-1000}..." +useradd --gid "${PGID:-1000}" --uid "${PUID:-1000}" --home-dir /config nitrox # Change the active user echo "Switching to Nitrox user..."