forked from PrivateCoffee/small
Merge pull request 'Add Docker support' (#1) from vlnst/small:Docker into main
Reviewed-on: PrivateCoffee/small#1
This commit is contained in:
commit
6c0cf84d2a
5 changed files with 61 additions and 4 deletions
3
.env.example
Normal file
3
.env.example
Normal file
|
@ -0,0 +1,3 @@
|
|||
PORT=8002
|
||||
UWSGI_PROCESSES=4
|
||||
UWSGI_THREADS=4
|
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
|||
venv/
|
||||
.venv/
|
||||
__pycache__/
|
||||
/dist/
|
||||
docker-compose.yml
|
||||
.env
|
||||
*.pyc
|
||||
/dist/
|
||||
__pycache__/
|
||||
.venv/
|
||||
venv/
|
||||
|
|
19
Dockerfile
Normal file
19
Dockerfile
Normal file
|
@ -0,0 +1,19 @@
|
|||
FROM alpine:3.20
|
||||
|
||||
ENV APP_ENV=/opt/venv
|
||||
ENV PATH="${APP_ENV}/bin:$PATH"
|
||||
|
||||
WORKDIR $APP_ENV
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN apk add --no-cache py3-pip uwsgi-python3 && \
|
||||
python3 -m venv $APP_ENV && \
|
||||
pip install --no-cache-dir . && \
|
||||
adduser -D -H small
|
||||
|
||||
EXPOSE 8002
|
||||
|
||||
USER small:small
|
||||
|
||||
ENTRYPOINT ["/opt/venv/entrypoint.sh"]
|
15
docker-compose-example.yml
Normal file
15
docker-compose-example.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
services:
|
||||
small:
|
||||
container_name: small
|
||||
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
18
entrypoint.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
args="--plugin python3 \
|
||||
--http-socket 0.0.0.0:$PORT \
|
||||
--master \
|
||||
--module small.app: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
|
Loading…
Reference in a new issue