summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorMike Delago <32778141+michaeldelago@users.noreply.github.com>2023-10-15 08:47:09 -0700
committerGitHub <noreply@github.com>2023-10-15 17:47:09 +0200
commitc4dc20a814451a27aef8113e829809a2b6587e3b (patch)
treea7480e17d2fdaa24eb71433d5efcd546a43bc20e /.github
parentd1d46074a6d959d03c54de584db96e893cd0b5c4 (diff)
refactor(Docker): remove prod container distinction (#17419)
* refactor(Docker): remove prod containers * workflows: use buildx * properly set tags * comment in Dockerfile * set docker build context * minor CI changes * CI: docker build args shouldnt have quotes * CI: using matrix and caching is too much work * CI: I hate yaml * CI: It was a typo * CI: extra build removed * CI: appease the linter * fixup! CI: appease the linter * fixup! CI: appease the linter * apps: docker: remove extraneous files
Diffstat (limited to '.github')
-rw-r--r--.github/actions/docker-tag-and-build/action.yml38
-rw-r--r--.github/workflows/docker_build.yml190
2 files changed, 123 insertions, 105 deletions
diff --git a/.github/actions/docker-tag-and-build/action.yml b/.github/actions/docker-tag-and-build/action.yml
new file mode 100644
index 0000000000..6a37cb53a1
--- /dev/null
+++ b/.github/actions/docker-tag-and-build/action.yml
@@ -0,0 +1,38 @@
+name: docker tag and build
+description: a helper action to shorten generating docker tags and building
+inputs:
+ component-name:
+ description: name of the component/docker image (eg worldserver, authserver)
+ type: string
+ required: true
+ push:
+ description: whether to push the image or not
+ type: boolean
+ required: true
+ version:
+ description: version tag to use for docker image
+ required: true
+ type: string
+runs:
+ using: composite
+ steps:
+ - name: Get Docker Metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: acore/ac-wotlk-${{ inputs.component-name }}
+ tags: |
+ type=raw,value=${{ inputs.version }}
+ type=ref,event=branch
+
+ - name: Build and push
+ uses: docker/build-push-action@v5
+ with:
+ context: ${{ github.workspace }}
+ file: apps/docker/Dockerfile
+ push: ${{ inputs.push }}
+ tags: ${{ steps.meta.outputs.tags }}
+ build-args: |
+ USER_ID=1000
+ GROUP_ID=1000
+ DOCKER_USER=acore
diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml
index 2dfc535eba..b3a9822cb2 100644
--- a/.github/workflows/docker_build.yml
+++ b/.github/workflows/docker_build.yml
@@ -4,7 +4,11 @@ on:
branches:
- 'master'
pull_request:
- types: ['labeled', 'opened', 'synchronize', 'reopened']
+ types:
+ - labeled
+ - opened
+ - synchronize
+ - reopened
concurrency:
group: ${{ github.head_ref }} || concat(${{ github.ref }}, ${{ github.workflow }})
@@ -12,41 +16,24 @@ concurrency:
jobs:
docker-build-n-deploy-dev:
- strategy:
- fail-fast: true
- matrix:
- os: [ubuntu-20.04]
- runs-on: ${{ matrix.os }}
+ runs-on: "ubuntu-latest"
if: |
github.repository == 'azerothcore/azerothcore-wotlk'
&& !github.event.pull_request.draft
- && (github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
+ && (github.ref_name == 'master' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
steps:
- - name: Extract branch name
- shell: bash
- run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- id: extract_branch
-
- - name: Configure
+ - name: Free up disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- docker --version
- docker compose version
- uses: actions/checkout@v4
- # we need the entire history for the ac-dev-server
- # with:
- # fetch-depth: 2
-
- # - name: Set up Docker Buildx
- # uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
@@ -55,123 +42,116 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Build Dev
- if: github.repository == 'azerothcore/azerothcore-wotlk'
- env:
- #DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
- DOCKER_CLIENT_TIMEOUT: 400
- COMPOSE_HTTP_TIMEOUT: 400
- run: |
- export DOCKER_USER_ID=$(id -u)
- export DOCKER_GROUP_ID=$(id -u)
- # pull the images first to load the docker cache layers
- #./acore.sh docker pull
- ./acore.sh docker build
- output=$(./acore.sh version | grep "AzerothCore Rev. ") && version=${output#"AzerothCore Rev. "}
- DOCKER_IMAGE_TAG=$version docker compose --profile dev --profile local build
-
- - name: Deploy Dev
- #env:
- # DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
- if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
+ - name: Get version
+ id: version
run: |
- docker compose --profile dev --profile local push
- output=$(./acore.sh version | grep "AzerothCore Rev. ") && version=${output#"AzerothCore Rev. "}
- DOCKER_IMAGE_TAG=$version docker compose --profile dev --profile local push
+ output=$(./acore.sh version | grep "AzerothCore Rev. ")
+ version=${output#"AzerothCore Rev. "}
+ echo "version=$version" >> $GITHUB_OUTPUT
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: acore/ac-wotlk-dev-server
+ tags: |
+ type=raw,value=${{ steps.version.outputs.version }}
+ type=ref,event=branch
+ - name: Build and push
+ uses: docker/build-push-action@v5
+ with:
+ context: ${{ github.workspace }}
+ file: apps/docker/Dockerfile.dev-server
+ push: ${{ github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ build-args: |
+ USER_ID=1000
+ GROUP_ID=1000
+ DOCKER_USER=acore
+
+ # TODO: rename this job
docker-build-n-deploy-prod:
- strategy:
- fail-fast: true
- matrix:
- os: [ubuntu-20.04]
- runs-on: ${{ matrix.os }}
+ runs-on: "ubuntu-latest"
if: |
github.repository == 'azerothcore/azerothcore-wotlk'
&& !github.event.pull_request.draft
- && (github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
+ && (github.ref_name == 'master' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
steps:
- - name: Extract branch name
- shell: bash
- run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- id: extract_branch
-
- - name: Configure
+ - name: Free up disk space
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- docker --version
- docker compose version
- uses: actions/checkout@v4
- # we need the entire history for the ac-dev-server
- # with:
- # fetch-depth: 2
-
- # - name: Set up Docker Buildx
- # uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
- if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
+ if: github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Cache
- uses: actions/cache@v3
- with:
- path: var/docker/ccache
- key: ccache:${{ matrix.os }}:clang:without-modules:${{ github.ref }}:${{ github.sha }}
- restore-keys: |
- ccache:${{ matrix.os }}:clang:without-modules:${{ github.ref }}
- ccache:${{ matrix.os }}:clang:without-modules
-
- - name: Build Production images
- if: github.repository == 'azerothcore/azerothcore-wotlk'
- env:
- #DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
- DOCKER_CLIENT_TIMEOUT: 220
- COMPOSE_HTTP_TIMEOUT: 220
- run: |
- export DOCKER_USER_ID=$(id -u)
- export DOCKER_GROUP_ID=$(id -u)
- # pull the images first to load the docker cache layers
- #./acore.sh docker prod:pull
- ./acore.sh docker prod:build
- output=$(./acore.sh version | grep "AzerothCore Rev. ") && version=${output#"AzerothCore Rev. "}
- DOCKER_IMAGE_TAG=$version ./acore.sh docker prod:build
- # create the container to allow the copy right after
- docker compose create ac-build-prod
- docker compose cp ac-build-prod:/azerothcore/var/ccache var/docker/
- echo "ccache exported"
-
- - name: Deploy Production images
- #env:
- # DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
- if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
+ - name: Get version
+ id: version
run: |
- docker compose --profile prod push
- output=$(./acore.sh version | grep "AzerothCore Rev. ") && version=${output#"AzerothCore Rev. "}
- DOCKER_IMAGE_TAG=$version docker compose --profile prod push
+ output=$(./acore.sh version | grep "AzerothCore Rev. ")
+ version=${output#"AzerothCore Rev. "}
+ echo "version=$version" >> $GITHUB_OUTPUT
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: build worldserver
+ uses: ./.github/actions/docker-tag-and-build
+ with:
+ component-name: worldserver
+ version: ${{ steps.version.outputs.version }}
+ push: ${{ github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master' }}
+ - name: build authserver
+ uses: ./.github/actions/docker-tag-and-build
+ with:
+ component-name: authserver
+ version: ${{ steps.version.outputs.version }}
+ push: ${{ github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master' }}
+
+ - name: build db-import
+ uses: ./.github/actions/docker-tag-and-build
+ with:
+ component-name: db-import
+ version: ${{ steps.version.outputs.version }}
+ push: ${{ github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master' }}
+
+ - name: build client-data
+ uses: ./.github/actions/docker-tag-and-build
+ with:
+ component-name: client-data
+ version: ${{ steps.version.outputs.version }}
+ push: ${{ github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master' }}
+
+ - name: build tools
+ uses: ./.github/actions/docker-tag-and-build
+ with:
+ component-name: tools
+ version: ${{ steps.version.outputs.version }}
+ push: ${{ github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master' }}
dispatch-acore-docker:
needs: [ docker-build-n-deploy-prod , docker-build-n-deploy-dev]
runs-on: ubuntu-latest
steps:
- - name: Extract branch name
- shell: bash
- run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- id: extract_branch
-
- name: Repository Dispatch
- if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
+ if: github.repository == 'azerothcore/azerothcore-wotlk' && github.ref_name == 'master'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.ACORE_DOCKER_REPO_ACCESS_TOKEN }}