2022-09-27 22:08:37 +02:00
|
|
|
# syntax=docker/dockerfile-upstream:1.4.3
|
|
|
|
|
2022-10-08 15:55:40 +02:00
|
|
|
# base system image (intermediate)
|
2022-10-29 11:40:14 +02:00
|
|
|
ARG DISTRO=alpine:3.16.2
|
2022-10-08 15:55:40 +02:00
|
|
|
FROM $DISTRO as system
|
2022-09-27 22:08:37 +02:00
|
|
|
|
2022-10-14 14:34:27 +02:00
|
|
|
ENV TZ=Etc/UTC LANG=C.UTF-8
|
|
|
|
|
|
|
|
ARG MAILU_UID=1000
|
|
|
|
ARG MAILU_GID=1000
|
2022-09-27 22:08:37 +02:00
|
|
|
|
|
|
|
RUN set -euxo pipefail \
|
2022-10-14 14:34:27 +02:00
|
|
|
; addgroup -Sg ${MAILU_GID} mailu \
|
|
|
|
; adduser -Sg ${MAILU_UID} -G mailu -h /app -g "mailu app" -s /bin/bash mailu \
|
2022-10-14 14:34:58 +02:00
|
|
|
; apk add --no-cache bash ca-certificates curl python3 tzdata
|
2022-09-27 22:08:37 +02:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
2022-10-08 15:55:40 +02:00
|
|
|
CMD /bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
# build virtual env (intermediate)
|
|
|
|
FROM system as build
|
|
|
|
|
2022-11-01 12:02:21 +02:00
|
|
|
ARG MAILU_DEPS=prod
|
2022-10-14 16:17:46 +02:00
|
|
|
|
2022-10-08 15:55:40 +02:00
|
|
|
ENV VIRTUAL_ENV=/app/venv
|
|
|
|
|
2022-10-14 16:17:46 +02:00
|
|
|
COPY requirements-build.txt ./
|
2022-10-14 14:34:27 +02:00
|
|
|
|
2022-10-08 15:55:40 +02:00
|
|
|
RUN set -euxo pipefail \
|
|
|
|
; apk add --no-cache py3-pip \
|
|
|
|
; python3 -m venv ${VIRTUAL_ENV} \
|
2022-10-14 16:17:46 +02:00
|
|
|
; ${VIRTUAL_ENV}/bin/pip install --no-cache-dir -r requirements-build.txt \
|
2022-11-01 00:40:51 +02:00
|
|
|
; apk del -r py3-pip \
|
|
|
|
; rm -f /tmp/*.pem
|
2022-10-08 15:55:40 +02:00
|
|
|
|
|
|
|
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
|
|
|
|
2022-11-01 12:02:21 +02:00
|
|
|
COPY requirements-${MAILU_DEPS}.txt ./
|
2022-10-08 15:55:40 +02:00
|
|
|
COPY libs/ libs/
|
2022-09-27 22:08:37 +02:00
|
|
|
|
|
|
|
RUN set -euxo pipefail \
|
2022-11-01 12:02:21 +02:00
|
|
|
; pip install -r requirements-${MAILU_DEPS}.txt || \
|
|
|
|
{ \
|
|
|
|
machine="$(uname -m)" \
|
|
|
|
; deps="build-base gcc libffi-dev python3-dev" \
|
2022-11-01 14:47:21 +02:00
|
|
|
; [[ "${machine}" != x86_64 ]] && \
|
2022-11-01 12:02:21 +02:00
|
|
|
deps="${deps} cargo git libressl-dev mariadb-connector-c-dev postgresql-dev" \
|
|
|
|
; apk add --virtual .build-deps ${deps} \
|
|
|
|
; [[ "${machine}" == armv7 ]] && \
|
|
|
|
mkdir -p /root/.cargo/registry/index && \
|
|
|
|
git clone --bare https://github.com/rust-lang/crates.io-index.git /root/.cargo/registry/index/github.com-1285ae84e5963aae \
|
|
|
|
; pip install -r requirements-${MAILU_DEPS}.txt \
|
|
|
|
; apk del -r .build-deps \
|
|
|
|
; rm -rf /root/.cargo /tmp/*.pem \
|
|
|
|
; } \
|
|
|
|
; rm -rf /root/.cache
|
2022-10-08 15:55:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
# base mailu image
|
|
|
|
FROM system
|
|
|
|
|
|
|
|
COPY --from=build /app/venv/ /app/venv/
|
|
|
|
|
|
|
|
ENV VIRTUAL_ENV=/app/venv
|
|
|
|
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|