Leonardo de Figueiredo commited on
Commit
a257faf
·
1 Parent(s): 7784b48

add front/backend dockerfiles

Browse files
docker-compose.yml CHANGED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Build the Docker image for this service using the Dockerfile in the ./backend directory
13
+ build: ./web_app/backend
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
+ # Build the Docker image for this service using the Dockerfile in the ./frontend directory
23
+ build: ./web_app/frontend
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= 0.0.0.0
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
nginx.conf ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The events block configures the connection handling capabilities of Nginx.
2
+ events {
3
+ # The worker_connections directive specifies the maximum number of simultaneous connections
4
+ # that a single worker process can handle.
5
+ worker_connections 1024;
6
+ }
7
+
8
+ # The http block is where you define directives for handling HTTP requests.
9
+ http {
10
+ upstream frontend {
11
+ server frontend:3000;
12
+ }
13
+
14
+ upstream backend {
15
+ server backend:5000;
16
+ }
17
+
18
+ server {
19
+ listen 80;
20
+
21
+ location / {
22
+ proxy_pass http://frontend;
23
+ }
24
+
25
+ location /api/ {
26
+ proxy_pass http://backend;
27
+ }
28
+ }
29
+ }
30
+
web_app/backend/Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/backend/app/__init__.py CHANGED
@@ -3,3 +3,4 @@ from flask import Flask, request
3
  app = Flask(__name__)
4
 
5
  from app import home
 
 
3
  app = Flask(__name__)
4
 
5
  from app import home
6
+
web_app/backend/app/home.py CHANGED
@@ -3,4 +3,6 @@ from app import app
3
 
4
  @app.route('/')
5
  def index():
6
- return "Hello, World!"
 
 
 
3
 
4
  @app.route('/')
5
  def index():
6
+ return "Hello, World!"
7
+
8
+
web_app/backend/requirements.txt CHANGED
@@ -10,4 +10,4 @@ psycopg2-binary==2.9.6
10
  python-dotenv==1.0.0
11
  SQLAlchemy==2.0.18
12
  typing_extensions==4.7.1
13
- Werkzeug==2.3.6
 
10
  python-dotenv==1.0.0
11
  SQLAlchemy==2.0.18
12
  typing_extensions==4.7.1
13
+ Werkzeug==2.3.6
web_app/frontend/Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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