Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a docker compose file #70

Merged
merged 2 commits into from
May 2, 2023
Merged

Add a docker compose file #70

merged 2 commits into from
May 2, 2023

Conversation

dngray
Copy link
Contributor

@dngray dngray commented Dec 5, 2022

It's quite the norm to include a docker-compose file, generally in the README or the root for people to copy and modify. For example as https://github.com/wfg/docker-openvpn-client has done so.

If there are Environmental variables, they should also be documented - in this case there isn't.

Copy link

@eyduh eyduh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good practise to have the docker-compose version stated at the top of the file, for compatibility with GUIs like portainer one might want to stick to
version: '2.1'

Also, should add a volume declaration

volumes:
  protonmail:
    name: protonmail

I also added an external network to my file so that I can add other containers to the same docker network and not expose the ports on the host, especially useful on servers with public IPs, however this might be a commented section in the file by default.

@Qhilm
Copy link

Qhilm commented Apr 2, 2023

@eyduh I am not entirely following the volume declaration.
Shouldn't it be something like:

volumes:
    - ./protonmail:/root

@eyduh
Copy link

eyduh commented Apr 2, 2023

For the containers, or services as they technically are referred to in a compose file, there can be a section declaring where to store user data. This can either be a named volume, like

volumes:
    - protonmail:/root

In which case the volume will need to be declared in a volumes: section in the compose file.

Another way to store user data is using bind mounts like you have declared in your example. If using bind mounts then you do not need to declare a volume separately.

There are also predefined volumes that get declared in the Dockerfile if one knows that a certain directory will contain data that needs to be persisted for the user.

You can read more about the different ways to persist user data here.. It is technically not needed but if one wants to move this container from one host to another using volumes is one way to do it, also to make sure the setup is persisted between updates or rebuilds of the image and container.

Seeing as there is no need to browse the files of this container, and the user files are a bit sensitive to permissions, I used a docker volume rather than a bind mount for my setup. The service is run as root so the gpg key files are generated in /root in this case so persisting /root in a docker volume made sense to me, but there is no one right way to do things c:

@Qhilm
Copy link

Qhilm commented Apr 3, 2023

Thank for the very detailed answer @eyduh!

How would one initialize the container with compose? If I initiate using docker run --rm -it -v protonmail:/root shenxn/protonmail-bridge init and then try to create a docker compose for it, it does not work, docker compose will try to create a new contain with the same name and complain.

@Nexion
Copy link

Nexion commented Apr 3, 2023

@hobbes444 by default docker compose creates new volumes and networks prefixed with the assigned project name. If you'd rather prefer it to use an existing volume, it should be marked with external: true:

volumes:
  protonmail:
    external: true

@Qhilm
Copy link

Qhilm commented Apr 15, 2023

Thanks @Nexion @eyduh . I did this:

docker run --rm -it -v protonmail:/root shenxn/protonmail-bridge init

then

version: '2.1'

services:
  protonmail-bridge:
    image: shenxn/protonmail-bridge
    container_name: pm_bridge
    ports:
      - 127.0.0.1:1025:25/tcp
      - 127.0.0.1:1143:143/tcp
    restart: unless-stopped
    stdin_open: true 
    tty: true
volumes:
  protonmail:
    external: true

but that does not seem to work, I get this error:

WARN[0000] Failed to add test credentials to keychain error="pass not initialized: exit status 1: Error: password store is empty. Try \"pass init\".\n" helper="*pass.Pass"

It seems it's not able to find the data created using the initialization command.

@Nexion
Copy link

Nexion commented Apr 16, 2023

@hobbes444

version: '2.1'

services:
  protonmail-bridge:
    image: shenxn/protonmail-bridge
    container_name: pm_bridge
    ports:
      - 127.0.0.1:1025:25/tcp
      - 127.0.0.1:1143:143/tcp
    volumes: # <---
      - protonmail:/root
    restart: unless-stopped
    stdin_open: true 
    tty: true
volumes:
  protonmail:
    external: true

@shenxn
Copy link
Owner

shenxn commented May 2, 2023

Thanks for the contribution! Sorry for replying late. I'll merge this first and feel free to submit any further improvements

@shenxn shenxn merged commit 67415bd into shenxn:master May 2, 2023
yo8192 added a commit to yo8192/protonmail-bridge-docker that referenced this pull request Feb 3, 2024
* Bump build version to 3.0.10

* Bump build version to 3.0.12

* Bump build version to 3.0.14

* Bump build version to 3.0.15

* Bump build version to 3.0.16

* Bump deb version to 3.0.17-1

* Bump build version to 3.0.18

* Bump deb version to 3.0.19-1

* Bump build version to 3.0.19

* Bump deb version to 3.0.20-1

* Bump build version to 3.0.20

* Update Ubuntu tag for deb to fix GLIBC dependency (shenxn#80)

GLIBC dependency issue highlighted in
shenxn#79 is caused
by v3 of the bridge not supporting bionic. This PR simply updates the
"deb" version to match the "build" version which is already on
ubuntu:jammy.

* Bump deb version to 3.0.21-1

* Bump build version to 3.0.21

* Bump build version to 3.1.0

* Bump build version to 3.1.1

* Bump deb version to 3.1.2-1

* Bump build version to 3.1.2

* Add a docker compose file (shenxn#70)

It's quite the norm to include a docker-compose file, generally in the
README or the root for people to copy and modify. For example as
https://github.com/wfg/docker-openvpn-client has done so.

If there are [Environmental
variables](https://github.com/wfg/docker-openvpn-client#environment-variables),
they should also be documented - in this case there isn't.

* Bump deb version to 3.1.3-1

* Bump build version to 3.1.3

* Bump build version to 3.2.0

* Bump deb version to 3.2.0-1

* Bump build version to 3.3.0

* Bump deb version to 3.3.0-1

* Bump build version to 3.3.1

* Bump deb version to 3.3.2-1

* Bump build version to 3.3.2

* Bump build version to 3.4.0

* Bump build version to 3.4.1

* Bump build version to 3.4.2

* Bump build version to 3.5.0

* Bump deb version to 3.4.2-1

* Bump build version to 3.5.1

* Bump deb version to 3.5.1-1

* Bump deb version to 3.4.2-1

* Bump build version to 3.5.2

* Bump deb version to 3.5.3-1

* Bump build version to 3.5.3

* Bump build version to 3.6.0

* Bump deb version to 3.5.4-1

* Bump build version to 3.6.1

* Bump deb version to 3.6.1-2

* Bump build version to 3.7.0

* Bump build version to 3.7.1

* Bump deb version to 3.7.1-1

* Bump build version to 3.8.0

* Bump build version to 3.8.1

* Bump deb version to 3.8.1-1

* Bump build version to 3.9.0

* Bump deb version to 3.8.2-1

---------

Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: Aziz Hasanain <sgtaziz013@gmail.com>
Co-authored-by: Daniel Nathan Gray <dng@disroot.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants