Skip to content

Commit

Permalink
Merge pull request #89 from crazy-max/test-compose-stack
Browse files Browse the repository at this point in the history
ci: use compose stack for testing
  • Loading branch information
crazy-max authored Aug 29, 2023
2 parents 544e25a + e1e8369 commit b29e937
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 60 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
45 changes: 16 additions & 29 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 @@ -37,31 +39,13 @@ jobs:
env:
DEFAULT_TAG: ${{ env.BUILD_TAG }}
-
name: Create network
run: |
docker network create -d bridge ${{ env.CONTAINER_NAME }}
-
name: Start MariaDB container
name: Start
run: |
docker run -d --name mariadb --hostname mariadb \
--network ${{ env.CONTAINER_NAME }} \
-e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" \
-e "MYSQL_DATABASE=flarum" \
-e "MYSQL_USER=flarum" \
-e "MYSQL_PASSWORD=flarum" \
mariadb:10.4
-
name: Start container
run: |
docker run -d --name ${{ env.CONTAINER_NAME }} \
--link mariadb \
--network ${{ env.CONTAINER_NAME }} \
-e "DB_HOST=mariadb" \
-e "DB_NAME=flarum" \
-e "DB_USER=flarum" \
-e "DB_PASSWORD=flarum" \
-e "FLARUM_BASE_URL=http://127.0.0.1:8000" \
${{ env.BUILD_TAG }}
docker compose up -d
working-directory: test
env:
FLARUM_IMAGE: ${{ env.BUILD_TAG }}
FLARUM_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Check container logs
uses: crazy-max/.github/.github/actions/container-logs-check@main
Expand All @@ -70,8 +54,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:
FLARUM_IMAGE: ${{ env.BUILD_TAG }}
FLARUM_CONTAINER: ${{ env.CONTAINER_NAME }}
55 changes: 32 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ docker buildx bake image-all

## Image

| Registry | Image |
|--------------------------------------------------------------------------------------------------|---------------------------------|
| [Docker Hub](https://hub.docker.com/r/crazymax/flarum/) | `crazymax/flarum` |
| [GitHub Container Registry](https://github.com/users/crazy-max/packages/container/package/flarum) | `ghcr.io/crazy-max/flarum` |
| Registry | Image |
|---------------------------------------------------------------------------------------------------|----------------------------|
| [Docker Hub](https://hub.docker.com/r/crazymax/flarum/) | `crazymax/flarum` |
| [GitHub Container Registry](https://github.com/users/crazy-max/packages/container/package/flarum) | `ghcr.io/crazy-max/flarum` |

Following platforms for this image are available:

Expand Down Expand Up @@ -120,15 +120,20 @@ Image: crazymax/flarum:latest
* `DB_NOPREFIX`: Enforce no prefix for the MySQL database (default `false`)
* `DB_TIMEOUT`: Time in seconds after which we stop trying to reach the MySQL server (useful for clusters, default `60`)

> 💡 `DB_USER_FILE` and `DB_PASSWORD_FILE` can be used to fill in the value from a file, especially for Docker's
> secrets feature.
> **Note**
>
> `DB_USER_FILE` and `DB_PASSWORD_FILE` can be used to fill in the value from a
> file, especially for Docker's secrets feature.
## Volumes

* `/data`: Contains assets, extensions and storage

> :warning: Note that the volume should be owned by the user/group with the specified `PUID` and `PGID`. If you
> don't give the volume correct permissions, the container may not start.
> **Warning**
>
> Note that the volume should be owned by the user/group with the specified
> `PUID` and `PGID`. If you don't give the volume correct permissions, the
> container may not start.
## Ports

Expand All @@ -139,11 +144,11 @@ Image: crazymax/flarum: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:

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

### Command line
Expand All @@ -158,17 +163,18 @@ docker run -d -p 8000:8000 --name flarum \
crazymax/flarum:latest
```

> `-e "DB_HOST=db"`<br />
> :warning: `db` must be a running MySQL instance
> **Warning**
>
> `db` must be a running MySQL instance
## Upgrade

You can upgrade Flarum automatically through the UI, it works well. But I recommend to recreate the container
whenever I push an update:
You can upgrade Flarum automatically through the UI, it works well. But I
recommend to recreate the container whenever I push an update:

```bash
docker-compose pull
docker-compose up -d
docker compose pull
docker compose up -d
```

## Notes
Expand All @@ -186,20 +192,20 @@ On first launch, an initial administrator user will be created:
You can install [Flarum extensions](https://extiverse.com/) from the command line using a
[specially crafted script](rootfs/usr/local/bin/extension) with this image:

`docker-compose exec flarum extension require <package>`
`docker compose exec flarum extension require <package>`

To remove an extension:

`docker-compose exec flarum extension remove <package>`
`docker compose exec flarum extension remove <package>`

To list all extensions:

`docker-compose exec flarum extension list`
`docker compose exec flarum extension list`

Example with [`fof/upload`](https://extiverse.com/extension/fof/upload) extension:

```
$ docker-compose exec flarum extension require fof/upload
$ docker compose exec flarum extension require fof/upload
Using version ^1.0 for fof/upload
./composer.json has been updated
Running composer update fof/upload
Expand Down Expand Up @@ -232,12 +238,15 @@ fof/upload extension added
Clearing the cache...
```

> :warning: You cannot use [Bazaar marketplace extension](https://discuss.flarum.org/d/5151-bazaar-the-extension-marketplace)
> **Warning**
>
> You cannot use [Bazaar marketplace extension](https://discuss.flarum.org/d/5151-bazaar-the-extension-marketplace)
> to install extensions for now.
### Sending mails with SMTP

You can use our SMTP relay `msmtpd` service published on port `2500` and declared in our [`docker-compose.yml`](examples/compose/docker-compose.yml):
You can use our SMTP relay `msmtpd` service published on port `2500` and
declared in our [`compose.yml`](examples/compose/compose.yml):

![](.github/smtp-settings.png)

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

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

services:
traefik:
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: flarum

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

MYSQL_DATABASE=flarum
MYSQL_USER=flarum
MYSQL_PASSWORD=flarum
42 changes: 42 additions & 0 deletions test/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: flarum

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

flarum:
image: ${FLARUM_IMAGE:-crazymax/flarum}
container_name: ${FLARUM_CONTAINER:-flarum}
ports:
- target: 8000
published: 8000
protocol: tcp
depends_on:
- db
volumes:
- "./data:/data"
environment:
- "TZ"
- "PUID"
- "PGID"
- "DB_HOST=db"
- "DB_NAME=${MYSQL_DATABASE}"
- "DB_USER=${MYSQL_USER}"
- "DB_PASSWORD=${MYSQL_PASSWORD}"
env_file:
- "./flarum.env"
restart: always
9 changes: 9 additions & 0 deletions test/flarum.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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

FLARUM_DEBUG=false
FLARUM_BASE_URL=http://127.0.0.1:8000

0 comments on commit b29e937

Please sign in to comment.