docker-compose.yml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. version: '3.8'
  2. volumes:
  3. postgres-data:
  4. services:
  5. app:
  6. container_name: javadev
  7. build:
  8. context: .
  9. dockerfile: Dockerfile
  10. environment:
  11. # NOTE: POSTGRES_DB/USER/PASSWORD should match values in db container
  12. POSTGRES_PASSWORD: postgres
  13. POSTGRES_USER: postgres
  14. POSTGRES_DB: postgres
  15. POSTGRES_HOSTNAME: postgresdb
  16. volumes:
  17. - ../..:/workspaces:cached
  18. # Overrides default command so things don't shut down after the process ends.
  19. command: sleep infinity
  20. # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
  21. network_mode: service:db
  22. # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
  23. # (Adding the "ports" property to this file will not forward from a Codespace.)
  24. db:
  25. container_name: postgresdb
  26. image: postgres:latest
  27. restart: unless-stopped
  28. volumes:
  29. - postgres-data:/var/lib/postgresql/data
  30. environment:
  31. # NOTE: POSTGRES_DB/USER/PASSWORD should match values in app container
  32. POSTGRES_PASSWORD: postgres
  33. POSTGRES_USER: postgres
  34. POSTGRES_DB: postgres
  35. # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
  36. # (Adding the "ports" property to this file will not forward from a Codespace.)