-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
215 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
project/{{ cookiecutter.__folder_name }}/.gitlab-ci.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
default: | ||
image: docker:24.0.5 | ||
services: | ||
- docker:24.0.5-dind | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common | ||
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin | ||
|
||
stages: | ||
- test | ||
- build | ||
- release | ||
- deploy | ||
|
||
variables: | ||
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled | ||
# DOCKER_HOST: tcp://docker:2376 | ||
DOCKER_TLS_CERTDIR: "/certs" | ||
CONTAINER_BACKEND_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/backend | ||
CONTAINER_FRONTEND_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/frontend | ||
CONTAINER_VARNISH_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/varnish | ||
|
||
check-backend: | ||
stage: test | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common git | ||
script: | ||
- cd backend | ||
- make check | ||
|
||
check-frontend: | ||
image: 22-alpine | ||
stage: test | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common git | ||
script: | ||
- cd frontend | ||
- make lint | ||
- make ci-i18n | ||
|
||
test-backend: | ||
stage: test | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common git | ||
script: | ||
- cd backend | ||
- make install | ||
- make test | ||
rules: | ||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' | ||
|
||
test-frontend: | ||
image: 22-alpine | ||
stage: test | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common git | ||
script: | ||
- cd frontend | ||
- make install | ||
- make test | ||
rules: | ||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' | ||
|
||
build-and-release-backend: | ||
stage: build | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common | ||
script: | ||
- cd backend | ||
- make build-image | ||
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin | ||
- docker tag $CONTAINER_BACKEND_RELEASE_IMAGE:latest $CONTAINER_BACKEND_RELEASE_IMAGE:$CI_COMMIT_TAG | ||
- docker push $CONTAINER_BACKEND_RELEASE_IMAGE:latest | ||
- docker push $CONTAINER_BACKEND_RELEASE_IMAGE:$CI_COMMIT_TAG | ||
|
||
only: | ||
- main | ||
- tags | ||
|
||
build-and-release-frontend: | ||
stage: build | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common | ||
|
||
script: | ||
- cd frontend | ||
- make build-image | ||
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin | ||
- docker tag $CONTAINER_FRONTEND_RELEASE_IMAGE:latest $CONTAINER_FRONTEND_RELEASE_IMAGE:$CI_COMMIT_TAG | ||
- docker push $CONTAINER_FRONTEND_RELEASE_IMAGE:latest | ||
- docker push $CONTAINER_FRONTEND_RELEASE_IMAGE:$CI_COMMIT_TAG | ||
only: | ||
- main | ||
- tags | ||
|
||
build-and-release-varnish: | ||
stage: build | ||
before_script: | ||
- apk add --no-cache make bash python3 ncurses openssh-client-common | ||
script: | ||
- cd devops/varnish | ||
- docker build . -t $CONTAINER_VARNISH_RELEASE_IMAGE:latest -t $CONTAINER_VARNISH_RELEASE_IMAGE:$CI_COMMIT_TAG | ||
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin | ||
- docker push $CONTAINER_VARNISH_RELEASE_IMAGE:latest | ||
- docker push $CONTAINER_VARNISH_RELEASE_IMAGE:$CI_COMMIT_TAG | ||
only: | ||
- main | ||
- tags | ||
|
||
deploy: | ||
stage: deploy | ||
rules: | ||
- if: $CI_COMMIT_TAG | ||
script: | ||
- mkdir -p ~/.ssh/ | ||
- touch ~/.ssh/known_hosts | ||
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts | ||
- chmod 644 ~/.ssh/known_hosts | ||
- cd devops | ||
- eval `ssh-agent -s` | ||
- echo "${DEPLOY_SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null # add ssh key | ||
- export TERM=dumb | ||
- touch .env | ||
- 'echo "DEPLOY_ENV: ${DEPLOY_ENV}" >> .env' | ||
- 'echo "DEPLOY_HOST: ${DEPLOY_HOST}" >> .env' | ||
- 'echo "DEPLOY_PORT: ${DEPLOY_PORT}" >> .env' | ||
- 'echo "DEPLOY_USER: ${DEPLOY_USER}" >> .env' | ||
- 'echo "DOCKER_CONFIG: ${DOCKER_CONFIG}" >> .env' | ||
- 'echo "STACK_NAME: ${STACK_NAME}" >> .env' | ||
- 'echo "STACK_PARAM: ${CI_COMMIT_TAG}" >> .env' | ||
- make docker-setup | ||
- make stack-deploy | ||
environment: production | ||
# deploy-with-auxiliary-docker-image: | ||
# stage: deploy | ||
# variables: | ||
# REGISTRY: ${CI_REGISTRY} | ||
# USERNAME: ${CI_REGISTRY_USER} | ||
# PASSWORD: ${CI_REGISTRY_PASSWORD} | ||
# REMOTE_HOST: ${DEPLOY_HOST} | ||
# REMOTE_PORT: ${DEPLOY_PORT} | ||
# REMOTE_USER: ${DEPLOY_USER} | ||
# REMOTE_PRIVATE_KEY: "${DEPLOY_SSH_PRIVATE_KEY}" | ||
# STACK_FILE: devops/stacks/${DEPLOY_HOST}.yml | ||
# STACK_NAME: ${STACK_NAME} | ||
# DEPLOY_IMAGE: ghcr.io/kitconcept/docker-stack-deploy:latest | ||
# script: | ||
# - docker pull ${DEPLOY_IMAGE} | ||
# - docker run --rm | ||
# -v "$(pwd)":/github/workspace | ||
# -v /var/run/docker.sock:/var/run/docker.sock | ||
# -e REGISTRY=${REGISTRY} | ||
# -e USERNAME=${USERNAME} | ||
# -e PASSWORD=${PASSWORD} | ||
# -e REMOTE_HOST=${REMOTE_HOST} | ||
# -e REMOTE_PORT=${REMOTE_PORT} | ||
# -e REMOTE_USER=${REMOTE_USER} | ||
# -e REMOTE_PRIVATE_KEY="${REMOTE_PRIVATE_KEY}" | ||
# -e STACK_FILE=${STACK_FILE} | ||
# -e STACK_NAME=${STACK_NAME} | ||
# ${DEPLOY_IMAGE} | ||
# only: | ||
# - main | ||
# environment: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters