|
| 1 | +# syntax=docker/dockerfile:1.7 |
| 2 | + |
| 3 | +FROM --platform=$TARGETPLATFORM golang:alpine3.21@sha256:b4dbd292a0852331c89dfd64e84d16811f3e3aae4c73c13d026c4d200715aff6 AS build |
| 4 | + |
| 5 | +ARG ENV_PROTONMAIL_BRIDGE_VERSION |
| 6 | +ARG TARGETPLATFORM |
| 7 | + |
| 8 | +# Install dependencies |
| 9 | +RUN set -eux; \ |
| 10 | + apk add --no-cache \ |
| 11 | + bash=5.2.37-r0 \ |
| 12 | + g++=14.2.0-r4 \ |
| 13 | + git=2.47.3-r0 \ |
| 14 | + grep=3.11-r0 \ |
| 15 | + libsecret-dev=0.21.7-r0 \ |
| 16 | + make=4.4.1-r2 \ |
| 17 | + sed=4.9-r2 |
| 18 | + |
| 19 | +WORKDIR /build/ |
| 20 | +RUN set -eux; \ |
| 21 | + : "${ENV_PROTONMAIL_BRIDGE_VERSION:?build arg ENV_PROTONMAIL_BRIDGE_VERSION is required}"; \ |
| 22 | + git clone --depth 1 --single-branch --branch "$ENV_PROTONMAIL_BRIDGE_VERSION" https://github.com/ProtonMail/proton-bridge.git; \ |
| 23 | + printf '%s\n' "$ENV_PROTONMAIL_BRIDGE_VERSION" > /build/BRIDGE_VERSION |
| 24 | +WORKDIR /build/proton-bridge/ |
| 25 | +RUN --mount=type=cache,target=/go/pkg/mod \ |
| 26 | + --mount=type=cache,target=/root/.cache/go-build \ |
| 27 | + set -eux; \ |
| 28 | + make build-nogui vault-editor |
| 29 | + |
| 30 | +# Working stage image |
| 31 | +FROM --platform=$TARGETPLATFORM alpine:3.21@sha256:c3f8e73fdb79deaebaa2037150150191b9dcbfba68b4a46d70103204c53f4709 |
| 32 | + |
| 33 | +# Define arguments and env variables |
| 34 | +ARG TARGETPLATFORM |
| 35 | +# Indicate (NOT define) the ports/network interface really used by Proton bridge mail. |
| 36 | +# It should be 1025/tcp and 1143/tcp but on some k3s instances it could be 1026 and 1144 (why ?) |
| 37 | +# Launch `netstat -ltnp` on a running container to be sure. |
| 38 | +ARG ENV_BRIDGE_SMTP_PORT=1025 |
| 39 | +ARG ENV_BRIDGE_IMAP_PORT=1143 |
| 40 | +ARG ENV_BRIDGE_HOST=127.0.0.1 |
| 41 | +# Change ENV_CONTAINER_SMTP_PORT only if you have a docker port conflict on host network namespace. |
| 42 | +ARG ENV_CONTAINER_SMTP_PORT=1026 |
| 43 | +ARG ENV_CONTAINER_IMAP_PORT=1144 |
| 44 | +ENV PROTON_BRIDGE_SMTP_PORT=$ENV_BRIDGE_SMTP_PORT \ |
| 45 | + PROTON_BRIDGE_IMAP_PORT=$ENV_BRIDGE_IMAP_PORT \ |
| 46 | + PROTON_BRIDGE_HOST=$ENV_BRIDGE_HOST \ |
| 47 | + CONTAINER_SMTP_PORT=$ENV_CONTAINER_SMTP_PORT \ |
| 48 | + CONTAINER_IMAP_PORT=$ENV_CONTAINER_IMAP_PORT \ |
| 49 | + ENV_TARGET_PLATFORM=$TARGETPLATFORM |
| 50 | +LABEL org.opencontainers.image.source="https://github.com/ProtonMail/proton-bridge" \ |
| 51 | + org.opencontainers.image.version="$ENV_PROTONMAIL_BRIDGE_VERSION" \ |
| 52 | + org.opencontainers.image.title="proton-bridge" \ |
| 53 | + org.opencontainers.image.description="Headless Proton Mail Bridge with CLI tooling" |
| 54 | + |
| 55 | +# Install dependencies |
| 56 | +RUN set -eux; \ |
| 57 | + apk add --no-cache \ |
| 58 | + bash=5.2.37-r0 \ |
| 59 | + ca-certificates=20250911-r0 \ |
| 60 | + gpg=2.4.9-r0 \ |
| 61 | + gpg-agent=2.4.9-r0 \ |
| 62 | + gnupg-keyboxd=2.4.9-r0 \ |
| 63 | + libsecret=0.21.7-r0 \ |
| 64 | + net-tools=2.10-r3 \ |
| 65 | + pass=1.7.4-r3 \ |
| 66 | + socat=1.8.0.3-r0 |
| 67 | + |
| 68 | +RUN set -eux; \ |
| 69 | + addgroup -S bridge; \ |
| 70 | + adduser -S -G bridge -h /home/bridge bridge; \ |
| 71 | + mkdir -p /home/bridge /app; \ |
| 72 | + chown -R bridge:bridge /home/bridge /app |
| 73 | + |
| 74 | +# RUN rc-update add dbus |
| 75 | +# RUN touch /run/openrc/softlevel |
| 76 | +# RUN rc-service dbus start |
| 77 | + |
| 78 | +# Copy executables made during previous stage |
| 79 | +WORKDIR /usr/bin/ |
| 80 | +COPY --from=build /build/proton-bridge/bridge /build/proton-bridge/proton-bridge /build/proton-bridge/vault-editor /usr/bin/ |
| 81 | + |
| 82 | +# Install needed scripts and files |
| 83 | +WORKDIR /app/ |
| 84 | +COPY --chmod=0755 entrypoint.sh /app/entrypoint.sh |
| 85 | +COPY GPGparams.txt /app/GPGparams.txt |
| 86 | +COPY --from=build /build/BRIDGE_VERSION /app/VERSION |
| 87 | + |
| 88 | +# SMTP and IMAP ports are not exposed by default, so you could adjust them if necessary with ENV |
| 89 | +# variables CONTAINER_SMTP_PORT and CONTAINER_IMAP_PORT. |
| 90 | +# See README.md and/or compose.yaml file. |
| 91 | +# EXPOSE ${ENV_CONTAINER_SMTP_PORT}/tcp |
| 92 | +# EXPOSE ${ENV_CONTAINER_IMAP_PORT}/tcp |
| 93 | + |
| 94 | +# Volume to save pass and bridge configurations/data |
| 95 | +VOLUME /home/bridge |
| 96 | + |
| 97 | +USER bridge:bridge |
| 98 | +ENTRYPOINT ["/app/entrypoint.sh"] |
0 commit comments