kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
106 wiersze
3.0 KiB
Docker
106 wiersze
3.0 KiB
Docker
FROM alpine:3.17 as pre-build
|
|
|
|
# We need this additional step to avoid having poetrys deps interacting with our
|
|
# dependencies. This is only required until alpine 3.16 is released, since this
|
|
# allows us to install poetry as package.
|
|
|
|
RUN apk add --no-cache python3 py3-cryptography py3-pip poetry
|
|
COPY pyproject.toml poetry.lock /
|
|
RUN poetry export --without-hashes > requirements.txt
|
|
RUN poetry export --with dev --without-hashes > dev-requirements.txt
|
|
|
|
|
|
FROM alpine:3.17 as builder
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
RUN \
|
|
echo 'installing dependencies' && \
|
|
apk add --no-cache \
|
|
git \
|
|
musl-dev \
|
|
gcc \
|
|
postgresql-dev \
|
|
python3-dev \
|
|
py3-psycopg2=2.9.5-r0 \
|
|
py3-cryptography=38.0.3-r0 \
|
|
py3-lxml=4.9.2-r0 \
|
|
py3-pillow=9.3.0-r0 \
|
|
py3-watchfiles=0.18.1-r0 \
|
|
libldap \
|
|
libffi-dev \
|
|
make \
|
|
zlib-dev \
|
|
jpeg-dev \
|
|
openldap-dev \
|
|
openssl-dev \
|
|
cargo \
|
|
libxml2-dev \
|
|
libxslt-dev \
|
|
curl
|
|
|
|
# create virtual env for next stage
|
|
RUN python -m venv --system-site-packages /venv
|
|
# emulate activation by prefixing PATH
|
|
ENV PATH="/venv/bin:/root/.local/bin:$PATH" VIRTUAL_ENV=/venv
|
|
|
|
COPY --from=pre-build /requirements.txt /requirements.txt
|
|
COPY --from=pre-build /dev-requirements.txt /dev-requirements.txt
|
|
# hack around https://github.com/pypa/pip/issues/6158#issuecomment-456619072
|
|
ARG PIP_DOWNLOAD_CACHE=/noop/
|
|
RUN \
|
|
echo 'installing pip requirements' && \
|
|
pip3 install --upgrade pip && \
|
|
pip3 install setuptools wheel && \
|
|
# Currently we are unable to relieably build rust-based packages on armv7. This
|
|
# is why we need to use the packages shipped by Alpine Linux.
|
|
# Since poetry does not allow in-place dependency pinning, we need
|
|
# to install the deps using pip.
|
|
grep -Ev 'cryptography|watchfiles|lxml|pillow|psycopg2' /requirements.txt | pip3 install -r /dev/stdin cryptography==38.0.3 watchfiles==0.18.1 lxml==4.9.2 pillow==9.3.0 psycopg2==2.9.5 && \
|
|
rm -rf "$PIP_DOWNLOAD_CACHE"
|
|
|
|
ARG install_dev_deps=0
|
|
RUN \
|
|
if [ "$install_dev_deps" = "1" ] ; then \
|
|
echo "Installing dev dependencies" && \
|
|
grep -Ev 'cryptography|watchfiles|lxml|pillow|psycopg2' /dev-requirements.txt | pip3 install -r /dev/stdin cryptography==38.0.3 watchfiles==0.18.1 lxml==4.9.2 pillow==9.3.0 psycopg2==2.9.5 && \
|
|
rm -rf "$PIP_DOWNLOAD_CACHE" \
|
|
; else \
|
|
echo "Skipping dev deps installation" \
|
|
; fi
|
|
|
|
|
|
FROM alpine:3.17 as image
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
COPY --from=builder /venv /venv
|
|
# emulate activation by prefixing PATH
|
|
ENV PATH="/venv/bin:$PATH"
|
|
|
|
RUN apk add --no-cache \
|
|
libmagic \
|
|
bash \
|
|
gettext \
|
|
python3 \
|
|
jpeg-dev \
|
|
ffmpeg \
|
|
libpq \
|
|
libxml2 \
|
|
libxslt \
|
|
py3-psycopg2=2.9.5-r0 \
|
|
py3-cryptography=38.0.3-r0 \
|
|
py3-lxml=4.9.2-r0 \
|
|
py3-pillow=9.3.0-r0 \
|
|
py3-watchfiles=0.18.1-r0 \
|
|
libldap
|
|
|
|
COPY . /app
|
|
WORKDIR /app
|
|
|
|
ENV CACHE_URL="redis://redis:6379/0"
|
|
ENV CELERY_BROKER_URL="redis://redis:6379/0"
|
|
|
|
ENTRYPOINT ["./compose/django/entrypoint.sh"]
|
|
CMD ["./compose/django/server.sh"]
|