This repository has been archived by the owner on Oct 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.yml
74 lines (70 loc) · 2.01 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
stages:
- build
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
build:review:
stage: build
tags:
- docker
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build --pull -f ./Dockerfile -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- echo "echo \"docker exec -it $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME sh\"; docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME && docker run -it --rm --name $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" >> run-$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME.sh
artifacts:
paths:
- run-$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME.sh
expire_in: 1 week
environment:
name: review/$CI_COMMIT_REF_NAME
on_stop: stop:build:review
auto_stop_in: 1 week
only:
- branches
except:
- master
- main
stop:build:review:
stage: build
tags:
- docker
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/paulgoio/toolkit:production
variables:
GIT_STRATEGY: none
script:
- echo "Stopping review/$CI_COMMIT_REF_NAME environment."
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
when: manual
only:
- branches
except:
- master
- main
build:production:
stage: build
tags:
- docker
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- docker login -u $DOCKER_USER -p $DOCKER_PASSWD
script:
- docker build --pull -f ./Dockerfile -t $DOCKER_REPO/$CI_PROJECT_NAME:$CI_ENVIRONMENT_SLUG .
- docker push $DOCKER_REPO/$CI_PROJECT_NAME:$CI_ENVIRONMENT_SLUG
environment:
name: production
url: https://$DOMAIN
only:
- master
- main