-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagga.yaml
118 lines (111 loc) · 2.97 KB
/
vagga.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
minimum-vagga: v0.7.0
containers:
pip-freeze:
setup:
- !Alpine v3.4
- !BuildDeps [postgresql-dev]
- !Py3Install
- pip
- 'Django >=1.8, <2.0'
- 'gunicorn >=19.6, <20.0'
- 'whitenoise >=3.2, <4.0'
- 'psycopg2 >=2.6, <3.0'
- 'django-environ >=0.4, <1.0'
- !Sh |
echo "-r base-requirements.txt" > requirements.txt
pip freeze >> requirements.txt
django:
setup:
- !Alpine v3.4
- !PipConfig
dependencies: true
- !BuildDeps [postgresql-dev]
- !Install
- libpq
- !Py3Requirements requirements.txt
environ:
DATABASE_URL: postgresql://vagga:[email protected]:5433/mainDB
environ-file: /work/mysite/.env
postgres:
setup:
- !Ubuntu xenial
- !EnsureDir /data
- !Sh |
addgroup --system --gid 200 postgres
adduser --uid 200 --system --home /data --no-create-home \
--shell /bin/bash --group --gecos "PostgreSQL administrator" \
postgres
- !Install [postgresql-9.5]
environ:
PGDATA: /data
PG_PORT: 5433
PG_DB: mainDB
PG_USER: vagga
PG_PASSWORD: vagga
PG_BIN: /usr/lib/postgresql/9.5/bin
volumes:
/data: !Persistent
name: postgres
owner-uid: 200
owner-gid: 200
init-command: _pg-init
/run: !Tmpfs
test:
setup:
- !Ubuntu trusty
- !PipConfig
dependencies: true
- !Depends .pre-commit-config.yaml
- !Py3Requirements test-requirements.txt
lint:
setup:
- !Ubuntu trusty
- !PipConfig
dependencies: true
- !Install [git]
- !Depends .pre-commit-config.yaml
- !Py3Requirements test-requirements.txt
- !Py3Install [setuptools]
- !Sh HOME=/root pre-commit install-hooks
commands:
_pg-init: !Command
description: Init postgres database
container: postgres
user-id: 200
group-id: 200
run: |
set -ex
ls -la /data
$PG_BIN/pg_ctl initdb
$PG_BIN/pg_ctl -w -o '-F --port=$PG_PORT -k /run' start
$PG_BIN/createuser -h 127.0.0.1 -p $PG_PORT $PG_USER
$PG_BIN/createdb -h 127.0.0.1 -p $PG_PORT $PG_DB -O $PG_USER
$PG_BIN/psql -h 127.0.0.1 -p $PG_PORT -c "ALTER ROLE $PG_USER WITH ENCRYPTED PASSWORD '$PG_PASSWORD';"
$PG_BIN/pg_ctl stop
app: &run-app !Command
container: django
run: |
python3 manage.py migrate
python3 manage.py runserver
db: &run-db !Command
container: postgres
user-id: 200
group-id: 200
run: exec $PG_BIN/postgres -F --port=$PG_PORT -k /run
manage.py: !Command
description: Shortcut to manage.py
container: django
run: [python3, manage.py]
run: !Supervise
description: Start the django development server using Postgres database
children:
app: *run-app
db: *run-db
lint: !Command
description: Run linters
container: lint
run: pre-commit run --all-files
test: !Command
description: Run tests
container: test
run: python3 manage.py test