2020-12-19 22:45:02 +00:00
|
|
|
stages:
|
2021-03-26 03:42:57 +00:00
|
|
|
- application_dependencies
|
|
|
|
- asset_dependencies
|
2020-12-19 22:45:02 +00:00
|
|
|
- test
|
2021-01-13 21:47:21 +00:00
|
|
|
- deploy_tags
|
2020-12-19 22:45:02 +00:00
|
|
|
- deploy
|
|
|
|
|
2020-07-03 15:34:19 +00:00
|
|
|
variables:
|
2020-07-03 15:39:15 +00:00
|
|
|
POSTGRES_PASSWORD: "postgres"
|
|
|
|
POSTGRES_USER: "postgres"
|
2020-07-03 15:34:19 +00:00
|
|
|
DATABASE_URL: "postgres"
|
2020-07-22 19:22:44 +00:00
|
|
|
MIX_ENV: "test"
|
2020-12-19 17:43:27 +00:00
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
2020-12-19 18:51:02 +00:00
|
|
|
DOCKER_HOST: tcp://docker:2376
|
2021-03-25 23:17:14 +00:00
|
|
|
GIT_STRATEGY: fetch
|
2020-07-03 15:34:19 +00:00
|
|
|
|
2021-03-26 03:27:42 +00:00
|
|
|
fetch_application_dependencies:
|
2021-03-26 03:42:57 +00:00
|
|
|
stage: application_dependencies
|
2021-03-26 03:27:42 +00:00
|
|
|
image: "elixir:1.10"
|
|
|
|
cache:
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- mix.lock
|
|
|
|
paths:
|
|
|
|
- _build/
|
|
|
|
- deps/
|
|
|
|
script:
|
2021-03-26 03:38:17 +00:00
|
|
|
- mix local.hex --force
|
|
|
|
- mix local.rebar --force
|
2021-03-26 03:27:42 +00:00
|
|
|
- mix deps.get
|
2021-03-26 04:02:05 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- deps/phoenix
|
|
|
|
- deps/phoenix_html
|
|
|
|
exclude:
|
|
|
|
- deps/
|
2021-03-26 03:27:42 +00:00
|
|
|
|
|
|
|
fetch_asset_dependencies:
|
2021-03-26 03:42:57 +00:00
|
|
|
stage: asset_dependencies
|
2021-03-26 03:27:42 +00:00
|
|
|
image: "node:15.0"
|
2021-03-26 03:38:17 +00:00
|
|
|
needs:
|
|
|
|
- fetch_application_dependencies
|
2021-03-26 03:27:42 +00:00
|
|
|
only:
|
|
|
|
- master
|
|
|
|
cache:
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- apps/app/assets/package-lock.json
|
|
|
|
paths:
|
|
|
|
- apps/app/assets/node_modules/
|
|
|
|
script:
|
|
|
|
- cd apps/app/assets/ && npm install
|
|
|
|
|
2020-12-18 20:21:07 +00:00
|
|
|
test:
|
2020-12-19 22:45:02 +00:00
|
|
|
stage: test
|
2021-03-26 03:27:42 +00:00
|
|
|
needs:
|
|
|
|
- fetch_application_dependencies
|
2021-02-27 01:11:22 +00:00
|
|
|
image: "elixir:1.10"
|
2020-12-19 22:28:35 +00:00
|
|
|
services:
|
|
|
|
- name: postgres:12
|
2021-03-26 02:32:26 +00:00
|
|
|
cache:
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- mix.lock
|
|
|
|
paths:
|
|
|
|
- _build/
|
|
|
|
- deps/
|
2020-07-17 23:30:31 +00:00
|
|
|
script: script/cibuild
|
2020-12-18 20:10:25 +00:00
|
|
|
|
2020-12-22 17:47:16 +00:00
|
|
|
build_image_for_commit:
|
|
|
|
stage: test
|
2021-03-26 03:27:42 +00:00
|
|
|
needs:
|
|
|
|
- fetch_asset_dependencies
|
|
|
|
- fetch_application_dependencies
|
2021-03-26 04:49:16 +00:00
|
|
|
image: "docker:20.10"
|
2021-01-16 19:20:27 +00:00
|
|
|
only:
|
|
|
|
- master
|
2020-12-19 22:28:35 +00:00
|
|
|
services:
|
2021-03-26 04:49:16 +00:00
|
|
|
- name: docker:20.10-dind
|
2020-12-19 22:28:35 +00:00
|
|
|
script:
|
2020-12-19 22:39:31 +00:00
|
|
|
- docker login "https://${CI_REGISTRY}" -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
|
|
|
|
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
2021-03-26 04:49:16 +00:00
|
|
|
- export DOCKER_BUILDKIT=1
|
|
|
|
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --build-arg BUILDKIT_INLINE_CACHE=1 .
|
2020-12-22 17:47:16 +00:00
|
|
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
|
|
|
2021-01-13 21:43:04 +00:00
|
|
|
deploy_to_tags:
|
2021-01-13 21:47:21 +00:00
|
|
|
stage: deploy_tags
|
2021-01-13 21:43:04 +00:00
|
|
|
needs: ['test']
|
|
|
|
image: "node:15.0"
|
|
|
|
only:
|
|
|
|
- master
|
2021-03-26 02:32:26 +00:00
|
|
|
cache:
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- package-lock.json
|
|
|
|
paths:
|
|
|
|
- node_modules/
|
2021-01-13 21:43:04 +00:00
|
|
|
script:
|
|
|
|
- npm install
|
2021-02-20 17:42:01 +00:00
|
|
|
- npx semantic-release --repository-url=$CI_REPOSITORY_URL
|
2021-01-13 21:43:04 +00:00
|
|
|
- script/generate-build-version
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
dotenv: build.env
|
|
|
|
|
2020-12-22 17:47:16 +00:00
|
|
|
deploy_commit_image_to_tag:
|
|
|
|
stage: deploy
|
2021-01-13 21:43:04 +00:00
|
|
|
needs:
|
|
|
|
- build_image_for_commit
|
|
|
|
- job: deploy_to_tags
|
|
|
|
artifacts: true
|
|
|
|
only:
|
|
|
|
- master
|
2020-12-22 17:47:16 +00:00
|
|
|
image: "docker:19.03.12"
|
|
|
|
services:
|
|
|
|
- name: docker:19.03.12-dind
|
2021-03-26 02:32:26 +00:00
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none # this job does not need the project files, only docker
|
2020-12-22 17:47:16 +00:00
|
|
|
script:
|
2021-01-13 21:43:04 +00:00
|
|
|
- echo "BUILD_VERSION is ${BUILD_VERSION}"
|
2020-12-22 17:47:16 +00:00
|
|
|
- docker login "https://${CI_REGISTRY}" -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
|
2020-12-22 20:36:13 +00:00
|
|
|
# Run the docker pull, but retry if it doesn't work at first because layers may be
|
|
|
|
# still be loading to storage
|
|
|
|
- for i in 1 2 3 4 5; do docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA && break || sleep 15; done
|
2021-01-13 21:43:04 +00:00
|
|
|
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$BUILD_VERSION
|
2020-12-19 22:28:35 +00:00
|
|
|
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
|
2021-01-13 21:43:04 +00:00
|
|
|
- docker push $CI_REGISTRY_IMAGE:$BUILD_VERSION
|
2020-12-19 22:28:35 +00:00
|
|
|
- docker push $CI_REGISTRY_IMAGE:latest
|