add nginx to docker

remotes/1693176582716663532/tmp_refs/heads/watchparty
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 imagemagick
RUN apt install -y postgresql RUN apt install -y postgresql
RUN apt install -y libpq-dev RUN apt install -y libpq-dev
RUN apt install -y nano
COPY supervisord.conf /etc/supervisord.conf
COPY requirements.txt /etc/requirements.txt COPY requirements.txt /etc/requirements.txt
@ -39,6 +38,11 @@ RUN node --version
RUN npm --version RUN npm --version
RUN npm i -g yarn 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 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: services:
files: files:
container_name: "rDrama" container_name: "rDrama"
build: build:
context: . context: .
volumes: volumes:
- "./:/service" - "./:/rDrama"
env_file: env - "./nginx.conf:/etc/nginx/sites-enabled/1"
environment: - "./nginx-serve-static.conf:/etc/nginx/includes/serve-static"
- DATABASE_URL=postgresql://postgres@postgres:5432 env_file: env
- REDIS_URL=redis://redis environment:
links: - DATABASE_URL=postgresql://postgres@postgres:5432
- "redis" - REDIS_URL=redis://redis
- "postgres" links:
ports: - "redis"
- "80:80" - "postgres"
depends_on: ports:
- redis - "80:80"
- postgres depends_on:
- redis
- postgres
redis: redis:
image: redis image: redis
ports: ports:
- "6379:6379" - "6379:6379"
postgres: postgres:
image: postgres:12.3 image: postgres
command: ["postgres", "-c", "log_statement=all"] command: ["postgres", "-c", "log_statement=all"]
# uncomment this if u wanna output all SQL queries to the console volumes:
volumes: - "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql" - "./seed-db.sql:/docker-entrypoint-initdb.d/10-seed-db.sql"
- "./seed-db.sql:/docker-entrypoint-initdb.d/10-seed-db.sql" environment:
environment: - POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_HOST_AUTH_METHOD=trust ports:
ports: - "5432:5432"
- "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 MASTER_KEY=blahblahblah
DOMAIN=localhost DOMAIN=localhost
SITE_NAME=rDrama SITE_NAME=rDrama
@ -33,4 +33,4 @@ CF_KEY=blahblahblah
CF_ZONE=blahblahblah CF_ZONE=blahblahblah
DEBIAN_FRONTEND=noninteractive DEBIAN_FRONTEND=noninteractive
NODE_VERSION=16.13.0 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 del g.db
stdout.flush() stdout.flush()
if app.config["SERVER_NAME"] == 'localhost': if "load_chat" in argv:
from files.routes import *
from files.routes.chat import *
elif "load_chat" in argv:
from files.routes.chat import * from files.routes.chat import *
else: else:
from files.routes import * 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.") return signup_error("There was a problem. Please try again.")
if not hmac.compare_digest(correct_formkey, form_formkey): 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( if not request.values.get(
"password") == request.values.get("password_confirm"): "password") == request.values.get("password_confirm"):

View File

@ -1,17 +1,15 @@
server { server {
server_name rdrama.net; server_name rdrama.net;
client_max_body_size 100m; client_max_body_size 100m;
listen 443 ssl; listen 80;
listen [::]:443 ssl; listen [::]:80;
ssl_certificate '/rdrama.pem'; proxy_set_header Host $http_host;
ssl_certificate_key '/rdrama.key';
proxy_set_header Host $host;
location / { location / {
proxy_pass http://localhost:5000/; proxy_pass http://localhost:5000/;
} }
location /socket.io { location /socket.io {
include proxy_params; proxy_set_header Host $http_host;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_buffering off; proxy_buffering off;
proxy_set_header Upgrade $http_upgrade; 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 pidfile=/tmp/supervisord.pid
logfile=/tmp/supervisord.log logfile=/tmp/supervisord.log
[program:service] [program:rDrama]
directory=/service directory=/rDrama
command=gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:80 --max-requests 30000 --max-requests-jitter 10000 command=sh startup_docker.sh
stdout_logfile=/dev/stdout stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0 stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0 stderr_logfile_maxbytes=0

View File

@ -4,7 +4,7 @@
# reboot # reboot
apt -y update apt -y update
apt -y upgrade 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 git config --global credential.helper store
cd /rDrama 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-available -r
sudo rm /etc/nginx/sites-enabled/default sudo rm /etc/nginx/sites-enabled/default
sudo mkdir /etc/nginx/includes sudo mkdir /etc/nginx/includes
sudo cp nginx.txt /etc/nginx/sites-enabled/1 sudo cp nginx.conf /etc/nginx/sites-enabled/1
sudo cp nginx-serve-static.txt /etc/nginx/includes/serve-static 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 schema.sql postgres
psql -U postgres -f seed-db.sql postgres psql -U postgres -f seed-db.sql postgres