aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2021-01-16 21:30:57 +0100
committerGitHub <noreply@github.com>2021-01-16 21:30:57 +0100
commit9af6bf15aa2fe836c3ebba306eaaa8971f00fac4 (patch)
tree4cad60a76d90acc2b2424fd79cf33e0359c26e6f
parent15d69bd885adca7070d3819493519065f02b35ca (diff)
CI/CircleCI: Expose binaries built on Circle CI as docker images in the Circle CI artifacts (#25832)
Co-authored-by: Shauren <shauren.trinity@gmail.com>
-rw-r--r--.circleci/config.yml16
-rw-r--r--contrib/Docker/Dockerfile8
-rw-r--r--contrib/Docker/README.md54
-rw-r--r--src/common/Utilities/StartProcess.cpp11
4 files changed, 86 insertions, 3 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 8a6807f79a7..50db90b8aba 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -52,7 +52,7 @@ jobs:
command: |
mkdir bin
cd bin
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=dynamic -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
+ 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
cd ..
- run:
name: Build
@@ -70,6 +70,20 @@ jobs:
cd bin/check_install/bin
./authserver --version
./worldserver --version
+ - setup_remote_docker:
+ version: 19.03.13
+ - run:
+ name: Create docker images
+ command: |
+ 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:]')
+ 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
+ - store_artifacts:
+ path: docker.tar.gz
nopch:
docker:
- image: trinitycore/circle-ci:3.3.5-buildpacks-focal
diff --git a/contrib/Docker/Dockerfile b/contrib/Docker/Dockerfile
new file mode 100644
index 00000000000..e4392c5b3d0
--- /dev/null
+++ b/contrib/Docker/Dockerfile
@@ -0,0 +1,8 @@
+FROM trinitycore/circle-ci:3.3.5-buildpacks-focal
+
+#Setup
+WORKDIR /home/circleci
+COPY README.md /
+COPY --chown=circleci:circleci sql /home/circleci/project/sql
+COPY ["authserver", "mapextractor", "mmaps_generator", "vmap4assembler", "vmap4extractor", "worldserver", "/usr/local/bin/"]
+ENTRYPOINT [ "echo", "Check the README.md file for instructions"]
diff --git a/contrib/Docker/README.md b/contrib/Docker/README.md
new file mode 100644
index 00000000000..a39f943b8a7
--- /dev/null
+++ b/contrib/Docker/README.md
@@ -0,0 +1,54 @@
+# Docker
+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 store that in the job artifacts.
+
+The instructions below expect basic knowledge about how to configure TrinityCore and how to use Docker:
+1. Click on the green ✔ next to each commit
+1. Scroll to "ci/circleci: pch" and click on "Details"
+1. Login to Circle CI if necessary. You might have to repeat again the previous steps after logging in to reach the correct page
+1. Click on "Artifacts" tab in Circle CI website
+1. Download the docker.tar.gz archive containing the docker image
+1. Load the image into your Docker host using
+ ```
+ docker load -i docker.tar.gz
+ ```
+1. Copy the .conf files from TrinityCore GitHub repository to a local folder that will be passed as 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
+ - authserver
+ ```
+ docker run --entrypoint=authserver -it --volume=/host/path/to/configs:/home/circleci/project/bin/check_install/etc --volume=/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock -p=3724:3724 "image name"
+ ```
+ - worldserver
+ ```
+ docker run --entrypoint=worldserver -it --volume=/host/path/to/configs:/home/circleci/project/bin/check_install/etc --volume=/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock --volume=/path/to/data/directory:/trinity/data -p=8085:8085 "image name"
+ ```
+ Change the ports and other parameters as needed. Consult Docker documentation for additional details about possible configuration settings.
+
+## Content
+The image contains:
+- authserver
+- mapextractor
+- mmaps_generator
+- vmap4asembler
+- vmap4extractor
+- worldserver
+- README&#46;md
+
+You can explore the image using
+```
+docker run --entrypoint=/bin/bash -it "image name"
+```
+Note that the WORKDIR is set to /home/circleci and by default all logs will be saved in that folder. You can export the logs from the container with
+```
+docker cp "container name":/home/circleci/name.log name.log
+```
+
+For more instructions please check docker official documentation.
+
+## Limitations:
+- Database connection: the instructions provided expect MySQL to run on the host machine. Change ``docker run`` parameters and .conf settings to fit your scenario
+- To import TDB using the autoupdater:
+ 1. Download the TDB sql file from GitHub
+ 1. Map it with ``--volume=/path/to/TDB_full_name.sql:/home/circleci/TDB_full_name.sql`` added to the commands specified in the main steps above
+ 1. Run the container
diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp
index ab81f4db5df..5c8e0f79763 100644
--- a/src/common/Utilities/StartProcess.cpp
+++ b/src/common/Utilities/StartProcess.cpp
@@ -81,17 +81,24 @@ static int CreateChildProcess(T waiter, std::string const& executable,
executable.c_str(), boost::algorithm::join(argsVector, " ").c_str());
}
+ // prepare file with only read permission (boost process opens with read_write)
+ std::shared_ptr<FILE> inputFile(!input.empty() ? fopen(input.c_str(), "rb") : nullptr, [](FILE* ptr)
+ {
+ if (ptr != nullptr)
+ fclose(ptr);
+ });
+
// Start the child process
child c = [&]()
{
- if (!input.empty())
+ if (inputFile)
{
// With binding stdin
return child{
exe = boost::filesystem::absolute(executable).string(),
args = argsVector,
env = environment(boost::this_process::environment()),
- std_in = input,
+ std_in = inputFile.get(),
std_out = outStream,
std_err = errStream
};