Skip to content

Instantly share code, notes, and snippets.

@j-bullard
Created July 24, 2024 21:18
Show Gist options
  • Save j-bullard/68cdd168a45ceaefaf00acb533efa424 to your computer and use it in GitHub Desktop.
Save j-bullard/68cdd168a45ceaefaf00acb533efa424 to your computer and use it in GitHub Desktop.
Docker compose using vite with HMR through nginx
version: "3.9"
services:
db:
image: postgres:latest
container_name: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: task_app_db
expose:
- "5432"
volumes:
- pgdata:/var/lib/postgresql/data
backend:
image: node:latest
container_name: backend
working_dir: /app
volumes:
- ./backend:/app
- /backend/node_modules
expose:
- "5174"
depends_on:
- db
command: sh -c "npm install && npm run dev"
frontend:
image: node:latest
container_name: frontend
working_dir: /app
volumes:
- ./frontend:/app
- /app/node_modules
expose:
- "5173"
depends_on:
- backend
command: sh -c "npm install && npm run dev"
nginx:
image: nginx:latest
container_name: nginx
ports:
- "80:80"
- "81:81"
volumes:
- ./nginx:/etc/nginx/conf.d
depends_on:
- frontend
- backend
volumes:
pgdata:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment