Skip to content

Commit 45fc878

Browse files
committed
Use profile in docker-compose.yml
- docker compose up will only run essential services - docker compose up run --rm <service-name> can be used to run cli helpers - docker compose --profile elasticsearch up is required to run kibana
1 parent 10282b5 commit 45fc878

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.9-bullseye
22

3-
ENV PYTHONUNBUFFERED 1
3+
ENV PYTHONUNBUFFERED=1
44
EXPOSE 80
55
EXPOSE 443
66

docker-compose.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.5'
2-
31
x-server: &base_server_setup
42
image: ifrcgo/go-api:latest
53
build: .
@@ -29,8 +27,8 @@ x-server: &base_server_setup
2927
CACHE_MIDDLEWARE_SECONDS: ${CACHE_MIDDLEWARE_SECONDS:-600}
3028
ELASTIC_SEARCH_HOST: ${ELASTIC_SEARCH_HOST:-elasticsearch://elasticsearch:9200}
3129
# Appeal API
32-
APPEALS_USER: ${APPEALS_USER}
33-
APPEALS_PASS: ${APPEALS_PASS}
30+
APPEALS_USER: ${APPEALS_USER:-}
31+
APPEALS_PASS: ${APPEALS_PASS:-}
3432
# Sentry
3533
SENTRY_DSN: ${SENTRY_DSN:-}
3634
SENTRY_SAMPLE_RATE: ${SENTRY_SAMPLE_RATE:-0.2}
@@ -56,7 +54,6 @@ x-server: &base_server_setup
5654
- db
5755
- redis
5856
- elasticsearch
59-
- kibana
6057

6158

6259
services:
@@ -107,6 +104,7 @@ services:
107104
- '5601:5601'
108105
depends_on:
109106
- elasticsearch
107+
profiles: [elasticsearch]
110108

111109
serve:
112110
<<: *base_server_setup
@@ -119,93 +117,119 @@ services:
119117
<<: *base_server_setup
120118
command: python manage.py run_celery_dev
121119

120+
# ------------------ Helper CLI Commands
121+
# Usage: `docker compose run --rm <service-name>`
122+
# Example: `docker compose run --rm bash`
122123
bash:
123124
<<: *base_server_setup
124125
entrypoint: /bin/bash
126+
profiles: [cli]
125127

126128
shell:
127129
<<: *base_server_setup
128130
command: python manage.py shell
131+
profiles: [cli]
129132

130133
loaddata:
131134
<<: *base_server_setup
132135
command: python manage.py loaddata Regions Countries Districts DisasterTypes Actions Groups
136+
profiles: [cli]
133137

134138
ingest_databank:
135139
<<: *base_server_setup
136140
command: python manage.py ingest_databank
141+
profiles: [cli]
137142

138143
collectstatic:
139144
<<: *base_server_setup
140145
command: python manage.py collectstatic --noinput -l
146+
profiles: [cli]
141147

142148
createsuperuser:
143149
<<: *base_server_setup
144150
command: python manage.py createsuperuser
151+
profiles: [cli]
145152

146153
ingest_appeals:
147154
<<: *base_server_setup
148155
command: python manage.py ingest_appeals
156+
profiles: [cli]
149157

150158
ingest_appeal_docs:
151159
<<: *base_server_setup
152160
command: python manage.py ingest_appeal_docs
161+
profiles: [cli]
153162

154163
user_registration_reminder:
155164
<<: *base_server_setup
156165
command: python manage.py user_registration_reminder
166+
profiles: [cli]
157167

158168
ingest_appeal_docs_fullscan:
159169
<<: *base_server_setup
160170
command: python manage.py ingest_appeal_docs --fullscan
171+
profiles: [cli]
161172

162173
ingest_mdb:
163174
<<: *base_server_setup
164175
command: python manage.py ingest_mdb
176+
profiles: [cli]
165177

166178
migrate:
167179
<<: *base_server_setup
168180
command: python manage.py migrate
181+
profiles: [cli]
169182

170183
makemigrations:
171184
<<: *base_server_setup
172185
command: python manage.py makemigrations
186+
profiles: [cli]
173187

174188
makemigrations_merge:
175189
<<: *base_server_setup
176190
command: python manage.py makemigrations --merge
191+
profiles: [cli]
177192

178193
make_permissions:
179194
<<: *base_server_setup
180195
command: python manage.py make_permissions
196+
profiles: [cli]
181197

182198
test:
183199
<<: *base_server_setup
184200
command: pytest --durations=10
201+
profiles: [cli]
185202

186203
test_snapshot_update:
187204
<<: *base_server_setup
188205
command: python manage.py test -k --snapshot-update
206+
profiles: [cli]
189207

190208
testr:
191209
<<: *base_server_setup
192210
command: pytest --reuse-db --durations=10 -s
211+
profiles: [cli]
193212

194213
coverage:
195214
<<: *base_server_setup
196215
command: coverage run --source='.' manage.py test -k
216+
profiles: [cli]
197217

198218
coverage_report:
199219
<<: *base_server_setup
200220
command: coverage report
221+
profiles: [cli]
201222

202223
coverage_html:
203224
<<: *base_server_setup
204225
command: coverage html
226+
profiles: [cli]
205227

206228
triggers_to_db:
207229
<<: *base_server_setup
208230
command: python manage.py triggers_to_db
231+
profiles: [cli]
232+
209233

210234
volumes:
211235
redis-data:

0 commit comments

Comments
 (0)