/
docker-compose.yaml
57 lines (56 loc) · 2.74 KB
/
docker-compose.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
version: '3.7'
# each service runs a container needed to run ceqr-app
services:
# rails container
backend:
build: backend # build the image for the container from backend/Dockerfile
entrypoint: ./entrypoint.sh # executes backend/entrypoint.sh on container startup
volumes:
# HOST:CONTAINER file mapping
- ./backend:/app # map our rails code into the container's /app directory
ports:
# HOST:CONTAINER port mapping
- "3000:3000" # map port 3000 on our machine to the container's port 3000 so we (our our frontend container) can go to localhost:3000 to access our container's rails server
env_file:
- backend/.env # sets our container's environment to from this file. You need to make sure to configure this before docker-compose up!
healthcheck:
test: ["CMD", "curl", "http://localhost:3000"]
interval: 10s
timeout: 30s
retries: 3
stdin_open: true
# ember container
frontend:
image: danlynn/ember-cli # build the image from this image on docker hub (see here to see how this image is built and how to use it: https://github.com/danlynn/ember-cli)
entrypoint: ./entrypoint.sh # executes frontend/entrypoint.sh on container startup
volumes:
- ./frontend:/myapp # map our frontend code into the container's /myapp directory (where danlynn/ember-cli expects to find our ember app)
ports:
- "4200:4200" # map port 4200 on our machine to the container's port 4200 (image exposes 4200 for us) so we can go to localhost:4200 to access our container's ember app server
environment:
HOST: http://localhost:3000
DISABLE_MIRAGE: 'true'
healthcheck:
test: ["CMD", "curl", "http://localhost:4200"]
interval: 1m
timeout: 30s
start_period: 5m
retries: 5
# ceqr_rails db container
postgis:
image: postgis/postgis # uses the default settings from this image. Only change is that our migrate container will execute rails commands to setup ceqr_rails with our schema and migrations.
ports:
- "5432:5432"
volumes:
# configures container to initialize with database backup if present
- ./backend/db/backup:/docker-entrypoint-initdb.d
environment:
- POSTGRES_HOST_AUTH_METHOD=trust # <== not secure, only for local development
# short-lived container to create db if not already running
migrate:
build: backend
entrypoint: ./migrate.sh # see backend/migrate.sh for startup commands (checks state of our database and will run the rails commands as needed)
volumes:
- ./backend:/app # need our rails code in this container so that it has rails commands, migration & seed files
env_file:
- backend/.env # also need to make sure it has the same environment so it can access ceqr_data db