commit a0b21c32923bfd0aa98cae6bcf5844386575883f Author: Mika Date: Tue Feb 10 18:38:13 2026 +0000 Initial commit diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..645ebf3 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +RCON_PASSWORD="" \ No newline at end of file diff --git a/.gitea/workflows/production.yml b/.gitea/workflows/production.yml new file mode 100644 index 0000000..00056ef --- /dev/null +++ b/.gitea/workflows/production.yml @@ -0,0 +1,46 @@ +name: Deploy to Production + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ + +jobs: + deploy-to-production: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + ref: main + path: . + + - name: Transfer files + uses: burnett01/rsync-deployments@7.0.1 + with: + switches: -azvr --delete --exclude=".gitignore" --exclude=".git" --exclude=".gitea" --exclude="data" --exclude=".env" + path: . + remote_path: /home/${{ secrets.USERNAME }}/minecraft-server-example-folder + remote_host: ${{ secrets.HOST }} + remote_user: ${{ secrets.USERNAME }} + remote_key: ${{ secrets.KEY }} + + - name: Stop container + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.host }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + script: | + cd minecraft-server-example-folder + docker compose down + + - name: Start container + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.host }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + script: | + cd minecraft-server-example-folder + docker compose up -d diff --git a/.gitea/workflows/restart.yml b/.gitea/workflows/restart.yml new file mode 100644 index 0000000..a69e5af --- /dev/null +++ b/.gitea/workflows/restart.yml @@ -0,0 +1,19 @@ +name: Restart Server + +on: + schedule: + - cron: '0 4 * * *' + +jobs: + restart-server: + runs-on: ubuntu-latest + steps: + - name: Restart container + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.host }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + script: | + cd minecraft-server-example-folder + docker compose restart diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f8be5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +data +.env \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..8669ee4 --- /dev/null +++ b/README.MD @@ -0,0 +1,26 @@ +# Minecraft Server Template +This is the minecraft server template that you can use to create minecraft servers. It uses the itzg/minecraft-server docker image to create the server within a docker container for ease of deployment. Documentation for the itzg/minecraft-server image can be found [here](https://docker-minecraft-server.readthedocs.io/en/latest/). + +## To run this server: +1. Use this repository as a template for a new repository. +2. Fill in the neccesary variables in the docker-compose file. +3. Copy the .env.example to a .env file and fill in the neccesary variables. +4. Run the server using `docker compose up -d`. + +## Deployment: +This server can be deployed with the provided gitea pipeline. Add the following secrets to the repository under actions -> secrets: +- `HOST`: The IP of the server. +- `USERNAME`: The username of the user. +- `KEY`: The private key to connect to the server. ( Found in 1password ) + +A deployment is automatically run when a tag is created. The tag must be in the format `vX.X.X` where X is a number. + +The pipeline `production.yml` will deploy the server when a tag is created. + +Change the directory ( `minecraft-server-example-folder` ) to the directory where the server will be located in the server. This directory must be defined in both the `production.yml` and the `restart.yml`. + + +## Important Notes: +The data directory will be created and populated with the server files the first time the server is run. please do not add these files to the repository. + +The current config is set to use Fabric, if you would like to use Forge or any other modloader, please refer to the documentation stated above. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2b38d30 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +services: + minecraft-server: + image: itzg/minecraft-server + stdin_open: true + tty: true + ports: + - "25565:25565" + - "25575:25575" + volumes: + - ./data:/data + - ./whitelist:/whitelist + environment: + EULA: "TRUE" + ENABLE_RCON: "TRUE" + RCON_PASSWORD: ${RCON_PASSWORD} + RCON_PORT: "25575" + MAX_PLAYERS: "69" + ICON: "https://example.com/icon.png" + TYPE: "PAPER" + VERSION: "1.21.4" + DIFFICULTY: "normal" + MEMORY: "2G" + INIT_MEMORY: "2G" + MAX_MEMORY: "4G" + SERVER_IP: "" + ENABLE_WHITELIST: "TRUE" + OVERRIDE_WHITELIST: "TRUE" + WHITELIST_FILE: /whitelist/whitelist.json + MOTD: "A Minecraft Server with docker" + restart: unless-stopped diff --git a/whitelist/whitelist.json b/whitelist/whitelist.json new file mode 100644 index 0000000..2af9c94 --- /dev/null +++ b/whitelist/whitelist.json @@ -0,0 +1,6 @@ +[ + { + "name":"zardzul", + "uuid":"9f0f315c-880d-48aa-a786-66ba83dcfb28" + } +] \ No newline at end of file