SANDRAMSC commited on
Commit
eadb9a4
1 Parent(s): 4c946ce

Changed path of dist folder file

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -33
Dockerfile CHANGED
@@ -1,47 +1,44 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim AS backend
3
 
4
- # Set the working directory for the backend in the container
5
- WORKDIR /app
6
 
7
- # Install system dependencies
8
- RUN apt-get update \
9
- && apt-get install -y --no-install-recommends gcc \
10
- && rm -rf /var/lib/apt/lists/*
11
 
12
- # Copy backend application dependencies
13
- COPY requirements.txt /app/
14
- RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Copy all backend source code from the root directory
17
- COPY . /app/
18
 
19
- # Expose the port the backend app runs on
20
- EXPOSE 5000
21
 
22
- # Build frontend
23
- FROM node:14 AS frontend
24
 
25
- # Set the working directory for the frontend in the container
26
- WORKDIR /app/frontend
27
 
28
- # Copy frontend source code
29
- COPY frontend /app/frontend
 
30
 
31
- # Install frontend dependencies and build
32
- RUN npm install
33
- RUN npm run build
34
 
35
- # Merge frontend build with backend
36
- FROM backend AS final
37
 
38
- # Copy built frontend files to appropriate location for serving
39
- COPY --from=frontend /app/frontend/dist /app/frontend/dist
40
 
41
- # Add configuration to serve frontend files using Nginx
42
- # Example:
43
- # COPY nginx.conf /etc/nginx/nginx.conf
44
 
45
- # Start the backend server
46
- CMD ["python", "together_call.py"]
47
 
 
1
+ # Stage 1: Build frontend
2
+ FROM node:latest AS frontend
3
 
4
+ # Set working directory for frontend
5
+ WORKDIR /app/frontend
6
 
7
+ # Copy frontend source code
8
+ COPY frontend/package.json frontend/package-lock.json ./
9
+ COPY frontend .
 
10
 
11
+ # Install dependencies
12
+ RUN npm install
 
13
 
14
+ # Build frontend
15
+ RUN npm run build
16
 
17
+ # Stage 2: Build backend
18
+ FROM python:3.9-slim AS backend
19
 
20
+ # Set working directory for backend
21
+ WORKDIR /app/backend
22
 
23
+ # Copy backend source code
24
+ COPY backend .
25
 
26
+ # Install backend dependencies
27
+ COPY requirements.txt .
28
+ RUN pip install --no-cache-dir -r requirements.txt
29
 
30
+ # Stage 3: Serve frontend and backend using nginx and gunicorn
31
+ FROM nginx:latest AS production
 
32
 
33
+ # Copy built frontend files from the frontend stage to nginx
34
+ COPY --from=frontend /app/frontend/dist /usr/share/nginx/html
35
 
36
+ # Copy built backend code from the backend stage
37
+ COPY --from=backend /app/backend /app/backend
38
 
39
+ # Expose port 80 for nginx
40
+ EXPOSE 80
 
41
 
42
+ # Start gunicorn server for backend
43
+ CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]
44