First CI
This commit is contained in:
parent
4ceb0e4d86
commit
386e7d1bf8
101
compose_ci.yml
Normal file
101
compose_ci.yml
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
version: '3.5'
|
||||||
|
services:
|
||||||
|
# PostgreSQL database
|
||||||
|
db:
|
||||||
|
build:
|
||||||
|
context: ./_dockerfiles/db
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
hostname: db
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
- POSTGRES_DB=postgres
|
||||||
|
ports:
|
||||||
|
- "5436:5432"
|
||||||
|
volumes:
|
||||||
|
- gm-db:/var/lib/postgresql/data/
|
||||||
|
|
||||||
|
elasticsearch:
|
||||||
|
image: elasticsearch:7.3.1
|
||||||
|
volumes:
|
||||||
|
- gm-esdata:/usr/share/elasticsearch/data
|
||||||
|
hostname: elasticsearch
|
||||||
|
ports:
|
||||||
|
- 9200:9200
|
||||||
|
- 9300:9300
|
||||||
|
environment:
|
||||||
|
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
||||||
|
- discovery.type=single-node
|
||||||
|
- xpack.security.enabled=false
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
redis:
|
||||||
|
image: redis:2.8.23
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
|
||||||
|
# Celery
|
||||||
|
worker:
|
||||||
|
build: .
|
||||||
|
command: ./run_celery.sh
|
||||||
|
environment:
|
||||||
|
- SETTINGS_CONFIGURATION=local
|
||||||
|
- DB_NAME=postgres
|
||||||
|
- DB_USERNAME=postgres
|
||||||
|
- DB_HOSTNAME=db
|
||||||
|
- DB_PORT=5432
|
||||||
|
- DB_PASSWORD=postgres
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
|
||||||
|
worker_beat:
|
||||||
|
build: .
|
||||||
|
command: ./run_celery_beat.sh
|
||||||
|
environment:
|
||||||
|
- SETTINGS_CONFIGURATION=local
|
||||||
|
- DB_NAME=postgres
|
||||||
|
- DB_USERNAME=postgres
|
||||||
|
- DB_HOSTNAME=db
|
||||||
|
- DB_PORT=5432
|
||||||
|
- DB_PASSWORD=postgres
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
|
||||||
|
|
||||||
|
# App: G&M
|
||||||
|
gm_app:
|
||||||
|
build: .
|
||||||
|
command: python manage.py runserver 0.0.0.0:8000
|
||||||
|
environment:
|
||||||
|
- SETTINGS_CONFIGURATION=local
|
||||||
|
- DB_HOSTNAME=db
|
||||||
|
- DB_PORT=5432
|
||||||
|
- DB_NAME=postgres
|
||||||
|
- DB_USERNAME=postgres
|
||||||
|
- DB_PASSWORD=postgres
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
- worker
|
||||||
|
- worker_beat
|
||||||
|
- elasticsearch
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
- gm-media:/media-data
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
gm-db:
|
||||||
|
name: gm-db
|
||||||
|
|
||||||
|
gm-media:
|
||||||
|
name: gm-media
|
||||||
|
|
||||||
|
gm-esdata:
|
||||||
75
fabfile.py
vendored
Normal file
75
fabfile.py
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
import os # NOQA
|
||||||
|
from fabric.api import * # NOQA
|
||||||
|
|
||||||
|
user = 'gm'
|
||||||
|
|
||||||
|
env.root = '~/'
|
||||||
|
env.src = '~/project'
|
||||||
|
|
||||||
|
env.default_branch = 'feature/develop_ci'
|
||||||
|
env.tmpdir = '~/tmp'
|
||||||
|
|
||||||
|
|
||||||
|
env.roledefs = {
|
||||||
|
'develop': {
|
||||||
|
'branch': env.default_branch,
|
||||||
|
'hosts': ['%s@rock.spider.ru:31' % user, ]
|
||||||
|
},
|
||||||
|
'staging': {
|
||||||
|
'hosts': ['%s@5.200.53.99' % user, ]
|
||||||
|
},
|
||||||
|
'production': {
|
||||||
|
'branch': 'master',
|
||||||
|
'hosts': ['%s@87.226.166.80' % user, ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def fetch(branch=None):
|
||||||
|
with cd(env.src):
|
||||||
|
role = env.roles[0]
|
||||||
|
run('git pull origin {}'.format(env.roledefs[role]['branch']))
|
||||||
|
run('git submodule update')
|
||||||
|
|
||||||
|
|
||||||
|
def migrate():
|
||||||
|
with cd(env.src):
|
||||||
|
run('./manage.py migrate')
|
||||||
|
|
||||||
|
|
||||||
|
def install_requirements():
|
||||||
|
with cd(env.src):
|
||||||
|
run('pip install -r requirements/base.txt')
|
||||||
|
|
||||||
|
|
||||||
|
def touch():
|
||||||
|
with cd(env.src):
|
||||||
|
run('touch ~/%s.touch' % user)
|
||||||
|
|
||||||
|
|
||||||
|
def kill_celery():
|
||||||
|
"""Kill celery workers for $user."""
|
||||||
|
with cd(env.src):
|
||||||
|
run('ps -u %s -o pid,fname | grep celery | (while read a b; do kill -9 $a; done;)' % user)
|
||||||
|
|
||||||
|
|
||||||
|
def collectstatic():
|
||||||
|
with cd(env.src):
|
||||||
|
run('./manage.py collectstatic --noinput')
|
||||||
|
|
||||||
|
|
||||||
|
def deploy(branch=None):
|
||||||
|
fetch()
|
||||||
|
install_requirements()
|
||||||
|
migrate()
|
||||||
|
collectstatic()
|
||||||
|
touch()
|
||||||
|
kill_celery()
|
||||||
|
|
||||||
|
|
||||||
|
def rev():
|
||||||
|
"""Show head commit."""
|
||||||
|
with hide('running', 'stdout'):
|
||||||
|
with cd(env.src):
|
||||||
|
commit = run('git rev-parse HEAD')
|
||||||
|
return local('git show -q %s' % commit)
|
||||||
60
gitlab-ci.yml
Normal file
60
gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
image: docker:latest
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- hello
|
||||||
|
|
||||||
|
#stages:
|
||||||
|
# - build
|
||||||
|
# - test
|
||||||
|
# - deploy
|
||||||
|
# - clean
|
||||||
|
#
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- apk add --update python python-dev py-pip gcc libc-dev libffi-dev openssl-dev make
|
||||||
|
- pip install docker-compose
|
||||||
|
|
||||||
|
|
||||||
|
hello:
|
||||||
|
- echo 'Test GitLab CI'
|
||||||
|
|
||||||
|
#clean:
|
||||||
|
# stage: clean
|
||||||
|
# script:
|
||||||
|
# - docker-compose -f compose-ci.yml stop
|
||||||
|
# - docker-compose -f compose-ci.yml rm --force gm_app
|
||||||
|
# when: always
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#buid:
|
||||||
|
# stage: build
|
||||||
|
# script:
|
||||||
|
# - docker-compose -f compose-ci.yml build gm_app
|
||||||
|
# when: always
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#test:
|
||||||
|
# stage: test
|
||||||
|
# script:
|
||||||
|
# - docker-compose -f compose-ci.yml run agro python manage.py test -v 3 --noinput
|
||||||
|
# when: always
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#deploy-develop:
|
||||||
|
# stage: deploy
|
||||||
|
# only:
|
||||||
|
# - feature/develop_ci
|
||||||
|
# script:
|
||||||
|
# - fab --roles=develop deploy
|
||||||
|
# environment:
|
||||||
|
# name: Develop
|
||||||
|
#
|
||||||
|
#
|
||||||
|
##deploy-staging:
|
||||||
|
## stage: deploy
|
||||||
|
## only:
|
||||||
|
## - master
|
||||||
|
## script:
|
||||||
|
## - fab --roles=staging deploy
|
||||||
|
## environment:
|
||||||
|
## name: Staging
|
||||||
Loading…
Reference in New Issue
Block a user