aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2021-03-05 22:22:56 +0100
committerShauren <shauren.trinity@gmail.com>2022-03-06 23:59:14 +0100
commit72bb73b2465e34f9c658bd496717f3fbb9be21e5 (patch)
tree0b23421ce222dce2e7089fb986a43aea54851186
parentfc456f7512b3a5f1f5fdc5b17877018892070e4d (diff)
Push docker images to DockerHub (#26177)
* CI/CircleCI: Push docker images to DockerHub Push docker image to DockerHub is DOCKERHUB_PUSH_IMAGES environmental variable is set to "TRUE". * Build in Release only if pushing the images to dockerhub * Move branch from repository name to tag name * Update docker readme Co-authored-by: Trond B. Krokli <38162891+illfated@users.noreply.github.com> (cherry picked from commit 84ad438d15cffd7dca0e67d540cd41946b946bed)
-rw-r--r--.circleci/config.yml19
-rw-r--r--contrib/Docker/README.md24
2 files changed, 36 insertions, 7 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 4d75ee671b8..d22495f7501 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -58,7 +58,11 @@ jobs:
command: |
mkdir bin
cd bin
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=static -DSERVERS=1 -DNOJEM=0 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_CXX_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_INSTALL_PREFIX=check_install -DBUILD_TESTING=1
+ if [ "$DOCKERHUB_PUSH_IMAGES" == "TRUE" ]; then
+ cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=static -DSERVERS=1 -DNOJEM=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=check_install -DBUILD_TESTING=1
+ else
+ cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=static -DSERVERS=1 -DNOJEM=0 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_CXX_FLAGS_DEBUG="-DNDEBUG" -DCMAKE_INSTALL_PREFIX=check_install -DBUILD_TESTING=1
+ fi
cd ..
- run:
name: Build
@@ -84,10 +88,17 @@ jobs:
cd bin/check_install/bin
cp -r ../../../contrib/Docker/* .
cp -r ../../../sql ./sql
- image_prefix=$(echo $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME-$(echo $CIRCLE_BRANCH | tr '/' '-') | tr '[:upper:]' '[:lower:]')
+ image_prefix=$(echo $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME | tr '[:upper:]' '[:lower:]')
echo $image_prefix
- docker build --file Dockerfile --force-rm --tag $image_prefix:$CIRCLE_SHA1 --tag $image_prefix:latest .
- docker save $image_prefix:$CIRCLE_SHA1 | gzip > ../../../docker.tar.gz
+ docker build --file Dockerfile --force-rm --tag $image_prefix:$CIRCLE_SHA1 --tag $image_prefix:$(echo $CIRCLE_BRANCH | tr '/' '-' | tr '[:upper:]' '[:lower:]') .
+ docker save $image_prefix | gzip > ../../../docker.tar.gz
+ if [ "$DOCKERHUB_PUSH_IMAGES" == "TRUE" ]; then
+ if [ "$CIRCLE_BRANCH" == "3.3.5" ] || [ "$CIRCLE_BRANCH" == "master" ]; then
+ docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
+ echo "Pushing docker image to dockerhub"
+ docker push $image_prefix
+ fi
+ fi
- store_artifacts:
path: docker.tar.gz
nopch:
diff --git a/contrib/Docker/README.md b/contrib/Docker/README.md
index 79dd6853f05..dc5dfe03dc0 100644
--- a/contrib/Docker/README.md
+++ b/contrib/Docker/README.md
@@ -1,8 +1,25 @@
# Docker
-The Circle CI Linux pch job uses the Dockerfile contained in the same folder as this README to create an image with the binaries built for Linux, and stores that in the job artifacts.
+The Circle CI Linux pch job uses the Dockerfile contained in the same folder as this README to create an image with the binaries built for Linux, and stores that in the job artifacts. For the 3.3.5 and master branches, it also pushes the images to https://hub.docker.com/r/trinitycore/trinitycore .
-The instructions below expect a basic knowledge of how to configure TrinityCore and how to use Docker:
+The instructions below expect a basic knowledge of how to configure TrinityCore and how to use Docker.
+
+## Load the Docker image
+For the 3.3.5 and master branches, it's possible to pull the images from DockerHub.
+- For latest 3.3.5, use the following command:
+ ```
+ docker pull trinitycore/trinitycore:3.3.5
+ ```
+- For latest master, use the following command:
+ ```
+ docker pull trinitycore/trinitycore:master
+ ```
+- For a specific 3.3.5 or master commit, use the following command, replacing "commit_hash" with the hash of the commit:
+ ```
+ docker pull trinitycore/trinitycore:commit_hash
+ ```
+
+For Pull Requests or branches other than 3.3.5 or master, follow the steps below to load the image from Circle CI:
1. Click the green tick ✔ next to each commit.
1. Scroll to "ci/circleci: pch" and click "Details".
1. Log in to Circle CI if necessary. You may have to repeat the previous steps after logging in, to reach the correct page.
@@ -13,7 +30,8 @@ The instructions below expect a basic knowledge of how to configure TrinityCore
docker load -i docker.tar.gz
```
-1. Copy the .conf and .pem files from the TrinityCore GitHub repository to a local folder which will be passed on as a mapped volume to docker.
+## Start bnetserver/worldserver from Docker
+1. Copy the .conf files from the TrinityCore GitHub repository to a local folder which will be passed on as a mapped volume to Docker.
1. Set the MySQL host in the .conf files to use the UNIX socket of MySQL, i.e.: `".;/var/run/mysqld/mysqld.sock;username;password;database"`
1. Set the "DataDir" config in worldserver.conf to `"/trinity/data"`
1. Start bnetserver or worldserver as desired, mapping the required volumes: