-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
95 lines (89 loc) · 2.83 KB
/
.gitlab-ci.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
stages:
- "build"
- "container-build"
- "deploy"
build-backend:
image: ${DOCKER_CACHE}/node:14-alpine
stage: "build"
artifacts:
untracked: false
paths:
- backend/bundle.js
expire_in: 1 days
script:
- cd backend/
- npm i
- npm install -g esbuild
- npm run build
- esbuild ./dist/index.js --bundle --outfile=bundle.js --platform=node
build-frontend:
image: ${DOCKER_CACHE}/node:14-alpine
stage: "build"
artifacts:
untracked: false
paths:
- frontend/build
expire_in: 1 days
script:
- cd frontend/
- npm i
- npm run build
build-backend-container:
stage: "container-build"
image:
name: 'gcr.io/kaniko-project/executor:debug'
entrypoint: [""]
needs:
- build-backend
script:
- echo "DATABASE_URL=\"${MONGO_URI}\"" > backend/.env
- echo "BASE_URL='https://eps-dev.net'" >> backend/.env
- echo "FRONTEND_URL='https://s.eps-dev.net'" >> backend/.env
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"registry.cdev.nexus\":{\"auth\":\"$(printf "%s:%s" "${PRIVATE_REG_USER}" "${PRIVATE_REG_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/backend/Dockerfile"
--destination "registry.cdev.nexus/url-shortener/backend:${CI_COMMIT_REF_SLUG}"
--destination "registry.cdev.nexus/url-shortener/backend:latest"
build-frontend-container:
stage: "container-build"
image:
name: 'gcr.io/kaniko-project/executor:debug'
entrypoint: [""]
needs:
- build-frontend
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"registry.cdev.nexus\":{\"auth\":\"$(printf "%s:%s" "${PRIVATE_REG_USER}" "${PRIVATE_REG_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/frontend/Dockerfile"
--destination "registry.cdev.nexus/url-shortener/frontend:${CI_COMMIT_REF_SLUG}"
--destination "registry.cdev.nexus/url-shortener/frontend:latest"
deploy-backend:
stage: deploy
image:
name: 'registry.cdev.nexus/devops/kubernetes:latest'
entrypoint: [""]
needs:
- build-backend-container
script:
- helm uninstall url-backend --namespace url-shortener || true
- helm install url-backend ./deployments/backend --values ./deployments/backend/values.yaml --namespace url-shortener
only:
- main
deploy-frontend:
stage: deploy
image:
name: 'registry.cdev.nexus/devops/kubernetes:latest'
entrypoint: [""]
needs:
- build-frontend-container
script:
- helm uninstall url-frontend --namespace url-shortener || true
- helm install url-frontend ./deployments/frontend --values ./deployments/frontend/values.yaml --namespace url-shortener
only:
- main