diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..f681406 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,105 @@ +# Configuration for Continous Integration +# +# Copyright (C) 2017 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Example to execute locally: +# gitlab-runner exec docker --kubernetes-memory-limit="10g" --kubernetes-service-memory-limit="10g" --kubernetes-memory-request="10g" --kubernetes-helper-memory-limit="10g" 'Linux server build' +# gitlab-runner exec docker --timeout=3600 'Linux server build' + + +stages: +- build + +Linux server build: + stage: build + tags: + - Docker + image: amd64/debian:9 + script: + - export -p WORKDIR=$PWD + - apt-get update + - apt-get dist-upgrade -y + - apt-get install -y bash-completion bsd-mailx cron curl debootstrap fakechroot fakeroot git jq less logrotate lzma nano net-tools openssh-server p7zip p7zip-full schroot sudo unzip vim wget xdelta +# - apt-get install -y libcurl4-openssl libfreetype6 libx11 libgl1-mesa libxxf86vm libxrandr libxrender libopenal libxml2 libpng libjpeg62-turbo libxmu libgif libssl liblzma zlib1g libssh2-1 libboost-all libopenal libgl1-mesa libtool libxml2 + - apt-get install -y libxml2 libpng16-16 libjpeg62-turbo libxmu6 libgif7 libssl1.1 liblzma5 zlib1g libssh2-1 libtool libxml2 + - DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server + - apt-get install -y apache2 apache2-utils libapache2-mod-php mcrypt php php-gd php-imagick php-mcrypt php-mysql python3 rrdtool screen + - DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin + - mkdir -p /opt/download + - export -p DIR_ARTEFACTS="/opt/download" + - (cd /opt/download ; $WORKDIR/server/common/download_artefacts.sh 'https://git.khaganat.net' 'khaganat' 'mmorpg_khanat/khanat-opennel-code' $CI_COMMIT_REF_NAME 'develop' 'master') + - mkdir -p /opt/ext + - cp $WORKDIR/server/debian/common/servercontainer_init_* /opt/ + - cp $WORKDIR/server/debian/common/servercontainer_function.sh /opt/ + - cp $WORKDIR/server/debian/common/servercontainer_configure_* /opt/ext + - cp $WORKDIR/server/debian/common/servercontainer_function.sh /opt/ext + - cp $WORKDIR/server/debian/common/khaganat.cfg /opt/ext + - echo -e 'export KHANAT_CLIENT_VERSION="1"\nexport UIDGAMESERVER=1000\nexport GIDGAMESERVER=1000\nexport DIRCLIENT="/opt/opennel_data"\nexport PACKAGECLIENT="smokey_linux64"' > /opt/khanat_config.sh + - /opt/servercontainer_init_create_account.sh + - mkdir -p /var/run/mysqld + - /opt/servercontainer_init_mysql.sh + - /opt/servercontainer_init_apache.sh + - /opt/servercontainer_init_configure_envi.sh +# - source /home/gameserver/.bashrc # doesn't work, why ? + - export -p KHANAT_HOME=/home/gameserver + - export -p KHANAT_PATH=/home/gameserver/khanat + - export -p PATH=$PATH:/usr/local/bin + - export -p PATCH_CLIENT_SYSTEM=$KHANAT_HOME/khanat/patch_service + - export -p DIRCLIENT="/opt/opennel_data" + - export -p PACKAGECLIENT="smokey_linux64" + - export -p PREPARE_CLIENT_DIR="khanat/prepare_client/$DIRCLIENT" + - export -p CLIENT_DIR="khanat/client_service" + - export -p HOME_PREPARE_CLIENT="$KHANAT_HOME/$PREPARE_CLIENT_DIR" + - export -p HOME_CLIENT="$KHANAT_HOME/$CLIENT_DIR" + - echo "KHANAT_PATH $KHANAT_PATH" + - mkdir -p $KHANAT_PATH + - mkdir -p /opt/artefacts + - (cd /opt/artefacts ; for file in /opt/download/khanat-server-debian_strech*.zip ; do echo "extract $file"; unzip -q -o $file; done) + - (cd /opt/artefacts ; for file in /opt/download/khanat-client_static-debian_strech*.zip ; do echo "extract $file"; unzip -q -o $file; done) + - mkdir -p /home/gameserver/ext + - ln -s /opt/artefacts/code/web /home/gameserver/ext/khanatweb + - ln -s /opt/artefacts/code/ryzom /home/gameserver/ext/ryzom-ressources + - (cd /home/gameserver/ext; git clone -q https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git) + #- ln -s /opt/download/khanat-ressources /home/gameserver/ext/khanat-ressources + - (cd /home/gameserver/ext; git clone -q https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git) + #- ln -s /opt/download/khanat-client-data /home/gameserver/ext/khanat-client-data + - for file in /opt/artefacts/code/build/bin/* ; do ln -s $file /usr/local/bin ; done + - for file in /opt/artefacts/code/build/lib/* ; do ln -s $file /usr/local/lib ; done + - ldconfig + - /opt/ext/servercontainer_configure_link.sh + - /opt/ext/servercontainer_configure_mysql.sh -d + - /opt/ext/servercontainer_configure_apache.sh + - /opt/ext/servercontainer_configure_world.sh + - su -c '/opt/ext/servercontainer_configure_khanat.sh' gameserver + - su -c '/opt/ext/servercontainer_configure_patch.sh' gameserver + - su -c '/opt/ext/servercontainer_configure_launcher.sh' gameserver + - su -c 'touch /home/gameserver/khanat/step_configure.ok' gameserver + # Clean + - rm -f /opt/servercontainer* + - rm -f /opt/ext/servercontainer* + # Create image + - mkdir -p out + - tar --numeric-owner --exclude=.git --exclude=/proc --exclude=/sys --exclude=/home --exclude=/builds --exclude=/opt/artefacts -cf out/debian_server.tar / + - ls /home + - pwd + - ls -lh + - ls -lh out + artifacts: + name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-server-debian-stretch" + paths: + - out + expire_in: 2 day +