Skip to content

Commit

Permalink
Merge pull request #216 from crazy-max/compose-stack-test
Browse files Browse the repository at this point in the history
ci: use compose stack for testing
  • Loading branch information
crazy-max committed Jul 22, 2023
2 parents 0c5ae8f + e640cfc commit ee387f5
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 58 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: build

concurrency:
group: build-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
Expand All @@ -13,8 +13,6 @@ on:
paths-ignore:
- '**.md'
pull_request:
branches:
- 'master'
paths-ignore:
- '**.md'

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: labels

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
Expand Down
58 changes: 21 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: test

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- 'master'
paths-ignore:
- '**.md'
pull_request:
branches:
- 'master'
paths-ignore:
- '**.md'

Expand Down Expand Up @@ -36,43 +38,22 @@ jobs:
targets: image-local
env:
DEFAULT_TAG: ${{ env.BUILD_TAG }}
-
name: Create network
run: |
docker network create -d bridge ${{ env.CONTAINER_NAME }}
-
name: Start MariaDB container
run: |
docker run -d --name mariadb --hostname mariadb \
--network ${{ env.CONTAINER_NAME }} \
-e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" \
-e "MYSQL_DATABASE=anonaddy" \
-e "MYSQL_USER=anonaddy" \
-e "MYSQL_PASSWORD=anonaddy" \
mariadb:10.5
-
name: Generate DKIM private key
run: |
docker run --rm -t --entrypoint "" \
-e "ANONADDY_DOMAIN=example.com" \
-v "/tmp/data:/data" \
${{ env.BUILD_TAG }} gen-dkim
docker compose run --rm gen-dkim
working-directory: test
env:
ANONADDY_IMAGE: ${{ env.BUILD_TAG }}
ANONADDY_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Start container
name: Start
run: |
docker run -d --name ${{ env.CONTAINER_NAME }} \
--link mariadb \
--network ${{ env.CONTAINER_NAME }} \
-e "DB_HOST=mariadb" \
-e "DB_DATABASE=anonaddy" \
-e "DB_USERNAME=anonaddy" \
-e "DB_PASSWORD=anonaddy" \
-e "APP_KEY=base64:Gh8/RWtNfXTmB09pj6iEflt/L6oqDf9ZxXIh4I9MS7A=" \
-e "ANONADDY_DOMAIN=example.com" \
-e "ANONADDY_SECRET=0123456789abcdefghijklmnopqrstuvwxyz" \
-e "RSPAMD_ENABLE=true" \
-v "/tmp/data:/data" \
${{ env.BUILD_TAG }}
docker compose up -d
working-directory: test
env:
ANONADDY_IMAGE: ${{ env.BUILD_TAG }}
ANONADDY_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Check container logs
uses: crazy-max/.github/.github/actions/container-logs-check@main
Expand All @@ -81,8 +62,11 @@ jobs:
log_check: "ready to handle connections"
timeout: 120
-
name: Container logs
name: Logs
if: always()
run: |
docker logs ${{ env.CONTAINER_NAME }}
docker rm -f ${{ env.CONTAINER_NAME }} > /dev/null 2>&1 || true
docker compose logs
working-directory: test
env:
ANONADDY_IMAGE: ${{ env.BUILD_TAG }}
ANONADDY_CONTAINER: ${{ env.CONTAINER_NAME }}
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ Image: anonaddy/anonaddy:latest
### Docker Compose

Docker compose is the recommended way to run this image. You can use the following
[docker compose template](examples/compose/docker-compose.yml), then run the container:
[docker compose template](examples/compose/compose.yml), then run the container:

```console
docker-compose up -d
docker-compose logs -f
docker compose up -d
docker compose logs -f
```

## Upgrade
Expand All @@ -240,8 +240,8 @@ You can upgrade AnonAddy automatically through the UI, it works well. But I
recommend to recreate the container whenever I push an update:

```console
docker-compose pull
docker-compose up -d
docker compose pull
docker compose up -d
```

## Notes
Expand All @@ -252,25 +252,25 @@ If you want to use the artisan command to perform common server operations like
manage users, passwords and more, type:

```console
docker-compose exec anonaddy anonaddy <command>
docker compose exec anonaddy anonaddy <command>
```

For example to list all available commands:

```console
docker-compose exec anonaddy anonaddy list
docker compose exec anonaddy anonaddy list
```

### Create user

```console
docker-compose exec anonaddy anonaddy anonaddy:create-user "username" "webmaster@example.com"
docker compose exec anonaddy anonaddy anonaddy:create-user "username" "webmaster@example.com"
```

### Generate DKIM private/public keypair

```console
docker-compose run --entrypoint '' anonaddy gen-dkim
docker compose run --entrypoint '' anonaddy gen-dkim
```

