-
-
Notifications
You must be signed in to change notification settings - Fork 794
/
Dockerfile
67 lines (51 loc) · 2.15 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# syntax=docker/dockerfile:1.6.0
# this Dockerfile is located at the root so the build context
# includes oauth2_provider which is a requirement of the
# tests/app/idp. This way we build images with the source
# code from the repos for validation before publishing packages.
FROM python:3.11.6-slim as builder
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DEBUG=False
ENV ALLOWED_HOSTS="*"
ENV TEMPLATES_DIRS="/data/templates"
ENV STATIC_ROOT="/data/static"
ENV DATABASE_URL="sqlite:////data/db.sqlite3"
RUN apt-get update
# Build Deps
RUN apt-get install -y --no-install-recommends gcc libc-dev python3-dev git openssh-client libpq-dev file libev-dev
# bundle code in a virtual env to make copying to the final image without all the upstream stuff easier.
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# need to update pip and setuptools for pep517 support required by gevent.
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
COPY . /code
WORKDIR /code/tests/app/idp
RUN pip install -r requirements.txt
RUN pip install gunicorn
RUN python manage.py collectstatic --noinput
FROM python:3.11.6-slim
# allow embed sha1 at build time as release.
ARG GIT_SHA1
LABEL org.opencontainers.image.authors="https://jazzband.co/projects/django-oauth-toolkit"
LABEL org.opencontainers.image.source="https://github.com/jazzband/django-oauth-toolkit"
LABEL org.opencontainers.image.revision=${GIT_SHA1}
ENV SENTRY_RELEASE=${GIT_SHA1}
# disable debug mode, but allow all hosts by default when running in docker
ENV DEBUG=False
ENV ALLOWED_HOSTS="*"
ENV TEMPLATES_DIRS="/data/templates"
ENV STATIC_ROOT="/data/static"
ENV DATABASE_URL="sqlite:////data/db.sqlite3"
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=builder /code /code
RUN mkdir -p /code/tests/app/idp/static /code/tests/app/idp/templates
WORKDIR /code/tests/app/idp
RUN apt-get update && apt-get install -y \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 80
VOLUME ["/data" ]
CMD ["gunicorn", "idp.wsgi:application", "-w 4 -b 0.0.0.0:80 --chdir=/code --worker-tmp-dir /dev/shm --timeout 120 --error-logfile '-' --log-level debug --access-logfile '-'"]