-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (43 loc) · 1.51 KB
/
Dockerfile
File metadata and controls
59 lines (43 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# ---------- Backend Build Stage ----------
FROM node:16 AS backend
WORKDIR /app/backend
# Copy backend dependencies and source files
COPY backend/package*.json ./
COPY backend/ ./
# Install dependencies without building native modules
RUN npm install --ignore-scripts
RUN npm install -g concurrently@7.6.0
# ---------- Frontend Build Stage ----------
FROM node:16 AS frontend
WORKDIR /app/recipe-app
COPY recipe-app/package*.json ./
COPY recipe-app/ ./
RUN npm install && npx update-browserslist-db@latest
# ---------- Middleware Build Stage ----------
FROM node:16 AS middleware
WORKDIR /app/middleware
COPY middleware/package*.json ./
COPY middleware/ ./
RUN npm install
# ---------- Final Image ----------
FROM node:16
WORKDIR /app
# Set environment variables
ENV PORT=4000
ENV BROWSER=none
# Copy built application files from all stages
COPY --from=backend /app/backend ./backend
COPY --from=frontend /app/recipe-app ./recipe-app
COPY --from=middleware /app/middleware ./middleware
COPY recipeApp.db recipeApp.db
# Reinstall backend dependencies in correct environment to fix native module issues
WORKDIR /app/backend
RUN npm install && npm rebuild sqlite3 bcrypt --build-from-source
# Reinstall middleware dependencies (if needed at runtime)
WORKDIR /app/middleware
RUN npm install
# Expose backend and frontend ports
EXPOSE 4000 3000
# Start backend and frontend using concurrently
WORKDIR /app
CMD ["sh", "-c", "export PORT=3000 && npx concurrently \"cd /app/backend && node server.js\" \"cd /app/recipe-app && npm start\""]