From e2ddc32715970421f4570cafa0ff8a26311d3791 Mon Sep 17 00:00:00 2001 From: AngrySoundTech Date: Tue, 16 Apr 2024 11:27:27 -0400 Subject: [PATCH] Assimilate CivDocker --- containers/LICENSE.txt => LICENSE.txt | 2 +- README.md | 31 +++-- containers/.github/workflows/build.yml | 78 ----------- .../.github/workflows/update-plugin.yml | 57 -------- containers/.gitignore | 11 -- containers/README.md | 17 --- containers/docker-compose.yml | 126 ------------------ docker-compose.yml | 54 +++++++- 8 files changed, 76 insertions(+), 300 deletions(-) rename containers/LICENSE.txt => LICENSE.txt (93%) delete mode 100644 containers/.github/workflows/build.yml delete mode 100644 containers/.github/workflows/update-plugin.yml delete mode 100644 containers/.gitignore delete mode 100644 containers/README.md delete mode 100644 containers/docker-compose.yml diff --git a/containers/LICENSE.txt b/LICENSE.txt similarity index 93% rename from containers/LICENSE.txt rename to LICENSE.txt index 1a3d04d62..0c21b361f 100644 --- a/containers/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2012-2021 AngrySoundTech +Copyright (c) 2023 CivMC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index dbdcf92d9..d7f7010fa 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,30 @@ A docker compose stack is provided to help test containers built from this repo. To start the stack, run the following command: `docker compose up --build`. Please note that this stack is NOT suitable for production use. +Container data (world, logs, etc.) are mounted at [./containers/data](./containers/data). + Optional services may be started by enabling the profile flag, e.g. `--profile ` Current services and exposed ports are: -| Name | Ports | Description | Profile | -|----------|-------|---------------------|------------| -| pvp | | | | -| mariadb | 3306 | TCP, Database | | -| postgres | 5432 | TCP, Database | | -| rabbitmq | 5672 | TCP, AMQP | | -| | 15672 | HTTP, Management UI | | -| grafana | 3000 | HTTP, Grafana UI | monitoring | +| Name | Ports | Description | Profile | +|-----------|-------|---------------------|------------| +| waterfall | 25565 | TCP, Minecraft | | +| paper | | | | +| pvp | | | | +| mariadb | 3306 | TCP, Database | | +| postgres | 5432 | TCP, Database | | +| rabbitmq | 5672 | TCP, AMQP | | +| | 15672 | HTTP, Management UI | | +| grafana | 3000 | HTTP, Grafana UI | monitoring | + +#### Using the console +For the minecraft servers and other interactive containers, you can attach to the console to run commands: + +1. run `docker ps` +2. Note the name of the container. By default, randomly generated. +3. Run `docker attach `, for example: `docker attach 81dcee85c1da` + +## Licencing +This project and any subprojects not otherwise containing a licence file are licenced under the MIT licence. +Individual plugins may be subject to their own licences, please check the respective plugin directories for details. diff --git a/containers/.github/workflows/build.yml b/containers/.github/workflows/build.yml deleted file mode 100644 index ee778758c..000000000 --- a/containers/.github/workflows/build.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Build - -on: - push: - branches: - - '*' - tags: - - 'v*.*.*' - pull_request: - branches: - - 'master' - workflow_dispatch: - -jobs: - build: - name: Build - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Waterfall - Docker meta - id: waterfall-meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/civmc/civdocker/waterfall - tags: | - type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Paper - Docker meta - id: paper-meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/civmc/civdocker/paper - tags: | - type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Login to Github Packages - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Waterfall Docker image - uses: docker/build-push-action@v5 - with: - context: waterfall - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.waterfall-meta.outputs.tags }} - labels: ${{ steps.waterfall-meta.outputs.labels }} - - - name: Build and push Paper Docker image - uses: docker/build-push-action@v5 - with: - context: paper - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.paper-meta.outputs.tags }} - labels: ${{ steps.paper-meta.outputs.labels }} - - - diff --git a/containers/.github/workflows/update-plugin.yml b/containers/.github/workflows/update-plugin.yml deleted file mode 100644 index a88784b8a..000000000 --- a/containers/.github/workflows/update-plugin.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: 'Update Plugin' - -# This workflow is still very much WIP, and more of a POC than anything right now. -# Inputs and such may very well change depending on what the parent repo -# ends up providing, but I'm kind of working backwards here. -on: - workflow_dispatch: - inputs: - plugin: - description: The plugin from this organization to update - required: true - type: string - version: - description: The release version to update to - required: true - type: string - asset_pattern: - description: The asset to update to - required: true - type: string -env: - GH_TOKEN: ${{ github.token }} - -jobs: - update_plugin: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set git user - run: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" && git config user.name "github-actions[bot]" - - - name: Extract branch name - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - id: extract_branch - - - name: List Releases - run: gh release list -R ${{ github.repository_owner }}/${{ inputs.plugin }} - - - name: Create Branch - run: git checkout -b feature/update-${{ inputs.plugin }}-${{ inputs.version }} - - - name: Remove old version - working-directory: paper/plugins - run: shopt -s nocaseglob && rm ${{ inputs.plugin }}* - - - name: Download latest release - working-directory: paper/plugins - run: gh release download -R ${{ github.repository_owner }}/${{ inputs.plugin }} ${{ inputs.version }} -p ${{ inputs.asset_pattern}} - - - name: Commit and push branch - run: git add . && git commit -m "${{ inputs.plugin }}-${{ inputs.version }}" && git push -u origin feature/update-${{ inputs.plugin }}-${{ inputs.version }} - - - name: Create PR - run: gh pr create -B ${{ steps.extract_branch.outputs.branch }} -H feature/update-${{ inputs.plugin }}-${{ inputs.version }} -t "Update ${{ inputs.plugin }}-${{ inputs.version }}" -b "Update ${{ inputs.plugin }}-${{ inputs.version }}" diff --git a/containers/.gitignore b/containers/.gitignore deleted file mode 100644 index e1a0896c0..000000000 --- a/containers/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -# Project -local/ - -# Editors -## Jetbrains -.idea -*.iml -*.iws - -## Vim -*.swp diff --git a/containers/README.md b/containers/README.md deleted file mode 100644 index 24e3825b4..000000000 --- a/containers/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# CivDocker - -## Development -1. run `docker-compose up` -2. Connect to minecraft server at `localhost:25565` - -Container data (world, logs, etc.) are mounted at [./local](./local). -The `data` directory therin is provided for local verification, -and should not be used in prod. - -If changes are made to the docker build, -you need to use `docker-compose up --build` next time you run. - -## Using the console -1. run `docker ps` -2. Note the name of the container. By default, randomly generated. -3. Run `docker attach `, for example: `docker attach 81dcee85c1da` diff --git a/containers/docker-compose.yml b/containers/docker-compose.yml deleted file mode 100644 index def9a5720..000000000 --- a/containers/docker-compose.yml +++ /dev/null @@ -1,126 +0,0 @@ -version: '3.9' - -services: - - waterfall: - build: waterfall - restart: unless-stopped - tty: true - stdin_open: true - depends_on: - mariadb: - condition: service_healthy - postgres: - condition: service_healthy - rabbitmq: - condition: service_healthy - environment: - CIV_POSTGRES_HOST: postgres - CIV_POSTGRES_USERNAME: postgres - CIV_POSTGRES_PASSWORD: postgres - ports: - - "25565:25577" - - paper: - build: paper - restart: unless-stopped - tty: true - stdin_open: true - depends_on: - mariadb: - condition: service_healthy - postgres: - condition: service_healthy - ports: - - "8123:8123" - environment: - INIT_MEMORY: 1G - MAX_MEMORY: 5G - - CIV_SERVER_NAME: local - - CIV_WORLD_GENERATOR: Terra:DEFAULT - CIV_WORDBANK_SEED: wordbank - - CIV_MYSQL_HOST: mariadb - CIV_MYSQL_USERNAME: mariadb - CIV_MYSQL_PASSWORD: mariadb - - CIV_POSTGRES_HOST: postgres - CIV_POSTGRES_USERNAME: postgres - CIV_POSTGRES_PASSWORD: postgres - - CIV_RABBITMQ_HOST: rabbitmq - CIV_RABBITMQ_USERNAME: rabbitmq - CIV_RABBITMQ_PASSWORD: rabbitmq - volumes: - - ./local/paper:/data - - mariadb: - image: mariadb:10.7.1 - restart: unless-stopped - command: --max-connections 500 - healthcheck: - test: [ "CMD-SHELL", 'mysqladmin ping --user "$$MYSQL_USER" --password="$$MYSQL_PASSWORD"' ] - timeout: 20s - retries: 10 - ports: - - "3306:3306" - environment: - MYSQL_ROOT_PASSWORD: mariadb - MYSQL_USER: mariadb - MYSQL_PASSWORD: mariadb - MYSQL_DATABASE: mariadb - volumes: - - ./provisioning/mariadb/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d - - ./local/mariadb:/var/lib/mysql - - postgres: - image: timescale/timescaledb:latest-pg14 - restart: unless-stopped - healthcheck: - test: ["CMD-SHELL", 'pg_isready -U "$$POSTGRES_USER"'] - interval: 10s - timeout: 5s - retries: 5 - ports: - - "5432:5432" - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - volumes: - - ./provisioning/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d - - ./local/postgres:/var/lib/postgresql/data - - rabbitmq: - image: rabbitmq:3.9.16-management - restart: unless-stopped - healthcheck: - test: ["CMD", "rabbitmq-diagnostics", "ping"] - interval: 60s - timeout: 10s - retries: 5 - ports: - - "5672:5672" - environment: - RABBITMQ_DEFAULT_USER: rabbitmq - RABBITMQ_DEFAULT_PASS: rabbitmq - - grafana: - image: grafana/grafana-oss:latest - restart: unless-stopped - depends_on: - postgres: - condition: service_healthy - profiles: - - extra - ports: - - "3000:3000" - environment: - CIV_INFLUX_HOST: http://influx:8086 - CIV_INFLUX_ORG: CivMC - CIV_INFLUX_TOKEN: admintoken - volumes: - - ./grafana/provisioning:/etc/grafana/provisioning - diff --git a/docker-compose.yml b/docker-compose.yml index 716edeea8..498e1c5cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.9' - # Development stack for Civ. This stack can be used to develop and test the server and plugins locally. # Please note that this stack is NOT suitable for production use, as it exposes all service ports, and uses default passwords. @@ -9,6 +7,58 @@ services: ### Minecraft ### ################# + waterfall: + build: containers/waterfall + restart: unless-stopped + tty: true + stdin_open: true + depends_on: + mariadb: + condition: service_healthy + postgres: + condition: service_healthy + rabbitmq: + condition: service_healthy + environment: + CIV_POSTGRES_HOST: postgres + CIV_POSTGRES_USERNAME: postgres + CIV_POSTGRES_PASSWORD: postgres + ports: + - "25565:25577" + + paper: + build: containers/paper + restart: unless-stopped + tty: true + stdin_open: true + depends_on: + mariadb: + condition: service_healthy + postgres: + condition: service_healthy + environment: + INIT_MEMORY: 1G + MAX_MEMORY: 5G + + CIV_SERVER_NAME: local + + CIV_WORLD_GENERATOR: Terra:DEFAULT + CIV_WORDBANK_SEED: wordbank + + CIV_MYSQL_HOST: mariadb + CIV_MYSQL_USERNAME: mariadb + CIV_MYSQL_PASSWORD: mariadb + + CIV_POSTGRES_HOST: postgres + CIV_POSTGRES_USERNAME: postgres + CIV_POSTGRES_PASSWORD: postgres + + CIV_RABBITMQ_HOST: rabbitmq + CIV_RABBITMQ_USERNAME: rabbitmq + CIV_RABBITMQ_PASSWORD: rabbitmq + volumes: + - ./containers/data/paper:/data + pvp: build: containers/pvp restart: unless-stopped