Spaces:
Runtime error
Runtime error
Leonardo de Figueiredo commited on
Commit ·
9d68d18
1
Parent(s): 2006421
single dockerfile
Browse files- Dockerfile +37 -0
- docker-compose.yml +7 -31
- web_app/backend/Dockerfile +0 -22
- web_app/frontend/Dockerfile +0 -25
Dockerfile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------
|
| 2 |
+
# STAGE 1: Backend build
|
| 3 |
+
# ----------------------
|
| 4 |
+
|
| 5 |
+
FROM python:3.9-slim-buster as backend
|
| 6 |
+
|
| 7 |
+
WORKDIR /app/backend
|
| 8 |
+
|
| 9 |
+
COPY web_app/backend/requirements.txt .
|
| 10 |
+
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
+
|
| 13 |
+
COPY web_app/backend/ .
|
| 14 |
+
|
| 15 |
+
EXPOSE 5000
|
| 16 |
+
|
| 17 |
+
CMD ["python", "run.py"]
|
| 18 |
+
|
| 19 |
+
# -------------------------
|
| 20 |
+
# STAGE 2: Frontend build
|
| 21 |
+
# -------------------------
|
| 22 |
+
|
| 23 |
+
FROM node:14-alpine as frontend
|
| 24 |
+
|
| 25 |
+
WORKDIR /app/frontend
|
| 26 |
+
|
| 27 |
+
COPY web_app/frontend/package*.json ./
|
| 28 |
+
|
| 29 |
+
RUN npm install
|
| 30 |
+
|
| 31 |
+
COPY web_app/frontend/ .
|
| 32 |
+
|
| 33 |
+
RUN npm run build
|
| 34 |
+
|
| 35 |
+
CMD ["npx", "serve", "-s", "build", "-l", "3000"]
|
| 36 |
+
|
| 37 |
+
EXPOSE 3000
|
docker-compose.yml
CHANGED
|
@@ -1,50 +1,26 @@
|
|
| 1 |
-
# docker-compose.yml
|
| 2 |
-
|
| 3 |
-
# The version of the Docker Compose file format
|
| 4 |
version: '3'
|
| 5 |
-
|
| 6 |
-
# Define the services that make up the application
|
| 7 |
services:
|
| 8 |
-
|
| 9 |
-
# Backend service definition
|
| 10 |
backend:
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Map the port 5000 in the Docker container to port 5000 on the host machine
|
| 16 |
ports:
|
| 17 |
- 5001:5000
|
| 18 |
-
|
| 19 |
-
# Frontend service definition
|
| 20 |
frontend:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
# Map the port 3000 in the Docker container to port 3000 on the host machine
|
| 26 |
ports:
|
| 27 |
- 3000:3000
|
| 28 |
-
|
| 29 |
environment:
|
| 30 |
-
- HOST=
|
| 31 |
-
|
| 32 |
-
# Nginx service definition
|
| 33 |
nginx:
|
| 34 |
-
|
| 35 |
-
# Use the pre-built 'nginx:1.19-alpine' Docker image for this service
|
| 36 |
image: nginx:1.19-alpine
|
| 37 |
-
|
| 38 |
-
# Mount the nginx configuration file from the host machine into the Docker container
|
| 39 |
volumes:
|
| 40 |
- ./nginx.conf:/etc/nginx/nginx.conf
|
| 41 |
- ./frontend/build:/usr/share/nginx/html
|
| 42 |
-
|
| 43 |
-
# Map the port 80 in the Docker container to port 80 on the host machine
|
| 44 |
ports:
|
| 45 |
- 80:80
|
| 46 |
-
|
| 47 |
-
# Start this service only after the 'backend' and 'frontend' services have been started
|
| 48 |
depends_on:
|
| 49 |
- backend
|
| 50 |
- frontend
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
version: '3'
|
|
|
|
|
|
|
| 2 |
services:
|
|
|
|
|
|
|
| 3 |
backend:
|
| 4 |
+
build:
|
| 5 |
+
context: .
|
| 6 |
+
target: backend
|
|
|
|
|
|
|
| 7 |
ports:
|
| 8 |
- 5001:5000
|
|
|
|
|
|
|
| 9 |
frontend:
|
| 10 |
+
build:
|
| 11 |
+
context: .
|
| 12 |
+
target: frontend
|
|
|
|
|
|
|
| 13 |
ports:
|
| 14 |
- 3000:3000
|
|
|
|
| 15 |
environment:
|
| 16 |
+
- HOST=0.0.0.0
|
|
|
|
|
|
|
| 17 |
nginx:
|
|
|
|
|
|
|
| 18 |
image: nginx:1.19-alpine
|
|
|
|
|
|
|
| 19 |
volumes:
|
| 20 |
- ./nginx.conf:/etc/nginx/nginx.conf
|
| 21 |
- ./frontend/build:/usr/share/nginx/html
|
|
|
|
|
|
|
| 22 |
ports:
|
| 23 |
- 80:80
|
|
|
|
|
|
|
| 24 |
depends_on:
|
| 25 |
- backend
|
| 26 |
- frontend
|
web_app/backend/Dockerfile
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
# backend/Dockerfile
|
| 2 |
-
|
| 3 |
-
# Start from a base Python image
|
| 4 |
-
FROM python:3.9-slim-buster
|
| 5 |
-
|
| 6 |
-
# Set a working directory
|
| 7 |
-
WORKDIR /app
|
| 8 |
-
|
| 9 |
-
# Copy requirements file to the container
|
| 10 |
-
COPY requirements.txt .
|
| 11 |
-
|
| 12 |
-
# Install Python dependencies
|
| 13 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
-
|
| 15 |
-
# Copy the rest of the application files to the container
|
| 16 |
-
COPY . .
|
| 17 |
-
|
| 18 |
-
# Expose port
|
| 19 |
-
EXPOSE 5000
|
| 20 |
-
|
| 21 |
-
# Run the application
|
| 22 |
-
CMD ["python", "run.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
web_app/frontend/Dockerfile
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
# frontend/Dockerfile
|
| 2 |
-
|
| 3 |
-
# Start from a base Node image
|
| 4 |
-
FROM node:14-alpine
|
| 5 |
-
|
| 6 |
-
# Set a working directory
|
| 7 |
-
WORKDIR /app
|
| 8 |
-
|
| 9 |
-
# Copy package.json and package-lock.json files to the container
|
| 10 |
-
COPY package*.json ./
|
| 11 |
-
|
| 12 |
-
# Install Node dependencies
|
| 13 |
-
RUN npm install
|
| 14 |
-
|
| 15 |
-
# Copy the rest of the application files to the container
|
| 16 |
-
COPY . .
|
| 17 |
-
|
| 18 |
-
# Build the application
|
| 19 |
-
RUN npm run build
|
| 20 |
-
|
| 21 |
-
# Serve the application using a simple server
|
| 22 |
-
CMD ["npx", "serve", "-s", "build", "-l", "3000"]
|
| 23 |
-
|
| 24 |
-
# Expose port
|
| 25 |
-
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|