Skip to content

Commit 3a3644f

Browse files
Provided docker to frontend and backend.
1 parent a4b036f commit 3a3644f

File tree

6 files changed

+102
-42
lines changed

6 files changed

+102
-42
lines changed

backend/app/app/settings.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@
8484
DATABASES = {
8585
"default": {
8686
"ENGINE": "django.db.backends.postgresql",
87-
"HOST": os.environ.get("DB_HOST"),
88-
"NAME": os.environ.get("DB_NAME"),
89-
"USER": os.environ.get("DB_USER"),
90-
"PASSWORD": os.environ.get("DB_PASS"),
87+
"HOST": os.environ.get("DB_HOST", "db"),
88+
"PORT": int(os.environ.get("DB_PORT", "5432")),
89+
"NAME": os.environ.get("DB_NAME", "dev_db"),
90+
"USER": os.environ.get("DB_USER", "devuser"),
91+
"PASSWORD": os.environ.get("DB_PASS", "changeme"),
92+
"OPTIONS": {"connect_timeout": 5},
9193
}
9294
}
9395

backend/docker-compose.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

docker-compose.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
services:
2+
backend:
3+
build: { context: ./backend, args: [DEV=true] }
4+
working_dir: /app
5+
command: >
6+
sh -c "python app/manage.py wait_for_db &&
7+
python app/manage.py migrate &&
8+
python app/manage.py runserver 0.0.0.0:8000"
9+
ports: ["8000:8000"]
10+
volumes: ["./backend:/app"]
11+
env_file: ["./backend/.env"]
12+
depends_on:
13+
db: { condition: service_healthy }
14+
redis: { condition: service_healthy }
15+
16+
frontend:
17+
build:
18+
context: ./frontend
19+
target: dev
20+
ports: ["3000:3000"]
21+
environment:
22+
- NUXT_PUBLIC_API_BASE=http://localhost:8000
23+
volumes:
24+
- ./frontend:/app
25+
- /app/node_modules
26+
depends_on:
27+
backend:
28+
condition: service_started
29+
30+
31+
db:
32+
image: postgres:15-alpine
33+
environment:
34+
- POSTGRES_DB=dev_db
35+
- POSTGRES_USER=devuser
36+
- POSTGRES_PASSWORD=changeme
37+
volumes: ["dev-db-data:/var/lib/postgresql/data"]
38+
healthcheck:
39+
test: ["CMD-SHELL","pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB} -h 127.0.0.1"]
40+
interval: 5s
41+
timeout: 3s
42+
retries: 10
43+
44+
redis:
45+
image: redis:7-alpine
46+
healthcheck:
47+
test: ["CMD","redis-cli","ping"]
48+
interval: 3s
49+
timeout: 2s
50+
retries: 20
51+
52+
volumes:
53+
dev-db-data:

frontend/.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.git
3+
.env
4+
.nuxt
5+
.output
6+
dist
7+
coverage

frontend/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# --- Base ---
2+
FROM node:22-alpine AS base
3+
4+
WORKDIR /app
5+
RUN apk add --no-cache libc6-compat
6+
7+
# --- Deps (cache) ---
8+
FROM base AS deps
9+
COPY package.json package-lock.json* ./
10+
RUN --mount=type=cache,target=/root/.npm npm ci
11+
12+
# --- Dev target ---
13+
FROM base AS dev
14+
ENV NUXT_HOST=0.0.0.0 NUXT_PORT=3000
15+
COPY --from=deps /app/node_modules ./node_modules
16+
COPY . .
17+
EXPOSE 3000
18+
CMD ["npm","run","dev"]
19+
20+
# --- Build (prod) ---
21+
FROM base AS build
22+
ENV NODE_ENV=production
23+
COPY --from=deps /app/node_modules ./node_modules
24+
COPY . .
25+
RUN npm run build
26+
27+
# --- Runtime (prod) ---
28+
FROM node:22-alpine AS prod
29+
WORKDIR /app
30+
ENV NODE_ENV=production
31+
# Nuxt Nitro node-server output
32+
ENV PORT=3000 NITRO_PORT=3000 NUXT_HOST=0.0.0.0
33+
COPY --from=build /app/.output ./.output
34+
EXPOSE 3000
35+
CMD ["node",".output/server/index.mjs"]

frontend/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default defineNuxtConfig({
2222
"/ws/**": { proxy: "http://127.0.0.1:8000/ws/**" },
2323
},
2424
},
25+
2526
modules: [
2627
"@nuxt/content",
2728
"@nuxt/eslint",

0 commit comments

Comments
 (0)