From 9d5ead578d94f29299d8f938f98f98631a66ac27 Mon Sep 17 00:00:00 2001 From: Michael Gibson Date: Mon, 8 Mar 2021 10:18:56 -0600 Subject: [PATCH 1/2] Updated Dockerfile to add bash. --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 90244d7..d1d4476 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ # Build the ProtonMail Bridge. -FROM golang:1.15-alpine as build +FROM golang:1.16-alpine as build ENV LANG C.UTF-8 RUN apk add --no-cache \ + bash \ curl \ gcc \ git \ From 6db0b9271c3da5a7560f013314b1c984b1e5bed9 Mon Sep 17 00:00:00 2001 From: Michael Gibson Date: Thu, 2 Feb 2023 07:48:00 -0600 Subject: [PATCH 2/2] Update for bridge 3.0.x. --- Dockerfile | 47 ++++++++++++++++++++++++++++------------------- entrypoint | 7 +++---- initproton | 13 +++++++++++-- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1d4476..50d0f0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,27 @@ # Build the ProtonMail Bridge. -FROM golang:1.16-alpine as build +FROM golang:1.18-buster as build ENV LANG C.UTF-8 -RUN apk add --no-cache \ - bash \ - curl \ - gcc \ - git \ - libsecret-dev \ - make \ - musl-dev -WORKDIR /usr/src +# Install required build packages +RUN apt-get update \ + && apt-get install -y \ + bash \ + build-essential \ + curl \ + git \ + libsecret-1-dev \ + musl-dev + +# Download/build the application +WORKDIR /usr/src ARG RELEASE ARG TAG RUN if [ -n "$RELEASE" ]; then \ echo "Using release $RELEASE..." \ && curl -L -s "https://github.com/ProtonMail/proton-bridge/archive/$RELEASE.tar.gz" | tar zx \ - && ln -s "proton-bridge-$RELEASE" proton-bridge \ - && cd proton-bridge \ + && export PROTON_BRIDGE="proton-bridge-$(echo $RELEASE | sed -e 's/^\(v\|br\)//')" \ + && ln -s "${PROTON_BRIDGE}" proton-bridge \ + && cd "${PROTON_BRIDGE}" \ ; else \ git clone https://github.com/ProtonMail/proton-bridge.git proton-bridge \ && cd proton-bridge \ @@ -26,21 +30,26 @@ RUN if [ -n "$RELEASE" ]; then \ && make build-nogui # Create a container for the ProtonMail Bridge. -FROM alpine:edge +FROM debian:stable ENV LANG C.UTF-8 EXPOSE 25/tcp EXPOSE 143/tcp COPY --from=build /usr/src/proton-bridge/proton-bridge /bin/proton-bridge +COPY --from=build /usr/src/proton-bridge/bridge /bin/bridge COPY entrypoint /bin/ COPY initproton /bin/ -RUN apk add --no-cache \ - libsecret \ - pass \ - socat \ - su-exec \ - && chmod +x /bin/entrypoint \ +RUN apt-get update\ + && apt-get install -y --no-install-recommends --no-install-suggests\ + libcap2\ + libsecret-1-0\ + gosu\ + gpg-agent\ + pass\ + socat\ + && rm -rf /var/lib/apt/lists/*\ + && chmod +x /bin/entrypoint\ && chmod +x /bin/initproton WORKDIR /var/lib/proton diff --git a/entrypoint b/entrypoint index 3390d06..884d393 100755 --- a/entrypoint +++ b/entrypoint @@ -9,13 +9,11 @@ GROUP=proton if getent group $GROUP_ID > /dev/null; then echo "Using group $GROUP with GID $GROUP_ID..." GROUP=$(getent group $GROUP_ID | cut -d: -f1) - echo "Using group $GROUP with GID $GROUP_ID..." else echo "Adding group $GROUP with GID $GROUP_ID..." addgroup -g $GROUP_ID $GROUP fi -echo "Adding user proton with group $GROUP..." -echo adduser -D -u $USER_ID -G $GROUP -h /var/lib/proton -s /bin/sh proton +echo "Adding user proton ($USER_ID) with group $GROUP ${GROUP_ID}..." adduser -D -u $USER_ID -G $GROUP -h /var/lib/proton -s /bin/sh proton chown -R ${USER_ID}:${GROUP_ID} /var/lib/proton export HOME=/var/lib/proton @@ -27,4 +25,5 @@ setcap 'cap_net_bind_service=+ep' /usr/bin/socat socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 & socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 & -exec /sbin/su-exec proton "$@" +echo "Starting ProtonMail Bridge..." +exec /usr/sbin/gosu proton "$@" diff --git a/initproton b/initproton index aa1f305..703ebe6 100755 --- a/initproton +++ b/initproton @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/bash set -eufo pipefail -BRIDGE=/bin/proton-bridge +BRIDGE=/bin/bridge FIFO=/tmp/fifo PRINT_INFO=${PRINT_INFO:-""} @@ -11,14 +11,20 @@ if [ -n "$PASS_FILE" ]; then PASS=$(cat $PASS_FILE) fi +echo "Checking for GPG configuration..." if ! [ -d .gnupg ]; then + echo "Generating GPG Key..." echo -e "%no-protection\nKey-Type: RSA\nKey-Length: 4096\nName-Real: $EMAIL\nExpire-Date: 0\n%commit" \ | gpg --generate-key --batch fi +echo "Checking for Password Store..." if ! [ -d .password-store ]; then + echo "Initializing Pass..." pass init "$EMAIL" fi +echo "Checking for ProtonMail Bridge Cache..." if ! [ -d ~/.cache/protonmail/bridge ]; then + echo "Logging in to ProtonMail Bridge..." COMMAND="login\n$EMAIL\n$PASSWORD" MFA_CODE=${MFA_CODE:-} if [ -n "$MFA_CODE" ]; then @@ -28,6 +34,7 @@ if ! [ -d ~/.cache/protonmail/bridge ]; then fi if [ -n "$PRINT_INFO" ]; then + echo "Printing Info..." echo info | $BRIDGE --cli | egrep '(Username|Password)' | sort -ru fi @@ -37,4 +44,6 @@ if [ -n "$LOG_LEVEL" ]; then ARGUMENTS="${ARGUMENTS} --log-level ${LOG_LEVEL}" fi +echo "Starting ProtonMail Bridge: $BRIDGE $ARGUMENTS" +$BRIDGE --version $BRIDGE $ARGUMENTS