forked from rDrama/rDrama
parent
d98e4c9c1c
commit
08d6a9c901
43
Dockerfile
43
Dockerfile
|
@ -1,11 +1,44 @@
|
||||||
FROM ubuntu:22.04
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
ADD .. /service
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN /service/ubuntu_setup.sh
|
RUN apt update
|
||||||
|
RUN apt -y upgrade
|
||||||
|
RUN apt install -y supervisor
|
||||||
|
RUN apt install -y python3-pip
|
||||||
|
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
|
||||||
|
|
||||||
|
COPY requirements.txt /etc/requirements.txt
|
||||||
|
|
||||||
|
RUN pip3 install -r /etc/requirements.txt
|
||||||
|
|
||||||
|
RUN mkdir /images
|
||||||
|
RUN mkdir /songs
|
||||||
|
RUN mkdir /videos
|
||||||
|
RUN mkdir /audio
|
||||||
|
RUN mkdir /asset_submissions
|
||||||
|
RUN mkdir /asset_submissions/marseys
|
||||||
|
RUN mkdir /asset_submissions/hats
|
||||||
|
RUN mkdir /asset_submissions/marseys/original
|
||||||
|
RUN mkdir /asset_submissions/hats/original
|
||||||
|
|
||||||
|
ENV NODE_VERSION=16.13.0
|
||||||
|
RUN apt install -y curl
|
||||||
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
||||||
|
ENV NVM_DIR=/root/.nvm
|
||||||
|
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
|
||||||
|
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
|
||||||
|
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
|
||||||
|
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
||||||
|
RUN node --version
|
||||||
|
RUN npm --version
|
||||||
|
RUN npm i -g yarn
|
||||||
|
|
||||||
EXPOSE 80/tcp
|
EXPOSE 80/tcp
|
||||||
|
|
||||||
RUN apt install -y supervisor
|
CMD [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ]
|
||||||
|
|
||||||
CMD [ "/usr/bin/supervisord", "-c", "/service/supervisord.conf" ]
|
|
||||||
|
|
|
@ -15,11 +15,10 @@ services:
|
||||||
- "redis"
|
- "redis"
|
||||||
- "postgres"
|
- "postgres"
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "80:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- postgres
|
- postgres
|
||||||
- nginx
|
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
|
@ -27,8 +26,9 @@ services:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres
|
image: postgres:12.3
|
||||||
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"
|
||||||
|
@ -36,11 +36,3 @@ services:
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
nginx:
|
|
||||||
image: nginx
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
volumes:
|
|
||||||
- ./nginx.txt:/etc/nginx/conf.d/default.conf
|
|
||||||
- ./nginx-serve-static.txt:/etc/nginx/includes/serve-static
|
|
||||||
|
|
|
@ -9,6 +9,16 @@ from files.helpers.get import *
|
||||||
from files.helpers.wrappers import *
|
from files.helpers.wrappers import *
|
||||||
from files.routes.static import marsey_list
|
from files.routes.static import marsey_list
|
||||||
|
|
||||||
|
@app.get('/asset_submissions/<path:path>')
|
||||||
|
@limiter.exempt
|
||||||
|
def asset_submissions(path):
|
||||||
|
resp = make_response(send_from_directory('/asset_submissions', path))
|
||||||
|
resp.headers.remove("Cache-Control")
|
||||||
|
resp.headers.add("Cache-Control", "public, max-age=3153600")
|
||||||
|
resp.headers.remove("Content-Type")
|
||||||
|
resp.headers.add("Content-Type", "image/webp")
|
||||||
|
return resp
|
||||||
|
|
||||||
@app.get("/submit/marseys")
|
@app.get("/submit/marseys")
|
||||||
@auth_required
|
@auth_required
|
||||||
def submit_marseys(v):
|
def submit_marseys(v):
|
||||||
|
|
|
@ -297,6 +297,40 @@ def static_service(path):
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
### BEGIN FALLBACK ASSET SERVING
|
||||||
|
# In production, we have nginx serve these locations now.
|
||||||
|
# These routes stay for local testing. Requests don't reach them on prod.
|
||||||
|
|
||||||
|
@app.get('/images/<path>')
|
||||||
|
@app.get('/hostedimages/<path>')
|
||||||
|
@app.get("/static/images/<path>")
|
||||||
|
@limiter.exempt
|
||||||
|
def images(path):
|
||||||
|
resp = make_response(send_from_directory('/images', path))
|
||||||
|
resp.headers.remove("Cache-Control")
|
||||||
|
resp.headers.add("Cache-Control", "public, max-age=3153600")
|
||||||
|
resp.headers.remove("Content-Type")
|
||||||
|
resp.headers.add("Content-Type" ,"image/webp")
|
||||||
|
return resp
|
||||||
|
|
||||||
|
@app.get('/videos/<path>')
|
||||||
|
@limiter.exempt
|
||||||
|
def videos(path):
|
||||||
|
resp = make_response(send_from_directory('/videos', path))
|
||||||
|
resp.headers.remove("Cache-Control")
|
||||||
|
resp.headers.add("Cache-Control", "public, max-age=3153600")
|
||||||
|
return resp
|
||||||
|
|
||||||
|
@app.get('/audio/<path>')
|
||||||
|
@limiter.exempt
|
||||||
|
def audio(path):
|
||||||
|
resp = make_response(send_from_directory('/audio', path))
|
||||||
|
resp.headers.remove("Cache-Control")
|
||||||
|
resp.headers.add("Cache-Control", "public, max-age=3153600")
|
||||||
|
return resp
|
||||||
|
|
||||||
|
### END FALLBACK ASSET SERVING
|
||||||
|
|
||||||
@app.get("/robots.txt")
|
@app.get("/robots.txt")
|
||||||
def robots_txt():
|
def robots_txt():
|
||||||
return send_file("assets/robots.txt")
|
return send_file("assets/robots.txt")
|
||||||
|
|
17
nginx.txt
17
nginx.txt
|
@ -1,15 +1,17 @@
|
||||||
server {
|
server {
|
||||||
server_name rdrama.net;
|
server_name rdrama.net;
|
||||||
client_max_body_size 100m;
|
client_max_body_size 100m;
|
||||||
listen 80;
|
listen 443 ssl;
|
||||||
listen [::]:80;
|
listen [::]:443 ssl;
|
||||||
|
ssl_certificate '/rdrama.pem';
|
||||||
|
ssl_certificate_key '/rdrama.key';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_set_header Host $http_host;
|
proxy_pass http://localhost:5000/;
|
||||||
proxy_pass http://rDrama:5000/;
|
|
||||||
}
|
}
|
||||||
location /socket.io {
|
location /socket.io {
|
||||||
proxy_set_header Host $http_host;
|
include proxy_params;
|
||||||
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;
|
||||||
|
@ -32,4 +34,9 @@ server {
|
||||||
location /asset_submissions/ {
|
location /asset_submissions/ {
|
||||||
include includes/serve-static;
|
include includes/serve-static;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_page 502 = /error_page/502.html;
|
||||||
|
location /error_page/ {
|
||||||
|
alias /rDrama/files/templates/errors/;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
10
readme.md
10
readme.md
|
@ -16,11 +16,17 @@ git clone https://github.com/Aevann1/rDrama/
|
||||||
|
|
||||||
cd rDrama
|
cd rDrama
|
||||||
|
|
||||||
docker-compose down --rmi all --remove-orphans --volumes
|
|
||||||
|
|
||||||
docker-compose up
|
docker-compose up
|
||||||
```
|
```
|
||||||
|
|
||||||
3- That's it! Visit `localhost` in your browser and make an account (the first account to be made will have full admin rights)
|
3- That's it! Visit `localhost` in your browser and make an account (the first account to be made will have full admin rights)
|
||||||
|
|
||||||
4- Optional: to change the domain from "localhost" to something else and configure the site settings, as well as integrate it with the external services the website uses, edit the variables in the `env` file and then restart the docker container.
|
4- Optional: to change the domain from "localhost" to something else and configure the site settings, as well as integrate it with the external services the website uses, edit the variables in the `env` file and then restart the docker container.
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
For returning contributors, we have noticed the following issues (if you can help fix them, we will be very grateful!):
|
||||||
|
|
||||||
|
1. Docker doesn't know when we add a new Python dependency, `docker-compose build` is needed.
|
||||||
|
2. DB schema changes are not applied automatically, the easiest way to deal with that is to delete the entire environment from the Docker GUI and do `docker-compose up`. Also wait five minutes for a "sneed" commit from Aevann meaning that the sql file was regenerated.
|
|
@ -5,7 +5,7 @@ logfile=/tmp/supervisord.log
|
||||||
|
|
||||||
[program:service]
|
[program:service]
|
||||||
directory=/service
|
directory=/service
|
||||||
command=gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:5000 --max-requests 30000 --max-requests-jitter 10000
|
command=gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:80 --max-requests 30000 --max-requests-jitter 10000
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
cd /rDrama
|
# locale-gen "en_US.UTF-8"
|
||||||
cp ./env /env
|
# update-locale LANG=en_US.utf8
|
||||||
sed -i 's/^/export /g;s/=/="/g;s/$/"/g' /env
|
# update-locale LC_ALL=en_US.utf8
|
||||||
. /env
|
# 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
|
||||||
|
|
||||||
git config --global credential.helper store
|
git config --global credential.helper store
|
||||||
|
cd /rDrama
|
||||||
|
cp ./env /env
|
||||||
|
sed -i 's/^/export /g;s/=/="/g;s/$/"/g' /env
|
||||||
|
. /env
|
||||||
|
|
||||||
mkdir /scripts
|
mkdir /scripts
|
||||||
cp ./startup.sh /scripts/s
|
cp ./startup.sh /scripts/s
|
||||||
|
|
Loading…
Reference in New Issue