Add Docker image and compose with documentation

This commit is contained in:
Ethanell 2022-06-07 11:46:39 +02:00
parent 40f4770e17
commit b27296e317
5 changed files with 114 additions and 1 deletions

3
.gitignore vendored
View file

@ -7,4 +7,5 @@ node_modules
admin.env admin.env
.env .env
_meta _meta
.serverless .serverless
db/

19
Dockerfile Normal file
View file

@ -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 . .

29
docker-compose.yml Normal file
View file

@ -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"

40
docker.md Normal file
View file

@ -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
```

24
twitfix_proxy.conf Normal file
View file

@ -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;
}
}