forked from Github-Mirrors/canaille
Feat: Add DockerFile for creating release docker container (Using UWSGI)
This commit is contained in:
parent
1302da6b21
commit
19a8867fbd
3 changed files with 84 additions and 0 deletions
55
Dockerfile
Normal file
55
Dockerfile
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
FROM python AS builder
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt update && \
|
||||||
|
apt -y upgrade && \
|
||||||
|
apt install -y \
|
||||||
|
build-essential \
|
||||||
|
libldap2-dev \
|
||||||
|
libsasl2-dev \
|
||||||
|
libssl-dev
|
||||||
|
|
||||||
|
COPY uv.lock pyproject.toml /opt/canaille/
|
||||||
|
|
||||||
|
RUN pip install uv
|
||||||
|
|
||||||
|
COPY canaille /opt/canaille/canaille
|
||||||
|
|
||||||
|
WORKDIR /opt/canaille
|
||||||
|
|
||||||
|
RUN uv sync --all-extras --upgrade
|
||||||
|
|
||||||
|
# We build a python wheel to install on the definitive docker image
|
||||||
|
RUN uv build --wheel
|
||||||
|
|
||||||
|
# We create a list of all the requirements to install next to canaille on the definitive docker image
|
||||||
|
RUN uv pip compile pyproject.toml --all-extras -o requirements.txt
|
||||||
|
|
||||||
|
WORKDIR /opt/canaille/dist
|
||||||
|
|
||||||
|
# We build these two modules here to avoid including build libraries on the definitive docker image
|
||||||
|
RUN pip wheel python-ldap uwsgi
|
||||||
|
|
||||||
|
FROM python:slim
|
||||||
|
|
||||||
|
# We need libxml2 for uwsgi to work
|
||||||
|
RUN \
|
||||||
|
apt update && \
|
||||||
|
apt -y upgrade && \
|
||||||
|
apt install -y \
|
||||||
|
libxml2
|
||||||
|
|
||||||
|
# I create a volume so that I can mount it in docker using -v ./database:/opt/canaille/database
|
||||||
|
RUN mkdir -p /opt/canaille/database
|
||||||
|
|
||||||
|
COPY --from=builder /opt/canaille/dist /opt/canaille/dist
|
||||||
|
COPY --from=builder /opt/canaille/requirements.txt /opt/canaille/requirements.txt
|
||||||
|
|
||||||
|
RUN pip install --find-links /opt/canaille/dist canaille python-ldap uwsgi
|
||||||
|
RUN pip install -r /opt/canaille/requirements.txt
|
||||||
|
|
||||||
|
COPY uwsgi.ini /opt/canaille
|
||||||
|
|
||||||
|
WORKDIR /opt/canaille
|
||||||
|
|
||||||
|
ENTRYPOINT ["uwsgi","--ini","uwsgi.ini"]
|
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
services:
|
||||||
|
canaille:
|
||||||
|
build: .
|
||||||
|
# image: git.shenanigans.cc/globuzma/canaille:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
volumes:
|
||||||
|
- ./database:/opt/canaille/database
|
||||||
|
- ./config.toml:/opt/canaille/config.toml
|
||||||
|
env:
|
||||||
|
# For an example config file see : https://canaille.readthedocs.io/en/latest/references/configuration.html#example-file
|
||||||
|
- CONFIG=/opt/canaille/config.toml
|
16
uwsgi.ini
Normal file
16
uwsgi.ini
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[uwsgi]
|
||||||
|
http-socket = :5000
|
||||||
|
plugin=python3
|
||||||
|
module=canaille:create_app()
|
||||||
|
lazy-apps=true
|
||||||
|
master=true
|
||||||
|
processes=1
|
||||||
|
threads=10
|
||||||
|
need-app=true
|
||||||
|
thunder-lock=true
|
||||||
|
touch-chain-reload=/etc/canaille/uwsgi-reload.fifo
|
||||||
|
enable-threads=true
|
||||||
|
reload-on-rss=1024
|
||||||
|
worker-reload-mercy=600
|
||||||
|
buffer-size=65535
|
||||||
|
disable-write-exception = true
|
Loading…
Reference in a new issue