From b27296e317e0eec87245fba2a58a38fdcb09e8ec Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 7 Jun 2022 11:46:39 +0200 Subject: [PATCH] Add Docker image and compose with documentation --- .gitignore | 3 ++- Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 29 +++++++++++++++++++++++++++++ docker.md | 40 ++++++++++++++++++++++++++++++++++++++++ twitfix_proxy.conf | 24 ++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 docker.md create mode 100644 twitfix_proxy.conf diff --git a/.gitignore b/.gitignore index 216bd44..e11fb61 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ node_modules admin.env .env _meta -.serverless \ No newline at end of file +.serverless +db/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9db5f69 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.6-alpine AS build +RUN apk add build-base python3-dev linux-headers pcre-dev jpeg-dev zlib-dev +RUN pip install --upgrade pip +RUN pip install yt-dlp pillow uwsgi + +FROM python:3.6-alpine AS deps +WORKDIR /twitfix +COPY requirements.txt requirements.txt +COPY --from=build /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages +RUN pip install -r requirements.txt + +FROM python:3.6-alpine AS runner +EXPOSE 9000 +RUN apk add pcre-dev jpeg-dev zlib-dev +WORKDIR /twitfix +CMD ["uwsgi", "twitfix.ini"] +COPY --from=build /usr/local/bin/uwsgi /usr/local/bin/uwsgi +COPY --from=deps /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages +COPY . . diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9e5c8ed --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +version: "3" + +services: + proxy: + image: nginx:alpine + container_name: twitfix_proxy + volumes: + - "./twitfix_proxy.conf:/etc/nginx/conf.d/default.conf" + ports: + - 8088:80 + depends_on: + - twitfix + + twitfix: + image: twitfix + build: . + container_name: twitfix_main + volumes: + - "./twitfix.ini:/twitfix/twitfix.ini:ro" + - "./config.json:/twitfix/config.json:ro" + depends_on: + - db + + db: + image: mongo:5.0.9 + container_name: twitfix_db + volumes: + - "./db:/data/db" + diff --git a/docker.md b/docker.md new file mode 100644 index 0000000..fc1d86d --- /dev/null +++ b/docker.md @@ -0,0 +1,40 @@ +# vxTwitter Docker + +## Configuration + +Setup mongodb in `config.json`: +```json +{ + "config":{ + "link_cache":"db", + "database":"mongodb://twitfix_db:27017/", + [...] + }, + [...] +} +``` + +Use TCP socket for uwsgi `twitfix.ini`: +```ini +[uwsgi] +module = wsgi:app + +master = true +processes = 5 + +socket = 0.0.0.0:9000 +buffer-size = 8192 +#socket = /var/run/twitfix.sock +#chmod-socket = 660 +vacuum = true + +die-on-term = true +``` + +## Run + +To run and build, use this command: +```bash +docker-compose up -d --build +``` + diff --git a/twitfix_proxy.conf b/twitfix_proxy.conf new file mode 100644 index 0000000..5ee2495 --- /dev/null +++ b/twitfix_proxy.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + try_files $uri @twitfix; + } + + location @twitfix { + include uwsgi_params; + uwsgi_pass uwsgi://twitfix_main:9000; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +}