Skip to content

Commit

Permalink
Feat(Docker/bash): docker-compose system rework (azerothcore#4488)
Browse files Browse the repository at this point in the history
## ⚠️ATTENTION! ⚠️ Upgrading procedure:

**Database:** After this PR will be merged you need to backup your DB first (you can use the db-assembler or any mysql client to generate the dump) and restore it after.  The reason is that we use now docker named volumes instead of binded ones to improve performance.

**Conf & client data**: if you use the default configuration, both the etc and the data folder are now available inside the **/env/docker**. 

Finally, you can cleanup the /docker folder previously used by our system.

## Changes Proposed:

This PR will implement the [devcontainer ](https://code.visualstudio.com/docs/remote/containers) feature for VSCode. Allowing us to develop and debug directly within the container in the same way on all OSes.

* Implemented support for vscode dev-container feature by remote-extension suite
* Docker performance optimizations for MacOS and non-linux hosts
* Bash system improvements
* Implemented first command using Deno runtime environment (typescript) and [commander.js]
* Implemented wait mechanism for db_assembler
* Implemented db migration command
* possibility to run the authserver and worldserver with GDB using the integrated simple-restarter
* Implemented docker multi-stage mechanism to use one single Dockerfile for all the services
* client-data downloader now creates a placeholder to avoid downloading the same version of data files multiple times
* deployment of pre-compiled docker images on [docker hub](https://hub.docker.com/u/acore), you can test them [here](https://github.com/azerothcore/acore-docker)
  • Loading branch information
Yehonal authored Apr 22, 2021
1 parent 4a8faaf commit 380f406
Show file tree
Hide file tree
Showing 100 changed files with 2,746 additions and 776 deletions.
53 changes: 53 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "ac-dev-server",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml",
"../docker-compose.override.yml", // needed until this issue will be solved: https://github.com/microsoft/vscode-remote-release/issues/1080
"docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "ac-dev-server",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/azerothcore",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": null
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"notskm.clang-tidy",
"xaver.clang-format",
"bbenoist.doxygen",
"ms-vscode.cpptools",
"austin.code-gnu-global",
"twxs.cmake",
"mhutchie.git-graph",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"cschlosser.doxdocgen"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line if you want start specific services in your Docker Compose config.
"runServices": ["ac-dev-server", "ac-database"],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "acore"
}
35 changes: 35 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.9'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
ac-dev-server:
# If you want add a non-root user to your Dockerfile, you can use the "remoteUser"
# property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks,
# debugging) to execute as the user. Uncomment the next line if you want the entire
# container to run as this user instead. Note that, on Linux, you may need to
# ensure the UID and GID of the container user you create matches your local user.
# See https://aka.ms/vscode-remote/containers/non-root for details.
#
# user: vscode

# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array). The sample below assumes your primary file is in the root of your project.
#
# build:
# context: .
# dockerfile: .devcontainer/Dockerfile

#volumes:
# Update this to wherever you want VS Code to mount the folder of your project
#- .:/workspace:cached

# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details.
# - /var/run/docker.sock:/var/run/docker.sock

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
# - SYS_PTRACE
# security_opt:
# - seccomp:unconfined
tty: true
20 changes: 11 additions & 9 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
build*/
var/*
data/contrib/*
data/doc/*
conf/*
!conf/dist
docker/worldserver/data/*
docker/build/cache
/cmake-build-debug/*
/build*/
/var/*
/env/dist/*
/env/user/*
/env/docker/data/*
/env/docker/logs/*
/env/docker/etc/*
!/env/docker/etc/authserver.conf.dockerdist
!/env/docker/etc/worldserver.conf.dockerdist
/.env*
.idea
cmake-build-debug/*
12 changes: 0 additions & 12 deletions .env.dist

This file was deleted.

67 changes: 22 additions & 45 deletions .github/workflows/core_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,62 +139,39 @@ jobs:
name: windows-2019-MSVC16-release
path: build/bin/Release

docker-build:
strategy:
fail-fast: true
runs-on: ubuntu-20.04
if: github.repository == 'azerothcore/azerothcore-wotlk'
steps:
- uses: actions/checkout@v2
- name: Configure
run: |
docker --version
docker-compose --version
- name: Build
run: |
./bin/acore-docker-build-no-scripts
docker-worldserver:
docker-build-n-deploy:
strategy:
fail-fast: true
runs-on: ubuntu-20.04
if: github.repository == 'azerothcore/azerothcore-wotlk'
env:
DOCKER_EXTENDS_BIND: abstract-no-bind
DOCKER_BUILD_WORLD_TARGET: worldserver
DOCKER_BUILD_AUTH_TARGET: authserver
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- uses: actions/checkout@v2
- name: Configure
run: |
docker --version
docker-compose --version
- name: Build
#env:
# DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
run: |
docker build -t azerothcore/worldserver -f docker/worldserver/Dockerfile docker/worldserver
docker-authserver:
strategy:
fail-fast: true
runs-on: ubuntu-20.04
if: github.repository == 'azerothcore/azerothcore-wotlk'
steps:
- uses: actions/checkout@v2
- name: Configure
run: |
docker --version
docker-compose --version
- name: Build
docker-compose --profile all build
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy
#env:
# DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
if: ${{ steps.extract_branch.outputs.branch == 'master' }}
run: |
docker build -t azerothcore/authserver -f docker/authserver/Dockerfile docker/authserver
docker-compose --profile all push
docker-database:
strategy:
fail-fast: true
runs-on: ubuntu-20.04
if: github.repository == 'azerothcore/azerothcore-wotlk'
steps:
- uses: actions/checkout@v2
- name: Configure
run: |
docker --version
docker-compose --version
- name: Build
run: |
docker build -t azerothcore/database -f docker/database/Dockerfile .
47 changes: 21 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@
# AzerothCore
#

conf/*
!conf/dist
apps/drassil/*
env/dist/*
env/user/*
modules/*
!modules/*.md
!modules/*.sh
build*/
var/*
docker/build/cache
docker/authserver/bin
docker/worldserver/bin
docker/authserver/etc/authserver.conf
docker/authserver/etc/authserver.conf.dist
docker/worldserver/etc/worldserver.conf
docker/worldserver/etc/worldserver.conf.dist
docker/authserver/logs/
docker/worldserver/logs/
docker/worldserver/data/
!docker/build
.env
apps/joiner
/conf/*
!/conf/dist
/modules/*
!/modules/*.md
!/modules/*.sh
/build*/
/var/*
/env/dist/*
/env/user/*
/env/docker/data/*
/env/docker/logs/*
/env/docker/etc/*
!/env/docker/etc/authserver.conf.dockerdist
!/env/docker/etc/worldserver.conf.dockerdist
/.env*
/apps/joiner
/deps/deno

/docker-compose.override.yml

!.gitkeep

Expand Down Expand Up @@ -59,7 +55,6 @@ nbproject/
.sync.ffs_db
*.kate-swp
.browse.VC*
.vscode
.idea
cmake-build-debug/*
cmake-build-debug-coverage/*
Expand All @@ -85,9 +80,9 @@ local.properties
# ==================
#
# CUSTOM
#
#
# put below your custom ignore rules
# for example , if you want to include a
# for example , if you want to include a
# module directly in repositoryyou can do:
#
# !modules/yourmodule
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/git-subrepo"]
path = deps/git-subrepo
url = https://github.com/ingydotnet/git-subrepo.git
15 changes: 15 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"recommendations": [
"ms-vscode-remote.remote-containers",
"notskm.clang-tidy",
"xaver.clang-format",
"bbenoist.doxygen",
"ms-vscode.cpptools",
"austin.code-gnu-global",
"twxs.cmake",
"mhutchie.git-graph",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"cschlosser.doxdocgen"
]
}
68 changes: 68 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Linux/Docker debug",
"type": "cppdbg",
"request": "launch",
"program": "/azerothcore/env/dist/bin/worldserver",
"cwd": "/azerothcore",
"args": [],
"environment": [],
"externalConsole": false,
"sourceFileMap": {
"/azerothcore": "${workspaceFolder}"
},
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
}
},
{
"name": "(docker run) Pipe Launch",
"type": "cppdbg",
"request": "launch",
"program": "/azerothcore/env/dist/bin/worldserver",
"cwd": "/azerothcore",
"args": [],
"environment": [],
"externalConsole": true,
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "docker-compose",
"pipeArgs": [
"exec", "-T", "ac-worldserver", "sh", "-c"
],
"pipeCwd": "${workspaceFolder}"
},
"sourceFileMap": {
"/azerothcore": "${workspaceFolder}"
},
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
}
}
]
}
Loading

0 comments on commit 380f406

Please sign in to comment.