From 56e9f14597e118535e7d7566904ea51ccad8b577 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me> Date: Sun, 19 Jun 2022 21:40:41 +0300 Subject: [PATCH] Added CI to deploy docker image --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9ec2f9e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +image: docker:stable + +services: + - docker:stable-dind + +variables: + REPOSITORY: "modjular/modjular-ubuntu" + BUILD_DIR: "." + +before_script: + - if [ -z "$DOCKER_TOKEN" ]; then + echo "The \$DOCKER_TOKEN variable is not set. This usually means you did not set up the needed variables in the GitLab repository settings. This can also be caused if trying to run Gitlab CI on a non protected tag or branch."; + fi + - echo "${DOCKER_TOKEN}" | docker login --username "${DOCKER_USER}" --password-stdin + +stages: + - deploy + +docker: + stage: deploy + script: + - if [ $CI_COMMIT_REF_NAME == "develop" ]; then + REV="git"; + elif [ $CI_COMMIT_REF_NAME == "master" ]; then + REV="latest"; + else + REV="$CI_COMMIT_REF_NAME"; + fi + - docker build --network=host --pull -t "${REPOSITORY}:${REV}" + --no-cache + "${BUILD_DIR}" + - docker push "${REPOSITORY}" + tags: + - gitlab-org-docker -- GitLab