diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..191f05a4 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..3089d259 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 00000000..24392c9c --- /dev/null +++ b/uwsgi.ini @@ -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