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>
This commit is contained in:
Giacomo Pozzoni
2021-03-05 22:22:56 +01:00
committed by GitHub
parent a34519bded
commit 84ad438d15
2 changed files with 36 additions and 7 deletions

View File

@@ -52,7 +52,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
@@ -78,10 +82,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:

View File

@@ -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 files from the TrinityCore GitHub repository to a local folder which will be passed on as a mapped volume to docker.
## Start authserver/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 authserver or worldserver as desired, mapping the required volumes: