-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
56 lines (38 loc) · 1.64 KB
/
Dockerfile
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
# Stage 1: Node.js dependencies for backend
FROM node:14 AS backend_dependencies
# Set the working directory for backend in the container
WORKDIR /usr/src/app/backend
# Copy backend package.json and package-lock.json to the working directory
COPY backend/package*.json ./
# Install Node.js dependencies for backend
RUN npm install
# Stage 2: Python dependencies
FROM python:3.9 AS python_dependencies
# Set the working directory for Python in the container
WORKDIR /usr/src/app/backend/perchance-image-generator
# Copy Python requirement.txt to the working directory
COPY backend/perchance-image-generator/requirement.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirement.txt
# Stage 3: Node.js dependencies for frontend
FROM node:14 AS frontend_dependencies
# Set the working directory for frontend in the container
WORKDIR /usr/src/app/frontend
# Copy frontend package.json and package-lock.json to the working directory
COPY frontend/package*.json ./
# Install Node.js dependencies for frontend
RUN npm install
# Stage 4: Final image
FROM node:14
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy backend Node.js dependencies from the first stage
COPY --from=backend_dependencies /usr/src/app/backend/node_modules ./backend/node_modules
# Copy frontend Node.js dependencies from the third stage
COPY --from=frontend_dependencies /usr/src/app/frontend/node_modules ./frontend/node_modules
# Copy the rest of the application code from the host to the working directory
COPY . .
# Expose ports
EXPOSE 3000 4000
# Command to run the application
CMD ["sh", "-c", "cd backend && npm start & cd frontend && npm start"]