Skip to content

Deployment

Rasmus Nielsen edited this page Sep 15, 2021 · 9 revisions

Services | Scripts | Persistence


The idea of using Docker as a deployment tool came naturally when we decided about hosting a Minecraft server. Docker has been around for enough time to have substantial documentation and support online, and as for minecraft even longer.
Deploying a docker container can be as straightforward as running docker run <image>
However automating an entire setup requires more configuration. For this purpose we use Docker-Compose that allows us to configure many containers in one go.
Here we are setting the details of two services that will run in their own containers:

Services

  sqldb:
    image: mysql:5.7
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - "./db_data:/var/lib/mysql"
      - "./docker-scripts:/docker-entrypoint-initdb.d"
    restart: always
    ports:
      - "3306:3306"
    expose:
      - "3306"
    environment: 
      MYSQL_ROOT_PASSWORD: skt
      # MYSQL_DATABASE: dynmap
      MYSQL_USER: pingu
      MYSQL_PASSWORD: skt
    networks:
      - mcnet
  spigot:
    depends_on: 
      - sqldb
    build:
      context: .
      dockerfile: Dockerfile
    links:
      - sqldb:sqldb
    expose:
      - "22"
      - "25565"
      - "8123"
      - "25575"
    ports:
      - "2220:22"     # ssh
      - "25565:25565" # minecraft
      - "8123:8123"   # dynmap
      - "25575:25575" # rcon
    volumes: 
      - ./mc:/data
    environment: 
      XMS: "16G" # Starting Memory
      XMX: "16G" # Max Memory Usage
      EULA: "TRUE"
    networks: 
      - mcnet 

Scripts

Through scripts such as this setup.sh we download some files that does not need to be on our GitHub.

# Download Spigot
curl -L -o /data/spigot.jar https://download.getbukkit.org/spigot/spigot-1.17.1.jar

Persistence

We allocate a space on the server to save the world generated by Minecraft.

# sqldb
volumes:
   - "./db_data:/var/lib/mysql"
   - "./docker-scripts:/docker-entrypoint-initdb.d"

# spigot
volumes: 
   - "./mc:/data"

FlipFlop - A minecraft server project

Content: Docker | Scripts | Persistance

Content: Users | Network | Accessibility | Backup | Risk-Analysis

Clone this wiki locally