nginx research results, no way this works

This commit is contained in:
2023-01-28 21:49:59 -06:00
parent 87833551a6
commit 4afbbb2887
5 changed files with 59 additions and 8 deletions

View File

@@ -1,13 +1,29 @@
FROM docker.io/python:3.8-buster # nginx-gunicorn-flask
FROM ubuntu:12.04
LABEL maintainer="Andrew Simonson <asimonson1125@gmail.com>" LABEL maintainer="Andrew Simonson <asimonson1125@gmail.com>"
WORKDIR /app ENV DEBIAN_FRONTEND noninteractive
ADD ./src /app
COPY . . RUN apt-get update
RUN apt-get install -y python python-pip python-virtualenv nginx gunicorn supervisor
# do we really need venv?
RUN apt-get -yq update && \ # Setup flask application
pip install --no-cache-dir -r ./src/requirements.txt RUN mkdir /deploy/app
WORKDIR /app/src COPY src /deploy/app
RUN pip install -r /deploy/app/requirements.txt
CMD [ "gunicorn", "--bind", "0.0.0.0:8080", "app:app"] # Setup nginx
RUN rm /etc/nginx/sites-enabled/default
COPY flask.conf /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/flask.conf /etc/nginx/sites-enabled/flask.conf
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Setup supervisord
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY gunicorn.conf /etc/supervisor/conf.d/gunicorn.conf
# Start processes (Lol idk how this works)
CMD ["/usr/bin/supervisord"]

18
ecs-task.json Normal file
View File

@@ -0,0 +1,18 @@
{
"containerDefinitions": [
{
"name": "app",
"image": "asimonson1125/asimonson1125.github.io",
"essential": true,
"memory": 500,
"cpu": 10,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
]
}
],
"family": "Portfolio"
}

9
flask.conf Normal file
View File

@@ -0,0 +1,9 @@
server {
listen 80;
location / {
proxy_pass http://localhost:5000/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

3
gunicorn.conf Normal file
View File

@@ -0,0 +1,3 @@
[program:gunicorn]
command=/usr/bin/gunicorn app:app -b localhost:5000
directory=/deploy/app

5
supervisord.conf Normal file
View File

@@ -0,0 +1,5 @@
[supervisord]
nodaemon=true
[program:nginx]
command=/usr/sbin/nginx