Skip to content

Commit ae6d97c

Browse files
feat: update Docker configurations for production environment
1 parent 08b0027 commit ae6d97c

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

backend/Dockerfile

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ WORKDIR /app
44

55
COPY package*.json ./
66

7+
# Install dependencies
78
RUN npm install
89

10+
# Copy application code
911
COPY . .
1012

13+
# Build the application
14+
RUN npm run build
15+
16+
# Set production environment
17+
ENV NODE_ENV=production
18+
1119
EXPOSE 3001
1220

13-
CMD ["npm", "run", "dev"]
21+
# Run in production mode
22+
CMD ["npm", "run", "start"]

docker-compose.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,20 @@ services:
77
dockerfile: Dockerfile
88
ports:
99
- "3001:3001"
10-
volumes:
11-
- ./backend:/app
12-
- /app/node_modules
1310
environment:
1411
- PORT=3001
15-
- NODE_ENV=development
16-
command: npm run dev
12+
- NODE_ENV=production
13+
restart: unless-stopped
1714

1815
frontend:
1916
build:
2017
context: ./frontend
2118
dockerfile: Dockerfile
2219
ports:
2320
- "3000:3000"
24-
volumes:
25-
- ./frontend:/app
26-
- /app/node_modules
2721
environment:
2822
- NEXT_PUBLIC_API_URL=http://localhost:3001/api
23+
- NODE_ENV=production
2924
depends_on:
3025
- backend
31-
command: npm run dev
26+
restart: unless-stopped

frontend/Dockerfile

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ WORKDIR /app
44

55
COPY package*.json ./
66

7+
# Install dependencies
78
RUN npm install
89

10+
# Copy application code
911
COPY . .
1012

13+
# Copy environment file
1114
COPY .env-sample .env
1215

16+
# Build the application
17+
RUN npm run build
18+
19+
# Set production environment
20+
ENV NODE_ENV=production
21+
1322
EXPOSE 3000
1423

15-
CMD ["npm", "run", "dev"]
24+
# Run in production mode
25+
CMD ["npm", "run", "start"]

0 commit comments

Comments
 (0)