add nginx to docker

master
Aevann1 2022-10-04 21:48:52 +02:00
parent 08d6a9c901
commit bf9a2398da
10 changed files with 64 additions and 58 deletions

View File

@ -10,8 +10,7 @@ RUN apt install -y ffmpeg
RUN apt install -y imagemagick
RUN apt install -y postgresql
RUN apt install -y libpq-dev
COPY supervisord.conf /etc/supervisord.conf
RUN apt install -y nano
COPY requirements.txt /etc/requirements.txt
@ -39,6 +38,11 @@ RUN node --version
RUN npm --version
RUN npm i -g yarn
RUN apt install -y nginx
RUN rm /etc/nginx/sites-available -r
RUN rm /etc/nginx/sites-enabled/default
RUN mkdir /etc/nginx/includes
EXPOSE 80/tcp
CMD [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ]
CMD [ "/usr/bin/supervisord", "-c", "/rDrama/supervisord.conf" ]

View File

@ -1,38 +1,37 @@
version: '2.3'
services:
files:
container_name: "rDrama"
build:
context: .
volumes:
- "./:/service"
env_file: env
environment:
- DATABASE_URL=postgresql://postgres@postgres:5432
- REDIS_URL=redis://redis
links:
- "redis"
- "postgres"
ports:
- "80:80"
depends_on:
- redis
- postgres
files:
container_name: "rDrama"
build:
context: .
volumes:
- "./:/rDrama"
- "./nginx.conf:/etc/nginx/sites-enabled/1"
- "./nginx-serve-static.conf:/etc/nginx/includes/serve-static"
env_file: env
environment:
- DATABASE_URL=postgresql://postgres@postgres:5432
- REDIS_URL=redis://redis
links:
- "redis"
- "postgres"
ports:
- "80:80"
depends_on:
- redis
- postgres
redis:
image: redis
ports:
- "6379:6379"
redis:
image: redis
ports:
- "6379:6379"
postgres:
image: postgres:12.3
command: ["postgres", "-c", "log_statement=all"]
# uncomment this if u wanna output all SQL queries to the console
volumes:
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"
- "./seed-db.sql:/docker-entrypoint-initdb.d/10-seed-db.sql"
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- "5432:5432"
postgres:
image: postgres
command: ["postgres", "-c", "log_statement=all"]
volumes:
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"
- "./seed-db.sql:/docker-entrypoint-initdb.d/10-seed-db.sql"
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- "5432:5432"

4
env
View File

@ -1,4 +1,4 @@
FLASK_APP=/service/files/cli:app
FLASK_APP=/rDrama/files/cli:app
MASTER_KEY=blahblahblah
DOMAIN=localhost
SITE_NAME=rDrama
@ -33,4 +33,4 @@ CF_KEY=blahblahblah
CF_ZONE=blahblahblah
DEBIAN_FRONTEND=noninteractive
NODE_VERSION=16.13.0
NVM_DIR=/root/.nvm
NVM_DIR=/root/.nvm

View File

@ -129,10 +129,7 @@ def teardown_request(error):
del g.db
stdout.flush()
if app.config["SERVER_NAME"] == 'localhost':
from files.routes import *
from files.routes.chat import *
elif "load_chat" in argv:
if "load_chat" in argv:
from files.routes.chat import *
else:
from files.routes import *

View File

@ -284,7 +284,7 @@ def sign_up_post(v):
return signup_error("There was a problem. Please try again.")
if not hmac.compare_digest(correct_formkey, form_formkey):
return signup_error("There was a problem. Please try again.")
return signup_error("There was a problem. Please try again!")
if not request.values.get(
"password") == request.values.get("password_confirm"):

View File

@ -1,17 +1,15 @@
server {
server_name rdrama.net;
client_max_body_size 100m;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate '/rdrama.pem';
ssl_certificate_key '/rdrama.key';
proxy_set_header Host $host;
listen 80;
listen [::]:80;
proxy_set_header Host $http_host;
location / {
proxy_pass http://localhost:5000/;
}
location /socket.io {
include proxy_params;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;

View File

@ -0,0 +1,7 @@
/etc/init.d/nginx start
cd ./chat
yarn install
yarn chat
cd ..
gunicorn files.__main__:app load_chat -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 -b 0.0.0.0:5001 --max-requests 30000 --max-requests-jitter 30000 -D
gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:5000 --max-requests 30000 --max-requests-jitter 10000

View File

@ -3,10 +3,10 @@ nodaemon=true
pidfile=/tmp/supervisord.pid
logfile=/tmp/supervisord.log
[program:service]
directory=/service
command=gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:80 --max-requests 30000 --max-requests-jitter 10000
[program:rDrama]
directory=/rDrama
command=sh startup_docker.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stderr_logfile_maxbytes=0

View File

@ -4,7 +4,7 @@
# reboot
apt -y update
apt -y upgrade
apt -y install git redis-server python3-pip ffmpeg imagemagick tmux nginx snapd ufw gpg-agent htop
apt -y install git redis-server python3-pip ffmpeg imagemagick tmux nginx snapd ufw gpg-agent htop nano
git config --global credential.helper store
cd /rDrama
@ -29,8 +29,9 @@ chown postgres:postgres /etc/postgresql/14/main/pg_hba.conf
sudo rm /etc/nginx/sites-available -r
sudo rm /etc/nginx/sites-enabled/default
sudo mkdir /etc/nginx/includes
sudo cp nginx.txt /etc/nginx/sites-enabled/1
sudo cp nginx-serve-static.txt /etc/nginx/includes/serve-static
sudo cp nginx.conf /etc/nginx/sites-enabled/1
sudo cp nginx-serve-static.conf /etc/nginx/includes/serve-static
/etc/init.d/nginx reload
psql -U postgres -f schema.sql postgres
psql -U postgres -f seed-db.sql postgres