Fixes to allow private swg repositories

This commit is contained in:
Calabro, Brandon
2025-07-20 21:13:14 -05:00
parent 965ba984d3
commit 885255f763
4 changed files with 68 additions and 14 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

View File

@@ -22,7 +22,9 @@ RUN apt-get install -y \
openjdk-11-jdk:i386 \
psmisc \
supervisor \
wget
wget \
vim \
nano
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*
@@ -44,7 +46,26 @@ ENV ORACLE_HOME=/usr/lib/oracle/18.3/client
ENV LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client/lib:/usr/include/oracle/18.3/client
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-i386
RUN git clone https://github.com/SWG-Source/swg-main.git /swg-main
# Declare build arguments with a default for the repo URL
ARG REPO_URL=https://github.com/SWG-Source/swg-main.git
ARG REPO_USERNAME
ARG REPO_PASSWORD
# Clone the repository, using credentials if provided
RUN if [ -n "$REPO_USERNAME" ] && [ -n "$REPO_PASSWORD" ]; then \
# URL-encode the password to handle special characters
ENCODED_PASSWORD=$(echo "$REPO_PASSWORD" | sed -e 's/%/%25/g' -e 's/@/%40/g' -e 's/:/%3A/g' -e 's/\$/%24/g' -e 's/&/%26/g' -e 's/+/%2B/g' -e 's/,/%2C/g' -e 's|/|%2F|g' -e 's/;/%3B/g' -e 's/=/%3D/g' -e 's/?/%3F/g' -e 's/ /%20/g'); \
# Extract the hostname (e.g., gitlab.bmcstudios.org) from the repo URL
REPO_HOST=$(echo "$REPO_URL" | sed -e 's|https://||' -e 's|/.*||'); \
# Globally configure git to rewrite URLs for this host to include credentials.
# This ensures ALL git operations for this host are authenticated.
git config --global url."https://${REPO_USERNAME}:${ENCODED_PASSWORD}@${REPO_HOST}".insteadOf "https://${REPO_HOST}"; \
# Now clone the repository and its submodules. The rewrite rule will be applied automatically.
git clone --recurse-submodules "${REPO_URL}" /swg-main; \
else \
git clone --recurse-submodules "${REPO_URL}" /swg-main; \
fi
WORKDIR /swg-main
RUN ant git_update_submods

View File

@@ -1,8 +1,36 @@
# swg-docker
Instructions:
- Clone this repository
- `docker compose up -d`
- `docker exec -it swg bash` to log into a shell in the swg container
- `ant swg` to compile the game and the assets
- `ant start` to run the server
This project sets up a development environment for SWG using Docker.
## Instructions:
1. Clone this repository.
2. **(Optional)** To use a custom git repository for the server source, create a file named `.env` in this directory. See the "Custom Repository" section below for details.
3. Run `docker compose up -d --build` to build the images and start the services.
4. Run `docker exec -it swg bash` to log into a shell in the `swg` container.
5. Run `ant swg` to compile the game and the assets.
6. Run `ant start` to run the server.
## Custom Repository
You can configure the Docker build to pull the `swg-main` source from your own repository. Create a file named `.env` in the root of this project and add the following variables as needed.
**Example `.env` file:**
```.env
# .env file for custom repository configuration
# The full HTTPS URL to your git repository.
# If left unset, it defaults to https://github.com/SWG-Source/swg-main.git
REPO_URL=https://github.com/SWG-Source/swg-main.git
# (Optional) Credentials for private repositories.
# For security, it is highly recommended to use a Personal Access Token instead of your actual password.
REPO_USERNAME=your-gitlab-username
REPO_PASSWORD=your-personal-access-token
# (Optional) Credentials for overriding the default oracle DB
ORACLE_PASSWORD=YourSecureOraclePassword
APP_USER=YourAppUser
APP_USER_PASSWORD=YourSecureAppPassword
```

View File

@@ -7,9 +7,9 @@ services:
ports:
- "1521:1521"
environment:
ORACLE_PASSWORD: swg
APP_USER: swg
APP_USER_PASSWORD: swg
ORACLE_PASSWORD: ${ORACLE_PASSWORD:-swg}
APP_USER: ${APP_USER:-swg}
APP_USER_PASSWORD: ${APP_USER_PASSWORD:-swg}
healthcheck:
test: ["CMD", "healthcheck.sh"]
interval: 10s
@@ -28,6 +28,10 @@ services:
condition: service_healthy
build:
context: .
args:
- REPO_URL=${REPO_URL}
- REPO_USERNAME=${REPO_USERNAME}
- REPO_PASSWORD=${REPO_PASSWORD}
ports:
- "44451-44453:44451-44453/tcp"
- "44462-44464:44462-44464/tcp"
@@ -36,9 +40,9 @@ services:
environment:
DB_HOST: oracle
DB_PORT: 1521
DB_USER: swg
ORACLE_PASSWORD: swg
DB_PASSWORD: swg
DB_USER: ${APP_USER:-swg}
ORACLE_PASSWORD: ${ORACLE_PASSWORD:-swg}
DB_PASSWORD: ${APP_USER_PASSWORD:-swg}
tty: true
stdin_open: true
volumes: