Skip to content

Commit

Permalink
Merge pull request #95 from icgood/docker
Browse files Browse the repository at this point in the history
Add docker build
  • Loading branch information
icgood committed Sep 23, 2020
2 parents 73aa253 + 068891b commit 089a2ab
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Everything runs in an [asyncio][2] event loop.

#### [API Documentation](https://icgood.github.io/pymap/)

#### [Docker Image](https://hub.docker.com/repository/docker/icgood/pymap)

### Table of Contents

* [Install and Usage](#install-and-usage)
Expand Down
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.8-alpine

RUN pip install -U pip wheel setuptools typing-extensions

ARG install_arg="pymap"
ARG install_arg_opt="redis,admin,sieve,optional"
RUN apk --update add --virtual build-dependencies python3-dev build-base \
&& pip install "${install_arg}[${install_arg_opt}]" \
&& apk del build-dependencies

ENTRYPOINT ["pymap"]
76 changes: 76 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
icgood/pymap
============

Runs a [pymap][1] IMAP server in a Docker container.

## Usage

First, create a new service in your `docker-compose.yml`:

```yaml
imap-server:
image: icgood/pymap
```

Declare one or more host port bindings:

```yaml
ports:
- "143:143"
- "4190:4190"
- "9090:9090"
```

Alternatively, use a [proxy-protocol][2] service to expose your IMAP ports to
preserve connection metadata. You will need to add `--proxy-protocol detect` to
the _pymap_ arguments below for this configuration.

Finally, modify the service entrypoint to declare the desired arguments:

```yaml
entrypoint: >-
pymap --debug dict --demo-data
```

The above example creates a basic in-memory server with `demouser`/`demopass`
credentials. See the [pymap][1] documentation for more useful ideas.

### SSL Certificates

If you need to provide certificates for TLS, some additional configuration is
necessary. The below examples are using [Let's Encrypt][4] via the
[icgood/letsencrypt-service][5] image, but should be adapted for other
configurations.

First, expose your certificates directory as a volume, e.g.:

```yaml
volumes:
- /etc/ssl/private:/etc/ssl/private
```

And add the new arguments to the entrypoint, e.g.:

```yaml
entrypoint: >-
pymap --debug
--cert /etc/ssl/private/mail/fullchain.pem
--key /etc/ssl/private/mail/privkey.pem
dict --demo-data
```

Finally, add a healthcheck so that [pymap][1] will restart whenever a new
certificate is generated.

```yaml
healthcheck:
interval: 10s
retries: 1
test: test /etc/ssl/private/mail/privkey.pem -ot /tmp/pymap.pid
```

[1]: https://github.com/icgood/pymap
[2]: https://hub.docker.com/repository/docker/icgood/proxy-protocol
[3]: https://docs.docker.com/compose/compose-file/#volumes
[4]: https://letsencrypt.org/
[5]: https://hub.docker.com/repository/docker/icgood/letsencrypt-service
5 changes: 5 additions & 0 deletions docker/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -ex

export install_arg="$GITHUB_REPO/archive/$SOURCE_BRANCH.tar.gz"
docker build --build-arg install_arg -f $DOCKERFILE_PATH -t $IMAGE_NAME .
7 changes: 7 additions & 0 deletions docker/hooks/post_push
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -ex

if [ "$SOURCE_BRANCH" != "master" ]; then
docker tag $IMAGE_NAME $DOCKER_REPO:latest
docker push $DOCKER_REPO:latest
fi

0 comments on commit 089a2ab

Please sign in to comment.