-
-
Save baumicon/107b2a7c99b7ba5b5e625e1cc8379756 to your computer and use it in GitHub Desktop.
Docker Compose file for ruby, postgres and redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
app: | |
build: | |
context: .. | |
dockerfile: .devcontainer/Dockerfile | |
args: | |
VARIANT: 2.6 | |
NODE_VERSION: "lts/*" | |
volumes: | |
- ..:/workspace:cached | |
command: sleep infinity | |
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. | |
network_mode: service:db | |
db: | |
image: postgres:latest | |
restart: unless-stopped | |
volumes: | |
- postgres-data:/var/lib/postgresql/data | |
- ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql | |
environment: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: postgres | |
POSTGRES_PASSWORD: postgres | |
redis: | |
image: redis:4.0.14-alpine | |
network_mode: service:db # <-- this is the line that took me an hour, so app can see redis | |
volumes: | |
postgres-data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taken from: https://twitter.com/chacon/status/1426986360703963144?lang=en
Also, the Rails/PG example has this line in the Dockerfile:
but that doesn't work in Rails 6, so you just need to add this to your development.rb file: