add docker things

This commit is contained in:
purerosefallen 2019-06-01 23:01:50 +08:00
parent c3ec32238c
commit ad1d7a04c8
No known key found for this signature in database
GPG Key ID: E6D78C90943A3185
4 changed files with 97 additions and 0 deletions

38
Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM node:stretch
#RUN sed -i 's/deb.debian.org/mirrors.163.com/g' /etc/apt/sources.list && \
# sed -i 's/security.debian.org/mirrors.163.com/g' /etc/apt/sources.list
# apt
RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y curl wget vim sudo git sqlite3 python2.7 python-virtualenv python3.5 python3-virtualenv ffmpeg nginx
#pm2
RUN npm install -g pm2
COPY . /taiko-web
WORKDIR /taiko-web
#python virtualenv
RUN bash -c 'virtualenv -p /usr/bin/python2 .venv2 && \
source .venv2/bin/activate && \
pip install Flask Flask-Caching ffmpy gunicorn && \
deactivate'
RUN bash -c 'virtualenv -p /usr/bin/python3 .venv3 && \
source .venv3/bin/activate && \
pip install websockets && \
deactivate'
RUN ln -s /taiko-web/templates/index.html /taiko-web/public/index.html && \
ln -s /taiko-web/public/songs/taiko.db /taiko-web/taiko.db
#nginx
RUN cp -rf /taiko-web/docker/taiko-web-nginx.conf /etc/nginx/conf.d/ && \
rm -rf /etc/nginx/sites-enabled/*
#info
EXPOSE 80
VOLUME ["/taiko-web/public/songs"]
CMD [ "/taiko-web/docker/entrypoint.sh" ]

8
docker/entrypoint.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
cd /taiko-web
echo "{\"songs_baseurl\":\"$TAIKO_URL/songs/\",\"assets_baseurl\":\"$TAIKO_URL/assets/\"}" | tee ./config.json
echo "{\"commit\":\"$(git log --pretty=%H -1)\",\"commit_short\":\"$(git log --pretty=%h -1)\",\"version\": \"$TAIKO_VERSION\"}" | tee ./version.json
pm2-docker start ./docker/pm2-docker.json

23
docker/pm2-docker.json Normal file
View File

@ -0,0 +1,23 @@
{
"apps": [
{
"name": "taiko-web",
"script": "/taiko-web/.venv2/bin/gunicorn",
"interpreter": "/taiko-web/.venv2/bin/python2",
"args": "-b 127.0.0.1:34801 app:app",
"cwd": "/taiko-web"
},
{
"name": "taiko-web-server",
"interpreter": "/taiko-web/.venv3/bin/python",
"script": "/taiko-web/server.py",
"args": "34802",
"cwd": "/taiko-web"
},
{
"name": "nginx",
"script": "/usr/sbin/nginx",
"args": "-g \"daemon off;\""
}
]
}

View File

@ -0,0 +1,28 @@
server {
listen 80;
server_name _;
server_tokens off;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $server_name;
proxy_read_timeout 7200s;
proxy_pass http://127.0.0.1:34801;
proxy_max_temp_file_size 50000m;
}
location ~ ^/(assets|songs|src)/ {
root /taiko-web/public;
location ~ ^/songs/([0-9]+)/preview\.mp3$ {
try_files $uri /api/preview?id=$1;
}
}
location /p2 {
proxy_pass http://127.0.0.1:34802;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}