Verified Commit 776964f2 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Reduce into a package containing password hashers

parent 04b6bb8b
Loading
Loading
Loading
Loading
+5 −17
Original line number Diff line number Diff line
# Python generated content
*.py[cod]
# Python cached objects
*.pyc

# CSS (generated by LESS)
**/static/css/*.css

# Development database & config
*.db
*.conf

# Upload directory
media/

# Setuptools generated
build/
dist/
setuptools-*
*.egg-info
# Packages
*.whl
*.tar.*

Dockerfile

deleted100644 → 0
+0 −70
Original line number Diff line number Diff line
FROM python:3.12-slim as build
RUN apt update && apt install -y libmariadb-dev build-essential pkg-config

COPY --from=docker.kodo.org.uk/kodo.org.uk/docker/docker-build-helpers:latest \
    /scripts /bin

## Build python wheels
WORKDIR /pkg
RUN --mount=type=bind,source=kodo_sso,target=/src/kodo_sso \
    --mount=type=bind,source=pyproject.toml,target=/src/pyproject.toml \
    pip install --prefer-binary /src gunicorn mysqlclient whitenoise
RUN <<END_SCRIPT
set -eu
bootstrap-stage
find /usr/local/lib/python3.* \
    -name '_tkinter.*' -prune \
    -o -name '*.so' -type f \
    -print0 |
xargs -0 collect-binaries \
    /bin/sh \
    /usr/local/bin/python3.* \
    /usr/local/lib/libpython3.*.so* \
    /usr/lib/*/libmariadbclient.so
ln -s /usr/local/bin/python3.*[0-9] /stage/usr/local/bin/python
cp /usr/local/bin/kodo-sso /usr/local/bin/gunicorn /stage/bin/
mkdir -p /stage/usr/local/lib/python3.* 
{
    find /usr/local/lib/python3.*/ \
        -mindepth 1 -maxdepth 1 \
        \( \
            -name site-packages \
            -o -name lib-dynload \
            -o -name 'config-*' \
        \) -prune -o -print
    find /usr/local/lib/python3.*/site-packages \
        -mindepth 1 -maxdepth 1 \
        \( \
            -name 'README.txt' \
            -o -name '*distutils*' \
            -o -name 'pip*' \
            -o -name 'setuptools*' \
            -o -name 'wheel*' \
            -o -name '*.so' \
        \) -prune -o -print
} | while read fname; do
    cp -r "$fname" /stage/usr/local/lib/python3.*/
done
END_SCRIPT


### INSTALL
FROM scratch as final

LABEL uk.org.kodo.maintainer = "Dom Sekotill <dom.sekotill@kodo.org.uk>"
LABEL maintainer = "Dom Sekotill <dom.sekotill@kodo.org.uk>"

COPY --from=build /stage/ /

WORKDIR /app
COPY docker/gunicorn_conf.py /app/gunicorn_conf.py
ENV LD_LIBRARY_PATH=/lib:/usr/local/lib
ENV PYTHONPATH=/app
ENV STATIC_ROOT=/app/static
ENV DJANGO_SETTINGS_MODULE=gunicorn_conf

RUN kodo-sso collectstatic --noinput

COPY docker/entrypoint.sh /bin/entrypoint
ENTRYPOINT ["/bin/entrypoint"]
CMD ["run"]
+0 −0

File moved.

docker/entrypoint.sh

deleted100755 → 0
+0 −20
Original line number Diff line number Diff line
#!/bin/sh
set -eu

command_run() {
	while [ $# -gt 0 ]; do
		case "$1" in
			*) echo >&2 "Unknown argument: $1"; exit 2 ;;
		esac
		shift
	done
	kodo-sso migrate --fake-initial
	exec gunicorn --config python:gunicorn_conf gunicorn_conf
}

command="${1}"; shift
case "${command}" in
	run) command_run "$@" ;;
	createsuperuser|collectstatic) exec kodo-sso "${command}" "$@" ;;
	*) exec "${command}" "$@" ;;
esac
Loading