-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathDockerfile
77 lines (61 loc) · 2.77 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
68
69
70
71
72
73
74
75
76
77
# syntax=docker/dockerfile:1
ARG WIRECLOUD_PYTHON_VERSION=3.10
ARG WIRECLOUD_DEBIAN_VERSION=bookworm
#$BUILDPLATFORM allows to build the image on the native platform of the builder, avoiding emulation
FROM --platform=$BUILDPLATFORM python:${WIRECLOUD_PYTHON_VERSION}-${WIRECLOUD_DEBIAN_VERSION} AS builder
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update && \
apt-get install -y --no-install-recommends gettext npm
COPY src /wirecloud/src
#README.md is needed to build the wheel
COPY README.md /wirecloud/
# Build WireCloud wheel
WORKDIR /wirecloud/src
#Build needs npm to build monaco editor
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
--mount=type=cache,target=node_modules/.cache,sharing=locked \
python3 setup.py bdist_wheel
FROM python:${WIRECLOUD_PYTHON_VERSION}-slim-${WIRECLOUD_DEBIAN_VERSION}
ARG WIRECLOUD_PYTHON_VERSION
ENV FORWARDED_ALLOW_IPS=* \
DB_PORT=5432 \
LOGLEVEL=info \
LOGFORMAT=plain \
WORKERS=2 \
THREADS=8 \
#PIP_NO_CACHE_DIR=off \
DJANGO_SETTINGS_MODULE=wirecloud_instance.settings
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update && \
apt-get install -y --no-install-recommends libpq-dev libmemcached-dev libpcre3-dev gosu ca-certificates curl gcc && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install WireCloud & dependencies
# Mount the wheel file from the builder stage
RUN --mount=type=bind,from=builder,source=/wirecloud/src/dist/,target=/dist/ \
--mount=type=cache,target=/root/.cache/pip,sharing=locked \
pip install /dist/*.whl \
social-auth-app-django "gunicorn==21.2" "psycopg2==2.8.6" pylibmc pysolr "elasticsearch==2.4.1" \
"regex==2019.02.18" "channels<2.3" "channels-redis" "wirecloud-keycloak>=0.3.0" "whitenoise" && \
pip uninstall selenium -y
RUN adduser --system --group --shell /bin/bash wirecloud && \
mkdir -p /opt/wirecloud_instance /var/www/static
COPY docker-platform/docker-entrypoint.sh /
COPY docker-platform/manage.py /usr/local/bin/
WORKDIR /opt
RUN wirecloud-admin startproject wirecloud_instance wirecloud_instance && \
chown -R wirecloud:wirecloud wirecloud_instance /var/www/static && \
chmod a+x wirecloud_instance/manage.py && \
chmod a+x /docker-entrypoint.sh
COPY docker-platform/settings.py docker-platform/urls.py /opt/wirecloud_instance/wirecloud_instance/
COPY docker-platform/glogger.py /usr/local/lib/python${WIRECLOUD_PYTHON_VERSION}/site-packages/wirecloud/
WORKDIR /opt/wirecloud_instance
VOLUME /var/www/static
VOLUME /opt/wirecloud_instance/data
EXPOSE 8000
HEALTHCHECK --interval=5s \
--start-period=120s \
CMD curl --fail http://localhost:8000/api/features || exit 1
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["gunicorn"]