-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitlab-ci.yaml
70 lines (60 loc) · 1.8 KB
/
.gitlab-ci.yaml
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
image: docker:latest
services:
- docker:1.13-dind
stages:
- build
- test
- deploy
variables:
DOCKER_DRIVER: overlay
CI_REGISTRY: docker.yourlabs.org/oss/djnextjs
CONTAINER_TEST_IMAGE: $CI_REGISTRY:$CI_BUILD_REF_NAME
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY:latest
POSTGRES_DB: buzzdetect
POSTGRES_USER: buzzdetect
POSTGRES_PASSWORD: buzzdetect
before_script:
- which docker && docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY || true
cache:
paths: [image.tar,pipcache]
build:
stage: build
script: |
docker build --tag $CONTAINER_TEST_IMAGE .
test:
stage: test
services:
- postgres:9.5
- redis:3.0
- docker:1.13-dind
script:
- docker run $CONTAINER_TEST_IMAGE sh -c "pip install -e /code[test]; cd /code; REDIS_URL=redis://$REDIS_PORT_6379_TCP_ADDR:6379 POSTGRES_HOST=$POSTGRES_PORT_5432_TCP_ADDR POSTGRES_USER=$POSTGRES_USER py.test src"
pages:
stage: test
image: python:2
script: |
rm -rf public
mkdir -p pipcache
pip install --cache-dir pipcache -r requirements.txt -e . psycopg2 sphinx
cd docs
EVENT_DISABLED=1 DB_ENGINE=django.db.backends.sqlite3 make html
mv _build/html ../public
artifacts:
paths: [public]
deploy:
stage: deploy
image: ubuntu:xenial
script: |
apt-get update -y
apt-get install --no-install-recommends -y openssh-client
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
echo "$SSH_PUBLIC_KEY" > ~/.ssh/id_rsa.pub
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
vars="-oPort=2222 -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=false"
set -x
scp $vars deploy docker-compose.yml [email protected]:.
ssh $vars [email protected] "CI_BUILD_TOKEN=$CI_BUILD_TOKEN CONTAINER_RELEASE_IMAGE=$CONTAINER_RELEASE_IMAGE CI_REGISTRY=$CI_REGISTRY ./deploy"
only:
- master