Verified Commit f7ad9482 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Merge branch 'release/0.3'

parents 9395fc80 701d018f
Loading
Loading
Loading
Loading

.gitlab-ci.yml

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
unittest:
  image: python:3.7
  stage: test
  before_script:
  - pip install .
  script:
  - ./manage.py test

triggers:
  image: pstauffer/curl:latest
  stage: deploy
  only:
  - master@kodo.org.uk/kodo-sso
  script:
  - >
    curl --request POST
    --form token=${TRIGGER_PROJECT_TOKEN}
    --form ref=master
    --form variables[KSSO_VERSION]=$CI_COMMIT_SHA
    https://code.kodo.org.uk/api/v4/projects/${TRIGGER_PROJECT_ID}/trigger/pipeline

Dockerfile

0 → 100644
+80 −0
Original line number Diff line number Diff line
# syntax = docker/dockerfile:1.3-labs

### BUILD
# FROM quay.io/pypa/manylinux2014_x86_64 as build

## Install dependencies
# RUN yum install -y \
#     mariadb-devel \
#     wget

FROM python:3.9-slim as build
RUN apt update && apt install -y libmariadb-dev build-essential

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=util,target=/src/util \
    --mount=type=bind,source=setup.py,target=/src/setup.py \
    pip install --prefer-binary /src gunicorn mysqlclient whitenoise
RUN <<END_SCRIPT
set -eu
bootstrap-stage
find /usr/local/lib/python3.9/lib-dynload \
    -name '_tkinter.*' -prune \
    -o -type f -print0 |
xargs -0 collect-binaries \
    /bin/sh \
    /usr/local/bin/python3.9 \
    /usr/local/lib/libpython3.9.so* \
    /usr/lib/*/libmariadbclient.so
ln -s python3.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.9 
{
    find /usr/local/lib/python3.9/ \
        -mindepth 1 -maxdepth 1 \
        \( \
            -name site-packages \
            -o -name lib-dynload \
            -o -name 'config-*' \
        \) -prune -o -print
    find /usr/local/lib/python3.9/site-packages \
        -mindepth 1 -maxdepth 1 \
        \( \
            -name 'README.txt' \
            -o -name '*distutils*' \
            -o -name 'pip*' \
            -o -name 'setuptools*' \
            -o -name 'wheel*' \
        \) -prune -o -print
} | while read fname; do
    cp -r "$fname" /stage/usr/local/lib/python3.9/
done
END_SCRIPT


### INSTALL
# FROM python:3.7-slim as final
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"]

docker/entrypoint.sh

0 → 100755
+20 −0
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
+25 −0
Original line number Diff line number Diff line
import os
import random

## Django configs

from kodo_sso.settings.production import *

ALLOWED_HOSTS = ['*']
WHITENOISE_MAX_AGE = 365 * 24 * 3600
SECRET_KEY = bytes(random.randrange(32, 127) for _ in range(20)).decode()
MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware',) + MIDDLEWARE


## Gunicorn configs

# kodo_sso.wsgi MUST be loaded after Django settings
from kodo_sso.wsgi import application

bind = ['0.0.0.0:80']
preload_app = True
proxy_allow_ips = '*'
accesslog = "-"

# import aiohttp.worker
# worker_class = aiohttp.worker.GunicornWebWorker
+1 −1
Original line number Diff line number Diff line
__version_info__ = 0,3
__version_info__ = 0,3,1
__version__ = '.'.join(str(v) for v in __version_info__)
Loading