Created
August 15, 2021 19:15
-
-
Save schacon/67a278cfa7853d5d47b46785190820d0 to your computer and use it in GitHub Desktop.
Docker Compose file for ruby, postgres and redis
This file contains 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