Skip to content

Commit

Permalink
Merge pull request #66 from PhantazmNetwork/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Steanky authored Jan 24, 2024
2 parents dc13752 + 6cdd907 commit c063d33
Show file tree
Hide file tree
Showing 379 changed files with 7,809 additions and 9,591 deletions.
65 changes: 65 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# ============================================================================== #
# Most configurable aspects of Phantazm's Docker setup process live here. #
# Instead of directly changing these values (as they are checked into the repo), #
# create a file named .override.env at the same level as this file. Variables #
# defined there will replace the ones present here. #
# ============================================================================== #

# Default profile used by Docker Compose. Running `docker compose up` is
# therefore equivalent to `docker compose --profile nodebug up`, but it is less
# verbose.
COMPOSE_PROFILES='nodebug'

# The project name. Used by Docker to create container names, e.g.
# phantazm-phantazm_server-1. Should not be overridden or changed.
COMPOSE_PROJECT_NAME='phantazm'

# Whether to enable automatic downloading of world files. Worlds that are not
# already present in the container will be downloaded from a Google Drive host.
PHANTAZM_AUTO_DL_WORLDS='true'

# Used to let scripts like ./setup.sh know that they are running inside of a
# container. Should not be overridden or changed!
PHANTAZM_IS_DOCKER_CONTAINER='true'

# This pair of properties defines the user and group id, respectively, that
# should be used inside of the container. These should be the same as the user
# and group id of the user on the host that should be accessing the files.
PHANTAZM_UID='1000'
PHANTAZM_GID='1000'

# This pair of properties defines the ports that will be used on the host and
# container, respectively, for attaching a remote debugger.
PHANTAZM_DEBUG_PORT_HOST='5005'
PHANTAZM_DEBUG_PORT_CONTAINER='5005'

# This pair of properties defines the ports that will be used on the host and
# container, respectively, for connecting to the proxy.
PHANTAZM_PROXY_PORT_HOST='25565'
PHANTAZM_PROXY_PORT_CONTAINER='25565'

# This pair of properties defines the ports that will be used on the host and
# container, respectively, for connecting to the database. These are only opened
# because it is often desirable to connect to the database from the host; e.g.
# through adding an IntelliJ data source. It is not necessary to open them in
# order for the server container to communicate with the database container.
PHANTAZM_DB_PORT_HOST='3306'
PHANTAZM_DB_PORT_CONTAINER='3306'

# The properties below are used to configure how the server is built and
# launched, once the container is running.

# Sets the arguments that are passed to the Gradle wrapper. In order for the
# server to run, the task `phantazm-server:copyJar` must execute, as it is used
# to generate necessary files.
PHANTAZM_GRADLE_ARGS='-PskipBuild=snbt-builder,dev-launcher,velocity -w phantazm-server:copyJar --no-daemon'

# Sets the arguments passed to the JVM when running the `nodebug` profile.
PHANTAZM_SERVER_JVM_ARGS='-Dfile.encoding=UTF-8 -jar'

# Sets the arguments passed to the Phantazm server when running the `nodebug`
# profile.
PHANTAZM_SERVER_ARGS='unsafe'

# Sets the name of the server file to run.
PHANTAZM_SERVER_FILE='server.jar'
92 changes: 45 additions & 47 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,49 @@ name: Deploy to Remote
on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
cache: 'gradle'
distribution: 'adopt'
- name: Set up server
run: ./gradlew -PskipBuild=zombies-mapeditor,zombies-timer :phantazm-server:setupServer
- name: Build & copy jar
run: ./gradlew -PskipBuild=zombies-mapeditor,zombies-timer :phantazm-server:copyJar
- name: Zip server files
run: |
cd ./run/server-1
tar -czf /tmp/server.tar.gz server.jar libs
- name: Set up SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/deploy
chmod 600 ~/.ssh/deploy
cat >> ~/.ssh/config <<END
Host phantazm
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/deploy
StrictHostKeyChecking no
END
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
- name: Copy server files to remote
run: |
scp /tmp/server.tar.gz phantazm:/home/prod/archive/server.tar.gz
- name: Restart server
uses: appleboy/ssh-action@master
with:
key: ${{ secrets.SSH_KEY }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
script: |
/home/prod/archive/sync.sh
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
cache: 'gradle'
distribution: 'adopt'
- name: Build & copy jar
run: ./gradlew -PskipBuild=dev-launcher,snbt-builder,velocity :phantazm-server:copyJar
- name: Zip server files
run: |
cd ./run/server-1
tar -czf /tmp/server.tar.gz server.jar libs
- name: Set up SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/deploy
chmod 600 ~/.ssh/deploy
cat >> ~/.ssh/config <<END
Host phantazm
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/deploy
StrictHostKeyChecking no
END
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
- name: Copy server files to remote
run: |
scp /tmp/server.tar.gz phantazm:/home/prod/archive/server.tar.gz
- name: Restart server
uses: appleboy/ssh-action@master
with:
key: ${{ secrets.SSH_KEY }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
script: |
/home/prod/archive/sync.sh
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
build/
run/
local.settings.gradle.kts
.gradle-home/*
!.gradle-home/README
docker-compose.override.yml
/tmp
.override.env
setup_log.txt
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = minestom
url = https://github.com/PhantazmNetwork/Minestom
branch = master
[submodule "commons"]
path = commons
url = https://github.com/PhantazmNetwork/PhantazmShared
branch = main
2 changes: 2 additions & 0 deletions .gradle-home/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
For Phantazm, we use a project-specific Gradle Home so that Docker containers can persist cache state.
This improves build times *massively*.
9 changes: 9 additions & 0 deletions .run/Launch Phantazm (debug).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Launch Phantazm (debug)" type="JarApplication" singleton="false">
<option name="JAR_PATH" value="$PROJECT_DIR$/dev-launcher.jar" />
<option name="PROGRAM_PARAMETERS" value="-d" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
</component>
8 changes: 8 additions & 0 deletions .run/Launch Phantazm.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Launch Phantazm" type="JarApplication">
<option name="JAR_PATH" value="$PROJECT_DIR$/dev-launcher.jar" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
</component>
12 changes: 0 additions & 12 deletions .run/Run Velocity.run.xml

This file was deleted.

23 changes: 0 additions & 23 deletions .run/Run mapeditor.run.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .run/Run server + Velocity.run.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .run/Run server.run.xml

This file was deleted.

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:3.19.0 AS java_base
LABEL authors="steank"

ARG uid=1000
ARG gid=1000

ENV PHANTAZM_UID_D $uid
ENV PHANTAZM_GID_D $gid

RUN apk --no-cache add openjdk17
RUN addgroup -g "${PHANTAZM_GID_D}" -S container
RUN adduser -S -G container -u "${PHANTAZM_UID_D}" container

USER container

FROM java_base AS server_base
LABEL authors="steank"

USER root
RUN apk --no-cache add git curl unzip
USER container

FROM mariadb:11.2.2 AS mariadb
Loading

0 comments on commit c063d33

Please sign in to comment.