-
Notifications
You must be signed in to change notification settings - Fork 11
/
.gitlab-ci.yml
57 lines (53 loc) · 2.22 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
image: docker:latest
stages:
- test
- build
- deploy
test_validation:
stage: test
image: node:latest
services:
- redis:4.0.0
cache:
paths:
- node_modules/
before_script:
- npm ci
- npm ci --prefix client
script:
- npm test
- npm run lint:test
build_push:
stage: build
only:
- master
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
script:
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD}
- docker build --build-arg REACT_APP_SENTRY_DSN --build-arg REACT_APP_AUTH0_DOMAIN --build-arg REACT_APP_AUTH0_CLIENT_ID --build-arg REACT_APP_AUTH0_CALLBACK_URL --build-arg REACT_APP_AUTH0_TOKEN_ENDPOINT --build-arg REACT_APP_AUTH0_API_ENDPOINT --build-arg REACT_APP_GOOGLE_CLIENT_ID --build-arg REACT_APP_GOOGLE_FIT_SCOPES . -t aossie/carbonfootprint-api:production
- docker push aossie/carbonfootprint-api:production
deploy_application:
stage: deploy
when: manual
only:
- master
before_script:
- apk add --no-cache openssh-client
- mkdir -p ~/.ssh
- echo "$DEPLOY_SERVER_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts
script:
- printf "API_TEST_KEY=${API_TEST_KEY}\nDB_HOST=${DB_HOST}\nDB_PORT=${DB_PORT}\nDB_USER=${DB_USER}\nDB_PASS=${DB_PASS}\nDB_NAME=${DB_NAME}\nMICROSOFT_MAPS_KEY=${MICROSOFT_MAPS_KEY}\nAUTH0_JWKS_URI=${AUTH0_JWKS_URI}\nAUTH0_ISSUER=${AUTH0_ISSUER}\nREDIS_HOST=${REDIS_HOST}\nREDIS_PORT=${REDIS_PORT}\nWHITELISTED_DOMAINS=${WHITELISTED_DOMAINS}\nSENTRY_DSN=${SENTRY_DSN}\nAUTH0_CLIENT_ID=${AUTH0_CLIENT_ID}\nAUTH0_CLIENT_SECRET=${AUTH0_CLIENT_SECRET}\nGOOGLE_FIT_API_ENDPOINT=${GOOGLE_FIT_API_ENDPOINT}" > .env
- scp -r ./.env ./docker-compose.yml carbonfootprintapi_gmail_com@${DEPLOYMENT_SERVER_IP}:~/
- ssh carbonfootprintapi_gmail_com@${DEPLOYMENT_SERVER_IP} "docker-compose stop;docker-compose rm web --force;docker pull aossie/carbonfootprint-api:production;docker-compose up -d;"