6 changed files with 133 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||||
|
**/__pycache__/ |
||||
|
build/ |
||||
|
dist/ |
||||
|
**/*.egg-info |
||||
@ -0,0 +1,15 @@ |
|||||
|
version: "2" |
||||
|
|
||||
|
services: |
||||
|
monsun_backend: |
||||
|
build: . |
||||
|
container_name: monsun_backend |
||||
|
restart: always |
||||
|
ports: |
||||
|
- 80:80 |
||||
|
volumes: |
||||
|
- ./log:/app/log |
||||
|
- /dev/:/dev/ |
||||
|
command: ["bash", "./docker-entrypoint.sh"] |
||||
|
# devices: |
||||
|
# - "/dev/tty.usbmodem207E3283544E1:/dev/tty.usbmodem207E3283544E1" |
||||
@ -0,0 +1,5 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
source /opt/venv/bin/activate |
||||
|
|
||||
|
service nginx start |
||||
|
uwsgi --ini uwsgi.ini |
||||
@ -0,0 +1,50 @@ |
|||||
|
# stage 1 |
||||
|
FROM python:3.7-slim-buster as backend-build |
||||
|
|
||||
|
VOLUME /app |
||||
|
WORKDIR /app |
||||
|
|
||||
|
RUN apt-get update \ |
||||
|
&& apt-get -y install python3-dev \ |
||||
|
&& apt-get -y install build-essential |
||||
|
# && apt-get -y install libglib2.0-0 \ |
||||
|
# && apt-get -y install libsm6 libxext6 libxrender-dev |
||||
|
|
||||
|
RUN python3 -m venv /opt/venv |
||||
|
|
||||
|
COPY . . |
||||
|
|
||||
|
RUN . /opt/venv/bin/activate \ |
||||
|
&& pip install --upgrade setuptools wheel \ |
||||
|
&& pip install -r requirements.txt \ |
||||
|
&& python setup.py sdist bdist_wheel > build.log \ |
||||
|
&& pip install monsun_backend --no-index --find-links file:///app/dist |
||||
|
|
||||
|
# stage 2 |
||||
|
FROM python:3.7-slim-buster |
||||
|
|
||||
|
RUN apt-get update \ |
||||
|
&& apt-get -y install nginx \ |
||||
|
&& apt-get -y install python3-dev \ |
||||
|
&& apt-get -y install build-essential \ |
||||
|
&& apt-get -qy install netcat |
||||
|
# && apt-get -y install libglib2.0-0 \ |
||||
|
# && apt-get -y install libsm6 libxext6 libxrender-dev |
||||
|
|
||||
|
# RUN mkdir /data |
||||
|
# VOLUME /data |
||||
|
|
||||
|
VOLUME /app |
||||
|
WORKDIR /app |
||||
|
|
||||
|
COPY --from=backend-build /app/build.log /app/build.log |
||||
|
COPY docker-entrypoint.sh /app/docker-entrypoint.sh |
||||
|
COPY wsgi.py /app/wsgi.py |
||||
|
COPY nginx.conf /etc/nginx |
||||
|
COPY uwsgi.ini /app/uwsgi.ini |
||||
|
|
||||
|
COPY config.yml /app/config.yml |
||||
|
|
||||
|
COPY --from=backend-build /opt/venv /opt/venv |
||||
|
|
||||
|
CMD ["bash", "./docker-entrypoint.sh"] |
||||
@ -0,0 +1,47 @@ |
|||||
|
user www-data; |
||||
|
worker_processes auto; |
||||
|
pid /run/nginx.pid; |
||||
|
|
||||
|
events { |
||||
|
worker_connections 1024; |
||||
|
use epoll; |
||||
|
multi_accept on; |
||||
|
} |
||||
|
|
||||
|
http { |
||||
|
access_log /dev/stdout; |
||||
|
error_log /dev/stdout; |
||||
|
|
||||
|
sendfile on; |
||||
|
tcp_nopush on; |
||||
|
tcp_nodelay on; |
||||
|
keepalive_timeout 65; |
||||
|
types_hash_max_size 2048; |
||||
|
|
||||
|
client_max_body_size 20M; |
||||
|
|
||||
|
include /etc/nginx/mime.types; |
||||
|
default_type application/octet-stream; |
||||
|
|
||||
|
index index.html index.htm; |
||||
|
|
||||
|
server { |
||||
|
listen 80 default_server; |
||||
|
listen [::]:80 default_server; |
||||
|
server_name localhost; |
||||
|
root /var/www/html; |
||||
|
|
||||
|
location / { |
||||
|
include uwsgi_params; |
||||
|
uwsgi_pass unix:/tmp/uwsgi.socket; |
||||
|
uwsgi_read_timeout 1h; |
||||
|
uwsgi_send_timeout 1h; |
||||
|
proxy_send_timeout 1h; |
||||
|
proxy_read_timeout 1h; |
||||
|
|
||||
|
proxy_buffer_size 128k; |
||||
|
proxy_buffers 4 256k; |
||||
|
proxy_busy_buffers_size 256k; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
[uwsgi] |
||||
|
wsgi-file = wsgi.py |
||||
|
uid = www-data |
||||
|
gid = www-data |
||||
|
master = true |
||||
|
processes = 5 |
||||
|
|
||||
|
socket = /tmp/uwsgi.socket |
||||
|
chmod-sock = 664 |
||||
|
vacuum = true |
||||
|
|
||||
|
die-on-term = true |
||||
Loading…
Reference in new issue