```text
Expand All @@ -291,7 +291,7 @@ If you don't have an existing GPG key, you can generate a new GPG key with the
following command:

```console
docker-compose exec --user anonaddy anonaddy gpg --full-gen-key
docker compose exec --user anonaddy anonaddy gpg --full-gen-key
```

Keys will be stored in `/data/.gnupg` folder.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.5"
name: annoaddy

services:
db:
Expand Down
4 changes: 2 additions & 2 deletions examples/nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ sudo openssl dhparam -out dhparam.pem 4096

## Configure mounts for nginx

The `docker-compose.yml` may need some adjusting to properly mount your
specific let's encrypt and dhparam certs.
The `compose.yml` may need some adjusting to properly mount your specific
let's encrypt and dhparam certs.

## Rspamd web ui

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.5"
name: annoaddy

services:
db:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.5"
name: annoaddy

services:
db:
Expand Down
4 changes: 2 additions & 2 deletions examples/traefik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
```bash
touch acme.json
chmod 600 acme.json
docker-compose up -d
docker-compose logs -f
docker compose up -d
docker compose logs -f
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.5"
name: annoaddy

services:
traefik:
Expand Down
3 changes: 3 additions & 0 deletions test/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MYSQL_DATABASE=anonaddy
MYSQL_USER=anonaddy
MYSQL_PASSWORD=anonaddy
36 changes: 36 additions & 0 deletions test/anonaddy.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
TZ=Europe/Paris
PUID=1000
PGID=1000

MEMORY_LIMIT=256M
UPLOAD_MAX_SIZE=16M
OPCACHE_MEM_SIZE=128
REAL_IP_FROM=0.0.0.0/32
REAL_IP_HEADER=X-Forwarded-For
LOG_IP_VAR=remote_addr

APP_KEY=base64:Gh8/RWtNfXTmB09pj6iEflt/L6oqDf9ZxXIh4I9MS7A=
APP_DEBUG=false
APP_URL=http://127.0.0.1:8000

ANONADDY_RETURN_PATH=bounces@example.com
ANONADDY_ADMIN_USERNAME=anonaddy
ANONADDY_ENABLE_REGISTRATION=true
ANONADDY_DOMAIN=example.com
ANONADDY_ALL_DOMAINS=example.com
ANONADDY_HOSTNAME=mail.example.com
ANONADDY_DNS_RESOLVER=127.0.0.1
ANONADDY_SECRET=0123456789abcdefghijklmnopqrstuvwxyz
ANONADDY_LIMIT=200
ANONADDY_BANDWIDTH_LIMIT=104857600
ANONADDY_NEW_ALIAS_LIMIT=10
ANONADDY_ADDITIONAL_USERNAME_LIMIT=3

MAIL_FROM_NAME=AnonAddy
MAIL_FROM_ADDRESS=anonaddy@example.com

POSTFIX_DEBUG=false
POSTFIX_SMTPD_TLS=false
POSTFIX_SMTP_TLS=false

RSPAMD_ENABLE=true
73 changes: 73 additions & 0 deletions test/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: annoaddy

services:
db:
image: mariadb:10.5
container_name: anonaddy_db
networks:
- anonaddy
command:
- "mysqld"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
volumes:
- "db:/var/lib/mysql"
environment:
- "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
- "MYSQL_DATABASE"
- "MYSQL_USER"
- "MYSQL_PASSWORD"
restart: always

redis:
image: redis:4.0-alpine
container_name: anonaddy_redis
networks:
- anonaddy
restart: always

anonaddy:
image: ${ANONADDY_IMAGE:-anonaddy/anonaddy}
container_name: ${ANONADDY_CONTAINER:-anonaddy}
depends_on:
- db
- redis
networks:
- anonaddy
ports:
- target: 25
published: 25
protocol: tcp
- target: 8000
published: 8000
protocol: tcp
volumes:
- "anonaddy:/data"
env_file:
- "./anonaddy.env"
environment:
- "DB_HOST=db"
- "DB_DATABASE=${MYSQL_DATABASE}"
- "DB_USERNAME=${MYSQL_USER}"
- "DB_PASSWORD=${MYSQL_PASSWORD}"
- "REDIS_HOST=redis"
restart: always

gen-dkim:
image: ${ANONADDY_IMAGE:-anonaddy/anonaddy}
profiles: ["bootstrap"]
entrypoint: ''
command: gen-dkim
volumes:
- "anonaddy:/data"
env_file:
- "./anonaddy.env"
restart: no

volumes:
db:
anonaddy:

networks:
anonaddy:
name: anonaddy

0 comments on commit ee387f5

Please sign in to comment.