create containerfiles
This commit is contained in:
parent
5cef29b7c0
commit
4eeeff474c
12
backend/Containerfile
Normal file
12
backend/Containerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM docker.io/library/python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY app.py ./
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
|
||||
@ -5,7 +5,7 @@ app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
|
||||
@app.get("/api/hello")
|
||||
@app.get("/hello")
|
||||
def hello():
|
||||
return jsonify(message="Hello from Flask")
|
||||
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
flask==3.0.0
|
||||
flask-cors==4.0.0
|
||||
gunicorn==21.2.0
|
||||
|
||||
21
frontend/Containerfile
Normal file
21
frontend/Containerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM docker.io/library/node:20-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
|
||||
COPY . ./
|
||||
|
||||
RUN npm run build
|
||||
|
||||
FROM docker.io/library/nginx:1.25-alpine
|
||||
|
||||
ENV BACKEND_URL=http://backend:5000/
|
||||
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
19
frontend/nginx.conf
Normal file
19
frontend/nginx.conf
Normal file
@ -0,0 +1,19 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass ${BACKEND_URL}/; # trailing slash is the key
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user