diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55e4b55..7b938c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,9 @@ stages: - test - build + - deploy include: - local: .gitlab/ci/test.gitlab-ci.yml - - local: .gitlab/ci/build.gitlab-ci.yml \ No newline at end of file + - local: .gitlab/ci/build.gitlab-ci.yml + - local: .gitlab/ci/deploy.gitlab-ci.yml \ No newline at end of file diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index b7a0716..6c1c29b 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -3,13 +3,8 @@ build: image: debian:stable-slim script: - rm -rf tests .git .gitignore script - artifacts: name: multi_user paths: - multi_user - only: - refs: - - master - - develop diff --git a/.gitlab/ci/deploy.gitlab-ci.yml b/.gitlab/ci/deploy.gitlab-ci.yml new file mode 100644 index 0000000..6cbc1ff --- /dev/null +++ b/.gitlab/ci/deploy.gitlab-ci.yml @@ -0,0 +1,18 @@ +deploy: + stage: deploy + image: slumber/docker-python + variables: + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "/certs" + + services: + - docker:19.03.12-dind + + script: + - RP_VERSION="$(python scripts/get_replication_version.py)" + - VERSION="$(python scripts/get_addon_version.py)" + - echo "Building docker image with replication ${RP_VERSION}" + - docker build --build-arg replication_version=${RP_VERSION} --build-arg version={VERSION} -t registry.gitlab.com/slumber/multi-user/multi-user-server:${VERSION} ./scripts/docker_server + - echo "Pushing to gitlab registry ${VERSION}" + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker push registry.gitlab.com/slumber/multi-user/multi-user-server:${VERSION} diff --git a/scripts/docker_server/Dockerfile b/scripts/docker_server/Dockerfile new file mode 100644 index 0000000..179501f --- /dev/null +++ b/scripts/docker_server/Dockerfile @@ -0,0 +1,24 @@ +# Download base image debian jessie +FROM python:slim + +ARG replication_version=0.0.21a15 +ARG version=0.1.0 + +# Infos +LABEL maintainer="Swann Martinez" +LABEL version=$version +LABEL description="Blender multi-user addon \ + dedicated server image." + +# Argument +ENV password='admin' +ENV port=5555 +ENV timeout=3000 +ENV log_level=INFO +ENV log_file="multiuser_server.log" + +#Install replication +RUN pip install replication==$replication_version + +# Run the server with parameters +CMD replication.serve -pwd ${password} -p ${port} -t ${timeout} -l ${log_level} -lf ${log_file} diff --git a/scripts/get_addon_version.py b/scripts/get_addon_version.py new file mode 100644 index 0000000..7c25283 --- /dev/null +++ b/scripts/get_addon_version.py @@ -0,0 +1,6 @@ +import re + +init_py = open("multi_user/__init__.py").read() +version = re.search("\d+, \d+, \d+", init_py).group(0) +digits = version.split(',') +print('.'.join(digits).replace(" ","")) \ No newline at end of file diff --git a/scripts/get_replication_version.py b/scripts/get_replication_version.py new file mode 100644 index 0000000..eb5005d --- /dev/null +++ b/scripts/get_replication_version.py @@ -0,0 +1,4 @@ +import re + +init_py = open("multi_user/__init__.py").read() +print(re.search("\d+\.\d+\.\d+\w\d+|\d+\.\d+\.\d+", init_py).group(0))