47 Commits
next ... dev

Author SHA1 Message Date
Xiaonan Shen
5c7c5c50c6 temp x 2023-02-24 23:23:56 +08:00
Xiaonan Shen
bea37a8aa9 Multi arch build 2023-01-14 17:11:58 +08:00
Xiaonan Shen
5284ee3425 Build locally 2023-01-14 16:55:13 +08:00
Daniel Nathan Gray
89b3ef69f4 Rebase on Jammy (#71)
If you're going to build v3 you need to have Jammy, or you will get
glibc errors
2023-01-14 14:56:03 +08:00
GitHub Actions
04a2fae963 Bump build version to 3.0.9 2022-12-21 00:12:33 +00:00
GitHub Actions
bd9addf4f4 Bump build version to 3.0.7 2022-12-17 00:12:20 +00:00
GitHub Actions
c3140a3fa0 Bump build version to 3.0.6 2022-12-08 00:13:17 +00:00
GitHub Actions
51015361c5 Bump build version to 3.0.5 2022-12-06 00:12:45 +00:00
GitHub Actions
0e92386a93 Bump build version to 3.0.4 2022-12-03 00:12:21 +00:00
GitHub Actions
2e3bcdef1f Bump build version to 3.0.2 2022-11-30 00:15:14 +00:00
GitHub Actions
cf1e025209 Bump deb version to 2.3.0-1 2022-11-26 00:13:33 +00:00
GitHub Actions
4dbf2f806e Bump deb version to 2.4.8-1 2022-11-23 00:14:33 +00:00
Xiaonan Shen
712de23988 Add riscv64 support to CI docker builds (#54) 2022-11-21 00:14:03 +08:00
Olof Nord
0541f29d98 Add riscv64 support to docker builds
* Adjust GitHub CI to also build for riscv64
* Update base Ubuntu base for build from 18.04 LTS to 20.04 LTS as to support riscv64
* Minor: Exclude idea IDE files from git
2022-11-20 23:32:58 +08:00
Xiaonan Shen
252397a86d Switch to carlosedp/golang for riscv64 support 2022-11-20 23:12:46 +08:00
GitHub Actions
6a2a413d0a Bump build version to 2.4.8 2022-11-17 00:15:47 +00:00
GitHub Actions
60c8a9ecc4 Bump build version to 2.4.5 2022-11-09 00:16:36 +00:00
Xiaonan Shen
535c80379d Copy bridge executable to the image (fixes #66) 2022-11-05 14:30:33 +08:00
GitHub Actions
acefed1b95 Bump build version to 2.4.3 2022-10-26 00:16:54 +00:00
Xiaonan Shen
6decf657c2 Bump golang to 1.18 2022-10-16 15:04:58 +08:00
Xiaonan Shen
0fa5f9fc13 Fix entrypoint init fail issue 2022-10-16 14:49:38 +08:00
Xiaonan Shen
e0b0ce653c Add .vscode to .gitignore 2022-10-16 14:47:32 +08:00
GitHub Actions
fa4ddf7126 Bump build version to 2.4.0 2022-09-29 00:23:38 +00:00
GitHub Actions
07d3779fc6 Bump deb version to 2.3.0-1 2022-09-09 00:17:44 +00:00
GitHub Actions
2e9d95d90b Bump build version to 2.3.0 2022-09-02 00:15:28 +00:00
GitHub Actions
a8f5c0a096 Bump build version to 2.2.2 2022-07-28 00:15:49 +00:00
GitHub Actions
14cac1052d Bump deb version to 2.2.2-1 2022-07-28 00:15:47 +00:00
GitHub Actions
92b0c5bd5f Bump build version to 2.2.1 2022-07-22 00:16:20 +00:00
Xiaonan Shen
812646acb9 Fix entrypoint so it works correctly on init #57 2022-05-28 12:40:24 +08:00
GitHub Actions
664b5e924d Bump build version to 2.2.0 2022-05-26 00:14:14 +00:00
Nilesh
680e82076e Fix entrypoint so it works correctly on init
Ran into this issue when trying to use in kubernetes via k8s-at-home/protonmail-bridge. Took a bit of figuring out before I realized I had to manually kill the other instance. The only output from the failed load is a dbus issue, and an immediate exit.
2022-05-12 11:31:03 -07:00
GitHub Actions
86e10823e0 Bump deb version to 2.1.3-1 2022-04-28 00:15:49 +00:00
GitHub Actions
22b04d941d Bump build version to 2.1.3 2022-04-12 00:12:24 +00:00
GitHub Actions
4e11382bdb Bump build version to 2.1.2 2022-03-31 00:11:19 +00:00
Rafael Blumberg
ba5d5297dc Add linux/arm/v7 to automate builds
After working around 32bits issues, this PR automate arm/v7 builds
2022-02-26 11:30:47 +08:00
GitHub Actions
758406337f Bump build version to 2.1.1 2022-02-10 00:08:25 +00:00
GitHub Actions
db7f0eb889 Bump deb version to 2.1.1-1 2022-02-10 00:08:25 +00:00
GitHub Actions
d73f3f4a63 Bump deb version to 2.1.0-1 2022-02-04 00:07:28 +00:00
GitHub Actions
683dd16a80 Bump build version to 2.1.0 2022-01-19 00:08:03 +00:00
Rafael Blumberg
75bee435f5 Workaround to compile for 32bit (#40)
* Workaround to compile for 32bit

This is a workaround based on [this
comment](https://github.com/antlr/antlr4/issues/2433#issuecomment-774514106).
It is not a pretty solution but it worked well on my test file.

It runs once to compile, if make fails, then it apply the fix and try
again, this is done so builds that don't need workaround don't use it
and also because the workaround is done on top of downloaded files
during ethe first compilation.

* Update README to remove ARMv7 error comment
2022-01-02 02:41:44 +08:00
GitHub Actions
e7020854f2 Bump build version to 2.0.1 2021-12-16 00:48:19 +00:00
GitHub Actions
1ebd048bf8 Bump deb version to 1.8.12-1 2021-12-07 00:50:09 +00:00
GitHub Actions
a76b7f2725 Bump build version to 1.8.12 2021-12-01 00:49:54 +00:00
GitHub Actions
616e4562a9 Bump build version to 1.8.11 2021-11-19 00:46:26 +00:00
GitHub Actions
0372093a19 Bump deb version to 1.8.10-1 2021-10-14 00:44:23 +00:00
GitHub Actions
a147e41001 Bump build version to 1.8.10 2021-10-07 00:48:28 +00:00
GitHub Actions
c45548e768 Bump deb version to 1.8.9-1 2021-09-14 00:47:48 +00:00
26 changed files with 400 additions and 290 deletions

138
.github/workflows/build.yaml vendored Normal file
View File

@@ -0,0 +1,138 @@
name: build from source
on:
push:
branches:
- master
- dev
paths:
- .github/workflows/build.yaml
- build/*
pull_request:
paths:
- .github/workflows/build.yaml
- build/*
env:
DOCKER_REPO: shenxn/protonmail-bridge
DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-dev
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/riscv64
jobs:
build-binary:
runs-on: ubuntu-22.04
strategy:
matrix:
arch: ["amd64", "arm64", "arm", "riscv64"]
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: main
- name: Set version
id: version
run: echo "version=`cat main/build/VERSION`" >> $GITHUB_OUTPUT
- name: Checkout proton bridge repo
uses: actions/checkout@v3
with:
repository: ProtonMail/proton-bridge
ref: v${{ steps.version.outputs.version }}
path: proton-bridge
- name: Set up golang
uses: actions/setup-go@v3
with:
go-version: 1.18
check-latest: true
- name: Install dependencies
run: sudo apt-get install -y --no-install-recommends build-essential libsecret-1-dev
- name: Download go dep
if: ${{ matrix.arch == 'arm' }}
working-directory: proton-bridge
# Build once to download deps.
# This step is expected to fail.
run: make build-nogui || true
env:
GOARCH: ${{ matrix.arch }}
- name: Patch for 32 bit arch
if: ${{ matrix.arch == 'arm' }}
# For 32bit architectures, there was a overflow error on the parser
# This is a workaround for this problem found at:
# https://github.com/antlr/antlr4/issues/2433#issuecomment-774514106
run: find $(go env GOPATH)/pkg/mod/github.com/\!proton\!mail/go-rfc5322*/ -type f -exec sed -i.bak 's/(1<</(int64(1)<</g' {} +
- name: Build binary
working-directory: proton-bridge
run: make build-nogui
env:
GOARCH: ${{ matrix.arch }}
# build:
# runs-on: ubuntu-latest
# services:
# registry:
# image: registry:2
# ports:
# - 5000:5000
# steps:
# - name: Checkout
# uses: actions/checkout@master
# - name: Set version
# id: version
# run: echo "::set-output name=version::`cat build/VERSION`"
# - name: Set repo
# id: repo
# run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
# - name: Docker meta
# id: docker_meta
# uses: crazy-max/ghaction-docker-meta@v1
# with:
# images: ${{ steps.repo.outputs.repo }}
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
# with:
# driver-opts: network=host
# - name: Build image without push to registry
# uses: docker/build-push-action@v2
# with:
# context: ./build
# file: ./build/Dockerfile
# platforms: ${{ env.PLATFORMS }}
# push: true
# tags: localhost:5000/protonmail-bridge:latest
# - name: Scan image
# id: scan
# uses: anchore/scan-action@v2
# with:
# image: localhost:5000/protonmail-bridge:latest
# fail-build: true
# severity-cutoff: critical
# acs-report-enable: true
# - name: Upload Anchore scan SARIF report
# uses: github/codeql-action/upload-sarif@v1
# with:
# sarif_file: ${{ steps.scan.outputs.sarif }}
# - name: Login to DockerHub
# uses: docker/login-action@v1
# if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
# with:
# username: ${{ secrets.REGISTRY_USERNAME }}
# password: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v1
# if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.CR_PAT }}
# - name: Push image
# uses: docker/build-push-action@v2
# with:
# context: ./build
# file: ./build/Dockerfile
# platforms: ${{ env.PLATFORMS }}
# tags: |
# ${{ steps.repo.outputs.repo }}:build
# ${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.version }}-build
# labels: ${{ steps.docker_meta.outputs.labels }}
# push: ${{ github.event_name != 'pull_request' }}

View File

@@ -1,42 +1,31 @@
name: build next name: pack from deb
on: on:
push: push:
branches: branches:
- next - master
- dev
paths: paths:
- .github/workflows/next.yaml - .github/workflows/deb.yaml
- docker/* - deb/*
- protonmail_version/*
- VERSION
pull_request: pull_request:
paths: paths:
- .github/workflows/next.yaml - .github/workflows/deb.yaml
- docker/* - deb/*
- protonmail_version/*
- VERSION
env: env:
DOCKER_REPO: shenxn/protonmail-bridge-ng DOCKER_REPO: shenxn/protonmail-bridge
DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-ng-dev DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-dev
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
jobs: jobs:
build: deb:
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@master uses: actions/checkout@master
- name: Set version - name: Set version
id: version id: version
run: | run: echo "::set-output name=version::`cat deb/VERSION`"
echo "::set-output name=image_version::$(cat VERSION)" && \
echo "::set-output name=protonmail_bridge_version::$(cat protonmail_bridge_version/VERSION_LATEST)"
- name: Set repo - name: Set repo
id: repo id: repo
run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
@@ -45,26 +34,20 @@ jobs:
uses: crazy-max/ghaction-docker-meta@v1 uses: crazy-max/ghaction-docker-meta@v1
with: with:
images: ${{ steps.repo.outputs.repo }} images: ${{ steps.repo.outputs.repo }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
with: - name: Build image without push
driver-opts: network=host
- name: Build image without push to registry
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./docker context: ./deb
file: ./docker/Dockerfile file: ./deb/Dockerfile
build-args: PROTONMAIL_BRIDGE_VERSION=${{ steps.version.outputs.protonmail_bridge_version }} load: true
platforms: ${{ env.PLATFORMS }} tags: protonmail-bridge:latest
push: true
tags: localhost:5000/protonmail-bridge:latest
- name: Scan image - name: Scan image
id: scan id: scan
uses: anchore/scan-action@v2 uses: anchore/scan-action@v2
with: with:
image: localhost:5000/protonmail-bridge:latest image: protonmail-bridge:latest
fail-build: true fail-build: true
severity-cutoff: critical severity-cutoff: critical
acs-report-enable: true acs-report-enable: true
@@ -80,7 +63,7 @@ jobs:
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v1 uses: docker/login-action@v1
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/next' }} if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
@@ -88,12 +71,10 @@ jobs:
- name: Push image - name: Push image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./docker context: ./deb
file: ./docker/Dockerfile file: ./deb/Dockerfile
build-args: PROTONMAIL_BRIDGE_VERSION=${{ steps.version.outputs.protonmail_bridge_version }}
platforms: ${{ env.PLATFORMS }}
tags: | tags: |
${{ steps.repo.outputs.repo }}:latest ${{ steps.repo.outputs.repo }}:latest
${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.image_version }}-${{ steps.version.outputs.protonmail_bridge_version }} ${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.version }}
labels: ${{ steps.docker_meta.outputs.labels }} labels: ${{ steps.docker_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}

3
.gitignore vendored
View File

@@ -0,0 +1,3 @@
# Ignoring IDE-specific files
.idea/*
.vscode

View File

@@ -12,10 +12,6 @@ Docker Hub: [https://hub.docker.com/r/shenxn/protonmail-bridge](https://hub.dock
GitHub: [https://github.com/shenxn/protonmail-bridge-docker](https://github.com/shenxn/protonmail-bridge-docker) GitHub: [https://github.com/shenxn/protonmail-bridge-docker](https://github.com/shenxn/protonmail-bridge-docker)
## ARMv7 Builds
Currently there is a problem building the new parser targeting 32-bit architectures (i.e. `arm/v7`). The latest working build is `1.4.5-build`. Therefore, if you are using an `arm/v7` device like Raspberry Pi, do not upgrade to newer version. More information about the problem can be found [here](https://www.reddit.com/r/ProtonMail/comments/jvzm12/issue_building_bridge_150/). If you have any idea on how to fix this, a PR is welcome.
## ARM Support ## ARM Support
We now support ARM devices (`arm64` and `arm/v7`)! Use the images tagged with `build`. See next section for details. We now support ARM devices (`arm64` and `arm/v7`)! Use the images tagged with `build`. See next section for details.
@@ -24,42 +20,31 @@ We now support ARM devices (`arm64` and `arm/v7`)! Use the images tagged with `b
There are two types of images. There are two types of images.
- `deb`: Images based on the official [.deb release](https://protonmail.com/bridge/install). It only supports the `amd64` architecture. - `deb`: Images based on the official [.deb release](https://protonmail.com/bridge/install). It only supports the `amd64` architecture.
- `build`: Images based on the [source code](https://github.com/ProtonMail/proton-bridge). It supports `amd64`, `arm64`, and `arm/v7`. Supporting to more architectures is possible. PRs are welcome. - `build`: Images based on the [source code](https://github.com/ProtonMail/proton-bridge). It supports `amd64`, `arm64`, `arm/v7` and `riscv64`. Supporting to more architectures is possible. PRs are welcome.
| tag | description | tag | description
| ----------------- | -------------------- | -- | --
| `latest` | latest `deb` image | `latest` | latest `deb` image
| `[version]` | `deb` images | `[version]` | `deb` images
| `build` | latest `build` image | `build` | latest `build` image
| `[version]-build` | `build` images | `[version]-build` | `build` images
## Environment Variables for images with `build` in tag
| Name | Description | Default Value |
| --------------------- | --------------------------------------------------------------------------------- | ------------- |
| `PROTONMAIL_USERNAME` | your protonmail account username | (not set) |
| `PROTONMAIL_PASSWORD` | the password for your protonmail account | (not set) |
| `KEY_ID` | the pgp-id for the internal password manager required by protonmail-bridge | `pass-key` |
| `GNUPGHOME` | change the defulat `/root/.gnupg` to this directory as a workaround for gpg error | `/tmp/gnupg` |
## Initialization ## Initialization
To initialize and add account to the bridge, run the following command. To initialize and add account to the bridge, run the following command.
```bash ```
docker run --rm -it -v protonmail:/home/protonmail shenxn/protonmail-bridge init docker run --rm -it -v protonmail:/root shenxn/protonmail-bridge init
``` ```
Wait for the bridge to startup, use `login` command and follow the instructions to add your account into the bridge. Then use `info` to see the configuration information (username and password). After that, use `exit` to exit the bridge. You may need `CTRL+C` to exit the docker entirely. Wait for the bridge to startup, use `login` command and follow the instructions to add your account into the bridge. Then use `info` to see the configuration information (username and password). After that, use `exit` to exit the bridge. You may need `CTRL+C` to exit the docker entirely.
__NOTE:__ If you have `PROTONMAIL_USERNAME` and `PROTONMAIL_PASSWORD` set for `docker run` with `-e`, the login process will finish automatically.
## Run ## Run
To run the container, use the following command. To run the container, use the following command.
```bash ```
docker run -d --name=protonmail-bridge -v protonmail:/home/protonmail -p 1025:25/tcp -p 1143:143/tcp --restart=unless-stopped shenxn/protonmail-bridge docker run -d --name=protonmail-bridge -v protonmail:/root -p 1025:25/tcp -p 1143:143/tcp --restart=unless-stopped shenxn/protonmail-bridge
``` ```
## Kubernetes ## Kubernetes
@@ -72,8 +57,8 @@ If you don't want to use Helm, you can also reference to the guide ([#6](https:/
Please be aware that running the command above will expose your bridge to the network. Remember to use firewall if you are going to run this in an untrusted network or on a machine that has public IP address. You can also use the following command to publish the port to only localhost, which is the same behavior as the official bridge package. Please be aware that running the command above will expose your bridge to the network. Remember to use firewall if you are going to run this in an untrusted network or on a machine that has public IP address. You can also use the following command to publish the port to only localhost, which is the same behavior as the official bridge package.
```bash ```
docker run -d --name=protonmail-bridge -v protonmail:/home/protonmail -p 127.0.0.1:1025:25/tcp -p 127.0.0.1:1143:143/tcp --restart=unless-stopped shenxn/protonmail-bridge docker run -d --name=protonmail-bridge -v protonmail:/root -p 127.0.0.1:1025:25/tcp -p 127.0.0.1:1143:143/tcp --restart=unless-stopped shenxn/protonmail-bridge
``` ```
Besides, you can publish only port 25 (SMTP) if you don't need to receive any email (e.g. as a email notification service). Besides, you can publish only port 25 (SMTP) if you don't need to receive any email (e.g. as a email notification service).

View File

@@ -1 +0,0 @@
0.1

8
build/.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
*
!.dockerignore
!VERSION
!entrypoint.sh
!gpgparams
!Dockerfile
!build.sh

30
build/Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
# Use carlosedp/golang for riscv64 support
FROM carlosedp/golang:1.18 AS build
# Install dependencies
RUN apt-get update && apt-get install -y git build-essential libsecret-1-dev
# Build
WORKDIR /build/
COPY build.sh VERSION /build/
RUN bash build.sh
FROM ubuntu:jammy
LABEL maintainer="Xiaonan Shen <s@sxn.dev>"
EXPOSE 25/tcp
EXPOSE 143/tcp
# Install dependencies and protonmail bridge
RUN apt-get update \
&& apt-get install -y --no-install-recommends socat pass libsecret-1-0 ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy bash scripts
COPY gpgparams entrypoint.sh /protonmail/
# Copy protonmail
COPY --from=build /build/proton-bridge/bridge /protonmail/
COPY --from=build /build/proton-bridge/proton-bridge /protonmail/
ENTRYPOINT ["bash", "/protonmail/entrypoint.sh"]

1
build/VERSION Normal file
View File

@@ -0,0 +1 @@
3.0.9

23
build/build.sh Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -ex
VERSION=`cat VERSION`
# Clone new code
git clone https://github.com/ProtonMail/proton-bridge.git
cd proton-bridge
git checkout v$VERSION
ARCH=$(uname -m)
if [[ $ARCH == "armv7l" ]] ; then
# This is expected to fail, and we use the following patch to fix
make build-nogui || true
# For 32bit architectures, there was a overflow error on the parser
# This is a workaround for this problem found at:
# https://github.com/antlr/antlr4/issues/2433#issuecomment-774514106
find $(go env GOPATH)/pkg/mod/github.com/\!proton\!mail/go-rfc5322*/ -type f -exec sed -i.bak 's/(1<</(int64(1)<</g' {} +
fi
# Build
make build-nogui

35
build/entrypoint.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -ex
# Initialize
if [[ $1 == init ]]; then
# Initialize pass
gpg --generate-key --batch /protonmail/gpgparams
pass init pass-key
# Kill the other instance as only one can be running at a time.
# This allows users to run entrypoint init inside a running conainter
# which is useful in a k8s environment.
# || true to make sure this would not fail in case there is no running instance.
pkill protonmail-bridge || true
# Login
/protonmail/proton-bridge --cli $@
else
# socat will make the conn appear to come from 127.0.0.1
# ProtonMail Bridge currently expects that.
# It also allows us to bind to the real ports :)
socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 &
socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 &
# Start protonmail
# Fake a terminal, so it does not quit because of EOF...
rm -f faketty
mkfifo faketty
cat faketty | /protonmail/proton-bridge --cli $@
fi

11
build/install-golang.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -ex
GOLANG_VERSION=1.18.7
ARCH=$(uname -m)
if [[ $ARCH == "riscv64" ]]; then
# There is no official riscv64 release. Use carlosedp/riscv-bringup instead.
wget

8
deb/.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
*
!.dockerignore
!VERSION
!entrypoint.sh
!install.sh
!gpgparams
!Dockerfile

15
deb/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM ubuntu:bionic
LABEL maintainer="Xiaonan Shen <s@sxn.dev>"
EXPOSE 25/tcp
EXPOSE 143/tcp
WORKDIR /protonmail
# Copy bash scripts
COPY gpgparams install.sh entrypoint.sh VERSION /protonmail/
# Install dependencies and protonmail bridge
RUN bash install.sh
ENTRYPOINT ["bash", "/protonmail/entrypoint.sh"]

1
deb/VERSION Normal file
View File

@@ -0,0 +1 @@
2.3.0-1

49
deb/entrypoint.sh Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
set -ex
# Initialize
if [[ $1 == init ]]; then
# # Parse parameters
# TFP="" # Default empty two factor passcode
# shift # skip `init`
# while [[ $# -gt 0 ]]; do
# key="$1"
# case $key in
# -u|--username)
# USERNAME="$2"
# ;;
# -p|--password)
# PASSWORD="$2"
# ;;
# -t|--twofactor)
# TWOFACTOR="$2"
# ;;
# esac
# shift
# shift
# done
# Initialize pass
gpg --generate-key --batch /protonmail/gpgparams
pass init pass-key
# Login
protonmail-bridge --cli
else
# socat will make the conn appear to come from 127.0.0.1
# ProtonMail Bridge currently expects that.
# It also allows us to bind to the real ports :)
socat TCP-LISTEN:25,fork TCP:127.0.0.1:1025 &
socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 &
# Start protonmail
# Fake a terminal, so it does not quit because of EOF...
rm -f faketty
mkfifo faketty
cat faketty | protonmail-bridge --cli
fi

8
deb/gpgparams Normal file
View File

@@ -0,0 +1,8 @@
%no-protection
%echo Generating a basic OpenPGP key
Key-Type: RSA
Key-Length: 2048
Name-Real: pass-key
Expire-Date: 0
%commit
%echo done

36
deb/install.sh Normal file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -ex
VERSION=`cat VERSION`
DEB_FILE=protonmail-bridge_${VERSION}_amd64.deb
# Install dependents
apt-get update
apt-get install -y --no-install-recommends socat pass ca-certificates
# Build time dependencies
apt-get install -y wget binutils xz-utils
# Repack deb (remove unnecessary dependencies)
mkdir deb
cd deb
wget -q https://protonmail.com/download/bridge/${DEB_FILE}
ar x -v ${DEB_FILE}
mkdir control
tar zxvf control.tar.gz -C control
sed -i "s/^Depends: .*$/Depends: libgl1, libc6, libsecret-1-0, libstdc++6, libgcc1/" control/control
cd control
tar zcvf ../control.tar.gz .
cd ../
ar rcs -v ${DEB_FILE} debian-binary control.tar.gz data.tar.gz
cd ../
# Install protonmail bridge
apt-get install -y --no-install-recommends ./deb/${DEB_FILE}
# Cleanup
apt-get purge -y wget binutils xz-utils
apt-get autoremove -y
rm -rf /var/lib/apt/lists/*
rm -rf deb

View File

@@ -1,42 +0,0 @@
FROM golang:1.16 AS build
# Install dependencies
RUN apt-get update && apt-get install -y libsecret-1-dev
ARG PROTONMAIL_BRIDGE_VERSION
# Build
WORKDIR /build/
RUN curl -L https://github.com/ProtonMail/proton-bridge/archive/refs/tags/${PROTONMAIL_BRIDGE_VERSION}.tar.gz \
| tar zx --strip-component 1
RUN make build-nogui
FROM ubuntu:bionic
LABEL maintainer="Xiaonan Shen <s@sxn.dev>"
EXPOSE 25/tcp
EXPOSE 143/tcp
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
expect socat pass libsecret-1-0 ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="/srv/protonmail:$PATH"
# Copy protonmail
COPY --from=build /build/proton-bridge /srv/protonmail/
# Copy bash scripts
COPY gpgparams entrypoint.sh auto-login.exp login.sh /srv/protonmail/
# Create use and group for protonmail
RUN groupadd --gid 8535 protonmail \
&& useradd --uid 8535 --gid 8535 --home-dir /protonmail protonmail \
&& mkdir /protonmail \
&& chown protonmail:protonmail /protonmail
USER protonmail
WORKDIR /protonmail
ENTRYPOINT ["bash", "/srv/protonmail/entrypoint.sh"]

View File

@@ -1 +0,0 @@
v1.8.9

View File

@@ -1,98 +0,0 @@
#!/usr/bin/expect -f
set timeout 15;
spawn proton-bridge -cli {*}$argv ;
# wait for inital prompt
expect {
">>> " {
# protonmail-bridge started without error, do nothing
}
timeout {
puts "Timed out"
exit 2
}
}
send "login\n"
expect {
"Username: " {
# login start, enter username
}
timeout {
puts "Timed out"
exit 2
}
}
send "$::env(PROTONMAIL_USERNAME)\n"
expect {
"Password: " {
# username entered, enter password
}
timeout {
puts "Timed out"
exit 2
}
}
stty -echo
sleep 1
send "$::env(PROTONMAIL_PASSWORD)\n"
stty echo
expect {
"was added successfully." {
# login ok
}
"Two factor code: " {
# 2FA enabled, enter OTP
if ![info exists ::env(PROTONMAIL_OTP)] {
puts "\n2FA enabled but PROTONMAIL_OTP is not set. Exiting"
exit 1
}
send "$::env(PROTONMAIL_OTP)\n"
expect {
"was added successfully." {
# login ok
}
"Server error" {
# login failed
exit 1
}
timeout {
puts "Timed out"
exit 2
}
}
}
"Server error" {
# login failed
exit 1
}
timeout {
puts "Timed out"
exit 2
}
}
send "info\n"
expect {
"Configuration for " {
# successfully got info. Wait for printing
sleep 1
}
timeout {
puts "Timed out"
exit 2
}
}

View File

@@ -1,62 +0,0 @@
#!/bin/bash
set -e
# Generate gpg keys
if [ ! -f ${HOME}/.gnupg ]; then
echo "Generateing gpg keys..."
# set GNUPGHOME as a workaround for
#
# gpg-agent[106]: error binding socket to '/root/.gnupg/S.gpg-agent': File name too long
#
# when using docker volume mount
#
# ref: https://dev.gnupg.org/T2964
#
export GNUPGHOME=/tmp/gnupg
mkdir ${GNUPGHOME}
chmod 700 ${GNUPGHOME}
gpg --generate-key --batch /srv/protonmail/gpgparams
pkill gpg-agent
mv ${GNUPGHOME} ${HOME}/.gnupg
export GNUPGHOME=""
fi
# Initialize pass
if [ ! -f ${HOME}/.password-store/.gpg-id ]; then
echo "Initializing pass"
pass init pass-key
fi
# Login
if [ ! -f ${HOME}/.logged-in ]; then
if [[ -n ${PROTONMAIL_USERNAME} && -n ${PROTONMAIL_PASSWORD} ]]; then
echo "Logging in"
auto-login.exp $@
echo "" > ${HOME}/.logged-in
else
# Wait for manual login
echo "=============================================================================="
echo "PROTONMAIL_USERNAME or PROTONMAIL_PASSWORD is not set. Will not do auto login."
echo "Run docker exec -it protonmail login.sh to login manually."
echo "Waiting for manual login..."
while [ ! -f ${HOME}/.logged-in ]; do
sleep 5
done
fi
fi
echo "Logged in flag detected. Starting protonmail bridge"
# socat will make the conn appear to come from 127.0.0.1
# ProtonMail Bridge currently expects that.
# It also allows us to bind to the real ports :)
socat TCP-LISTEN:2025,fork TCP:127.0.0.1:1025 &
socat TCP-LISTEN:2143,fork TCP:127.0.0.1:1143 &
# Start protonmail
# Fake a terminal, so it does not quit because of EOF...
rm -f faketty
mkfifo faketty
cat faketty | proton-bridge --cli $@

View File

@@ -1,12 +0,0 @@
#!/bin/bash
echo "Start manual login"
echo "========================================================================"
echo "IMPORTANT: Use `exit` instead of CTRL-C when you successfully logged in."
echo "Otherwise protonmail bridge will not start."
echo "========================================================================"
proton-bridge -cli
echo "Consider logged in. Add flag."
echo "" > $HOME/.logged-in

View File

@@ -1 +0,0 @@
v1.8.7

View File

@@ -1 +0,0 @@
v1.8.9

View File

@@ -1,4 +0,0 @@
image_version: 0.1
protonmail_version:
latest: v1.8.7 # Latest stable version
pre: v1.8.9 # Latest preview version