-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
59 lines (50 loc) · 1.93 KB
/
.gitlab-ci.yml
File metadata and controls
59 lines (50 loc) · 1.93 KB
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
# This file is a template, and might need editing before it works on your project.
# Official docker image.
image: docker:latest
services:
- docker:dind
variables:
STAGE_SSH_USER: sibdev
SSH_OPT: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
stages:
- test
- build
- deploy
before_script:
- apk add --update --no-cache openssh sshpass
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
test:
stage: test
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f Dockerfile .
- docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" npm run test:ci -- --coverage
only:
- merge_request
lint:
stage: test
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f Dockerfile .
- docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" npm run lint
only:
- merge_request
build:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" -f nginx/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
# deploy-stage:
# stage: deploy
# script:
# - sshpass -V
# - export SSHPASS=$STAGE_SSH_PASS
# - sshpass -e ssh $SSH_OPT root@$STAGE_SSH_HOST "docker --version"
# - sshpass -e ssh $SSH_OPT root@$STAGE_SSH_HOST "docker-compose --version"
# - sshpass -e ssh $SSH_OPT root@$STAGE_SSH_HOST "docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY"
# - sshpass -e ssh $SSH_OPT root@$STAGE_SSH_HOST "mkdir -p /data/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME"
# - sshpass -e scp $SSH_OPT ./docker-compose.prod.yml root@$STAGE_SSH_HOST:/data/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/docker-compose.yml
# - sshpass -e ssh $SSH_OPT root@$STAGE_SSH_HOST "cd /data/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/ && docker-compose pull"
# - sshpass -e ssh $SSH_OPT root@$STAGE_SSH_HOST "cd /data/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/ && docker-compose up -d"
# only:
# - master