mirror of
https://github.com/asimonson1125/asimonson1125.github.io.git
synced 2026-02-25 05:09:49 -06:00
added nginx with supervisor
so much suffering occurred here. Let's hope it was worth it.
This commit is contained in:
37
Dockerfile
37
Dockerfile
@@ -1,13 +1,34 @@
|
||||
FROM docker.io/python:3.8-buster
|
||||
FROM ubuntu:lunar
|
||||
LABEL maintainer="Andrew Simonson <asimonson1125@gmail.com>"
|
||||
|
||||
WORKDIR /app
|
||||
ADD ./src /app
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
COPY . .
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y python3-pip nginx gunicorn supervisor
|
||||
|
||||
RUN apt-get -yq update && \
|
||||
pip install --no-cache-dir -r ./src/requirements.txt
|
||||
WORKDIR /app/src
|
||||
# Setup flask application
|
||||
RUN mkdir -p /deploy/app
|
||||
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 && \
|
||||
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
|
||||
|
||||
# Permissions
|
||||
# RUN adduser --disabled-password --gecos '' supervisor && \
|
||||
RUN chmod -R 777 /var/* && \
|
||||
chown -R root /var/*
|
||||
|
||||
# Entrypoint
|
||||
USER root
|
||||
|
||||
# Start processes
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
|
||||
9
flask.conf
Normal file
9
flask.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
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
3
gunicorn.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
[program:gunicorn]
|
||||
command=/usr/bin/gunicorn app:app -b localhost:5000
|
||||
directory=/deploy/app
|
||||
19
supervisord.conf
Normal file
19
supervisord.conf
Normal file
@@ -0,0 +1,19 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/dev/null
|
||||
username = dummy
|
||||
password = dummy
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/dev/null
|
||||
|
||||
[unix_http_server]
|
||||
username = dummy
|
||||
password = dummy
|
||||
|
||||
[supervisorctl]
|
||||
username = dummy
|
||||
password = dummy
|
||||
Reference in New Issue
Block a user