Merge pull request 'Add Docker' (#6) from vlnst/structables:docker into main

Reviewed-on: #6
This commit is contained in:
Kumi 2024-06-17 16:44:33 +00:00 committed by git.private.coffee
commit 0f91a929d2
Signed by: git.private.coffee
GPG key ID: 60CFD1C72200C214
6 changed files with 64 additions and 5 deletions

3
.env.example Normal file
View file

@ -0,0 +1,3 @@
PORT=8002
UWSGI_PROCESSES=4
UWSGI_THREADS=4

12
.gitignore vendored
View file

@ -1,7 +1,9 @@
venv/
*.pyc
__pycache__/
.env
.vscode
privacy.txt
__pycache__/
dist/
docker-compose.yml
privacy.md
/dist/
privacy.txt
*.pyc
venv/

17
Dockerfile Normal file
View file

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

View file

@ -16,6 +16,7 @@ An open source alternative front-end to Instructables. This is a fork of <a href
| URL | Provided by | Country | Comments |
| -------------------------------------------------------------------------- | ----------------------------------------- | ------- | -------- |
| [https://structables.private.coffee/](https://structables.private.coffee/) | [Private.coffee](https://private.coffee/) | Austria | |
| [https://structables.bloat.cat/](https://structables.bloat.cat/) | [Bloat.cat](https://bloat.cat) | Romania | |
To add your own instance to this list, please open a pull request or issue.

View file

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

18
entrypoint.sh Executable file
View file

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