Merge branch 'feature/develop_ci' into 'develop'
Feature/develop ci See merge request gm/gm-backend!70
This commit is contained in:
commit
f484219ec7
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -21,4 +21,6 @@ logs/
|
|||
/geoip_db/
|
||||
|
||||
# dev
|
||||
./docker-compose.override.yml
|
||||
./docker-compose.override.yml
|
||||
|
||||
celerybeat-schedule
|
||||
|
|
|
|||
40
.gitlab-ci.yml
Normal file
40
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
image: docker:latest
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
- clean
|
||||
|
||||
|
||||
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 gm_app python manage.py test -v 3 --noinput
|
||||
when: always
|
||||
|
||||
|
||||
|
||||
deploy-develop:
|
||||
stage: deploy
|
||||
only:
|
||||
- develop
|
||||
script:
|
||||
- fab --roles=develop deploy
|
||||
environment:
|
||||
name: Develop
|
||||
14
apps/account/migrations/0017_merge_20191024_1233.py
Normal file
14
apps/account/migrations/0017_merge_20191024_1233.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-24 12:33
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('account', '0016_auto_20191024_0830'),
|
||||
('account', '0016_auto_20191024_0833'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
20
apps/establishment/migrations/0043_establishment_currency.py
Normal file
20
apps/establishment/migrations/0043_establishment_currency.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-24 13:13
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0022_auto_20191023_1113'),
|
||||
('establishment', '0042_establishment_tz'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='establishment',
|
||||
name='currency',
|
||||
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='main.Currency', verbose_name='currency'),
|
||||
),
|
||||
]
|
||||
79
compose-ci.yml
Normal file
79
compose-ci.yml
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
version: '2'
|
||||
services:
|
||||
db:
|
||||
build:
|
||||
context: ./_dockerfiles/db
|
||||
dockerfile: Dockerfile
|
||||
hostname: db
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DB=postgres
|
||||
ports:
|
||||
- "5436:5432"
|
||||
|
||||
elasticsearch:
|
||||
image: elasticsearch:7.3.1
|
||||
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
|
||||
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
|
||||
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
|
||||
ports:
|
||||
- "8000:8000"
|
||||
69
fabfile.py
vendored
Normal file
69
fabfile.py
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import os # NOQA
|
||||
from fabric.api import * # NOQA
|
||||
|
||||
|
||||
|
||||
user = 'gm'
|
||||
|
||||
env.roledefs = {
|
||||
'develop': {
|
||||
'branch': 'develop',
|
||||
'hosts': ['%s@95.213.204.126' % user, ]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
env.root = '~/'
|
||||
env.src = '~/project'
|
||||
|
||||
env.default_branch = 'develop'
|
||||
env.tmpdir = '~/tmp'
|
||||
|
||||
|
||||
def fetch(branch=None):
|
||||
with cd(env.src):
|
||||
role = env.roles[0]
|
||||
run('git pull origin {}'.format(env.roledefs[role]['branch']))
|
||||
|
||||
|
||||
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)
|
||||
Loading…
Reference in New Issue
Block a user