-
Notifications
You must be signed in to change notification settings - Fork 7
/
docker-compose.yml
136 lines (117 loc) · 4.51 KB
/
docker-compose.yml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
version: '2'
volumes:
postgres-data:
driver: local
redis-data:
driver: local
gems:
driver: local
networks:
front-tier:
driver: bridge
back-tier:
driver: bridge
services:
db:
image: postgres:9.5.1
ports:
# We'll bind our host's port 5432 to postgres's port 5432, so we can use
# our database IDEs with it:
- 5432:5432
volumes:
# We'll store the postgres data in the 'postgres-data' volume we defined:
- postgres-data:/var/lib/postgresql/data
networks:
# Make the database service available only on the "back-tier" network:
# NOTE: Although the service is available only on the "back-tier" network,
# the host-to-container port binding we've defined for development
# purposes will allow connection from the development host.
- back-tier
environment:
POSTGRES_PASSWORD: 3x4mpl3
keyval:
image: redis:3.0.7
ports:
# We'll bind our host's port 6379 to redis's port 6379, so we can use
# Redis Desktop Manager (or other tools) with it:
- 6379:6379
volumes:
# We'll store the redis data in the 'redis-data' volume we defined:
- redis-data:/var/lib/redis
command: redis-server --appendonly yes
# Make the redis service available only on the "back-tier" network:
# NOTE: See networks comment on the postgres service above.
networks: [ "back-tier" ]
# The job processor container - we'll use this as a base for the rest of the
# containers:
jobs: &app
image: ruby:2.2.3
command: sidekiq -c 25
entrypoint: /usr/src/app/dev-entrypoint.sh
networks:
- back-tier
volumes:
# Mount our app code directory (".") into our app containers at the
# "/usr/src/app" folder:
- .:/usr/src/app
# Mount the 'gems' volume on the folder that stores bundled gems:
- gems:/usr/local/bundle
# Specify the directory from where all commands sent to the container will be
# issued to where the code is mounted:
working_dir: /usr/src/app
# Keep the stdin open, so we can attach to our app container's process
# and do things such as byebug, etc:
stdin_open: true
# Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
tty: true
# Link to our postgres and redis containers, so they can be visible from our
# app containers:
links:
# We'll include a link to the 'db' (postgres) container, making it
# visible from the container using the 'db' hostname:
- db
# We'll include a link to the 'keyval' (redis) container, making it
# visible from the container using the 'keyval' hostname:
- keyval
# Specify environment variables available for our app containers. We'll leave
# a YML anchor in case we need to override or add more variables if needed on
# each app container:
environment: &app_environment
# We'll overwrite the PATH environment variable to include the 'bin/'
# directory, for the entrypoint script to find the app's executables:
PATH: /usr/src/app/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# We'll set the DATABASE_URL environment variable for the app to connect
# to our postgres container - no need to use a 'config/database.yml' file.
DATABASE_URL: postgres://postgres:3x4mpl3@db:5432/my_app_dev?pool=25&encoding=unicode&schema_search_path=public,partitioning
# We'll set the REDIS_URL environment variable for the app to connect
# to our redis container:
REDIS_URL: redis://keyval:6379
# We'll set the RAILS_ENV and RACK_ENV environment variables to
# 'development', so our app containers will start in 'development' mode
# on this compose project:
RAILS_ENV: development
RACK_ENV: development
# We'll specify a dotenv file for docker-compose to load more environment
# variables into our app containers. This dotenv file would normally contain
# sensitive data (API keys & secrets, etc) which SHOULD NOT be committed into
# Git.
# Keep in mind that any changes in this file will require a container restart
# in order to be available on the app containers:
env_file:
- dev.env
web:
<<: *app
command: rails server -b 0.0.0.0 -p 3000 -P /tmp/rails.pid
ports:
- 3000:3000
networks:
- front-tier
- back-tier
cable:
<<: *app
command: puma --bind tcp://0.0.0.0:28080 cable/config.ru
ports:
- 28080:28080
networks:
- front-tier
- back-tier