69 lines
2.1 KiB
YAML
69 lines
2.1 KiB
YAML
variables:
|
|
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
|
|
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
|
|
|
|
stages:
|
|
- eleventy
|
|
- docker_build
|
|
- docker_deploy
|
|
|
|
eleventy:
|
|
stage: eleventy
|
|
image: node:latest
|
|
cache:
|
|
paths:
|
|
- node_modules/
|
|
script:
|
|
- npm install
|
|
- npm run build
|
|
artifacts:
|
|
paths:
|
|
- _site/
|
|
only:
|
|
- master
|
|
|
|
docker_build:
|
|
stage: docker_build
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [""]
|
|
script:
|
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $IMAGE_TAG --destination $IMAGE_TAG_LATEST
|
|
only:
|
|
- master
|
|
|
|
docker_deploy:
|
|
stage: docker_deploy
|
|
image: kroniak/ssh-client:3.6
|
|
script:
|
|
- mkdir ~/.ssh
|
|
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
|
|
- chmod 644 ~/.ssh/known_hosts
|
|
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
|
|
- eval $(ssh-agent -s)
|
|
- ssh-add <(echo "$SSH_PRIVATE_KEY")
|
|
# log into Docker registry
|
|
- ssh administrator@docker.comprofix.xyz "docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY"
|
|
# stop container, remove image.
|
|
- ssh administrator@docker.comprofix.xyz "docker stop comprofix" || true
|
|
- ssh administrator@docker.comprofix.xyz "docker rm comprofix" || true
|
|
- ssh administrator@docker.comprofix.xyz "docker rmi registry.gitlab.comprofix.com/comprofix/website:latest" || true
|
|
# start new container
|
|
- ssh administrator@docker.comprofix.xyz "docker run -d \
|
|
--name=comprofix \
|
|
--network=traefik \
|
|
--restart unless-stopped \
|
|
--label traefik.enable=true
|
|
--label traefik.http.routers.comprofix.rule=Host(`comprofix.com`) \
|
|
--label traefik.http.routers.comprofix.rule=Host(`www.comprofix.com`) \
|
|
--label traefik.http.routers.comprofix.entrypoints=https \
|
|
--label traefik.http.routers.comprofix.tls.certresolver=cloudflare \
|
|
registry.gitlab.comprofix.com/comprofix/website:latest"
|
|
only:
|
|
- master
|
|
|
|
|
|
|
|
|
|
|