From 923854c322f1a0166af93041c339fabd86f3be13 Mon Sep 17 00:00:00 2001 From: vlnst Date: Mon, 17 Jun 2024 17:54:05 +0300 Subject: [PATCH 1/2] Add new instance structables.bloat.cat --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 74970cb..bc1b01f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ An open source alternative front-end to Instructables. This is a fork of Date: Mon, 17 Jun 2024 18:40:34 +0300 Subject: [PATCH 2/2] Add Docker support --- .env.example | 3 +++ .gitignore | 12 +++++++----- Dockerfile | 17 +++++++++++++++++ docker-compose-example.yml | 18 ++++++++++++++++++ entrypoint.sh | 18 ++++++++++++++++++ 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .env.example create mode 100644 Dockerfile create mode 100644 docker-compose-example.yml create mode 100755 entrypoint.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..0cfbf09 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +PORT=8002 +UWSGI_PROCESSES=4 +UWSGI_THREADS=4 diff --git a/.gitignore b/.gitignore index e9fb3cf..0a3a81a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ -venv/ -*.pyc -__pycache__/ +.env .vscode -privacy.txt +__pycache__/ +dist/ +docker-compose.yml privacy.md -/dist/ \ No newline at end of file +privacy.txt +*.pyc +venv/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2db183 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:3.20 + +ENV APP_ENV=/opt/venv +ENV PATH="${APP_ENV}/bin:$PATH" + +RUN apk add --no-cache py3-pip uwsgi-python3 && \ + python3 -m venv $APP_ENV && \ + $APP_ENV/bin/pip install --no-cache-dir pip structables && \ + adduser -S -D -H structables + +COPY entrypoint.sh /entrypoint.sh + +EXPOSE 8002 + +USER structables + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-compose-example.yml b/docker-compose-example.yml new file mode 100644 index 0000000..c75ca88 --- /dev/null +++ b/docker-compose-example.yml @@ -0,0 +1,18 @@ +services: + structables: + container_name: structables + restart: unless-stopped + build: . + ports: + - "127.0.0.1:8002:8002" + env_file: .env + security_opt: + - no-new-privileges:true + cap_drop: + - ALL + read_only: true + deploy: + resources: + limits: + cpus: '0.5' + memory: 300M diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..90814a6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh +args="--plugin python3 \ + --http-socket 0.0.0.0:$PORT \ + --master \ + --module structables.main:app \ + -H /opt/venv" + +if [ "$UWSGI_PROCESSES" ] +then + args="$args --processes $UWSGI_PROCESSES" +fi + +if [ "$UWSGI_THREADS" ] +then + args="$args --threads $UWSGI_THREADS" +fi + +exec /usr/sbin/uwsgi $args -- 2.39.5