Skip to content

Commit 0358c0e

Browse files
committed
- Multistage build
- Introduced `compose.dev.yml` for local image building - Added `compose.prod.yml` to pull the published image from GitHub Container Registry
1 parent 2f7657f commit 0358c0e

5 files changed

Lines changed: 97 additions & 56 deletions

File tree

Dockerfile

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
1-
FROM php:8.4-fpm-alpine3.24
1+
FROM php:8.4-fpm-alpine3.24 AS builder
22

3-
RUN apk add --no-cache \
4-
curl \
5-
imagemagick \
6-
nginx \
7-
su-exec \
8-
netcat-openbsd \
9-
libpng \
10-
libjpeg-turbo \
11-
freetype \
12-
libzip \
13-
libpq \
14-
&& apk add --no-cache --virtual .build-deps \
3+
ENV PHPBB_VERSION=3.3.17
4+
ENV PHPBB_SHA256=b52fd231e612a099c0af1d2dcb73a79f7d03926a482842c4ee2830d12f461b67
5+
6+
RUN apk add --no-cache --virtual .build-deps \
157
$PHPIZE_DEPS \
168
libpng-dev \
179
libjpeg-turbo-dev \
1810
freetype-dev \
1911
libzip-dev \
20-
postgresql-dev \
2112
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
22-
&& docker-php-ext-install -j"$(nproc)" gd zip mysqli pdo_pgsql pgsql \
13+
&& docker-php-ext-install -j"$(nproc)" gd zip mysqli \
2314
&& apk del .build-deps
2415

25-
# phpBB
26-
ENV PHPBB_VERSION=3.3.17
27-
ENV PHPBB_SHA256=b52fd231e612a099c0af1d2dcb73a79f7d03926a482842c4ee2830d12f461b67
28-
29-
WORKDIR /tmp
30-
31-
RUN curl -fsSL "https://download.phpbb.com/pub/release/3.3/${PHPBB_VERSION}/phpBB-${PHPBB_VERSION}.tar.bz2" -o phpbb.tar.bz2 \
16+
RUN apk add --no-cache curl \
17+
&& curl -fsSL "https://download.phpbb.com/pub/release/3.3/${PHPBB_VERSION}/phpBB-${PHPBB_VERSION}.tar.bz2" -o phpbb.tar.bz2 \
3218
&& echo "${PHPBB_SHA256} phpbb.tar.bz2" | sha256sum -c - \
3319
&& tar -xjf phpbb.tar.bz2 \
3420
&& mkdir -p /phpbb/sqlite \
3521
&& mv phpBB3 /phpbb/www \
36-
&& rm -f phpbb.tar.bz2
22+
&& rm -rf phpbb.tar.bz2 \
23+
&& apk del curl
3724

38-
COPY phpbb/config.php /phpbb/www
3925

40-
RUN mkdir -p /run/nginx /phpbb/opcache \
41-
&& chown nginx:nginx /run/nginx /phpbb/opcache \
42-
&& rm -f /etc/nginx/http.d/default.conf
26+
FROM php:8.4-fpm-alpine3.24
27+
28+
RUN apk add --no-cache \
29+
nginx \
30+
su-exec \
31+
netcat-openbsd \
32+
libpng \
33+
libjpeg-turbo \
34+
freetype \
35+
libzip \
36+
&& rm -f /etc/nginx/http.d/default.conf \
37+
&& mkdir -p /run/nginx /phpbb/opcache \
38+
&& chown nginx:nginx /run/nginx /phpbb/opcache
39+
40+
COPY --from=builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
41+
COPY --from=builder /usr/local/etc/php/conf.d/docker-php-ext-gd.ini \
42+
/usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini \
43+
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini \
44+
/usr/local/etc/php/conf.d/
45+
COPY --from=builder /phpbb /phpbb
4346

47+
COPY phpbb/config.php /phpbb/www/
4448
COPY nginx/nginx.conf /etc/nginx/
4549
COPY nginx/http.d/* /etc/nginx/http.d/
4650
COPY php/php.ini php/php-cli.ini /usr/local/etc/php/

README.md

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,42 @@
22

33
Lightweight Alpine-based [phpBB](https://www.phpbb.com/) image with nginx and PHP 8.4 FPM.
44

5-
Bundled phpBB **3.3.17** with support for SQLite, MariaDB/MySQL (`mysqli`), and PostgreSQL.
5+
Published to GitHub Container Registry as [`ghcr.io/fed1337/docker-phpbb`](https://github.com/fed1337/docker-phpbb/pkgs/container/docker-phpbb).
66

7-
## Quick start with Docker Compose
7+
Bundled phpBB **3.3.17** with SQLite and MariaDB/MySQL (`mysqli`) support.
88

9-
The included `compose.yml` runs phpBB with MariaDB LTS:
9+
## Docker Compose
10+
11+
The stack is split into a shared base and two overlays:
12+
13+
| File | Purpose |
14+
| --- | --- |
15+
| `compose.yml` | Shared MariaDB + phpBB configuration |
16+
| `compose.dev.yml` | Build the image locally |
17+
| `compose.prod.yml` | Pull the published image from GHCR |
18+
19+
### Development (local build)
20+
21+
```console
22+
$ docker compose -f compose.yml -f compose.dev.yml up --build
23+
```
24+
25+
### Production (GHCR image)
1026

1127
```console
12-
$ docker compose up -d --build
28+
$ docker compose -f compose.yml -f compose.prod.yml up -d
1329
```
1430

15-
Open http://127.0.0.1:8000. For a fresh install, start once with the installer enabled:
31+
Pull a specific phpBB version tag instead of `latest`:
1632

1733
```console
18-
$ PHPBB_INSTALL=true docker compose up --build
34+
$ PHPBB_TAG=3.3.17 docker compose -f compose.yml -f compose.prod.yml up -d
35+
```
36+
37+
Open http://127.0.0.1:8000. For a fresh install, pass `PHPBB_INSTALL` once:
38+
39+
```console
40+
$ PHPBB_INSTALL=true docker compose -f compose.yml -f compose.dev.yml up --build
1941
```
2042

2143
During installation, use these database settings:
@@ -28,29 +50,39 @@ During installation, use these database settings:
2850
| Username | `phpbb` (or your `MARIADB_USER`) |
2951
| Password | `phpbb` (or your `MARIADB_PASSWORD`) |
3052

31-
Default MariaDB credentials can be overridden with environment variables:
53+
Default MariaDB credentials can be overridden:
3254

3355
- `MARIADB_ROOT_PASSWORD` (default: `changeme`)
3456
- `MARIADB_DATABASE` (default: `phpbb`)
3557
- `MARIADB_USER` (default: `phpbb`)
3658
- `MARIADB_PASSWORD` (default: `phpbb`)
3759

38-
After installation, restart without `PHPBB_INSTALL` so the `install/` directory is removed on startup. Optionally enable automatic migrations:
60+
After installation, restart without `PHPBB_INSTALL` so the `install/` directory is removed on startup:
3961

4062
```console
41-
$ docker compose up -d
42-
$ PHPBB_DB_AUTOMIGRATE=true docker compose up -d
63+
$ docker compose -f compose.yml -f compose.dev.yml up -d
4364
```
4465

45-
When `PHPBB_INSTALL` is not set in the environment, the startup script deletes `install/` automatically.
66+
Optionally enable automatic migrations:
4667

47-
## Standalone container
68+
```console
69+
$ PHPBB_DB_AUTOMIGRATE=true docker compose -f compose.yml -f compose.dev.yml up -d
70+
```
4871

49-
Build and run the image without Compose:
72+
## Image tags
73+
74+
GitHub Actions publishes to GHCR on manual workflow dispatch. Tags track the phpBB version from the `Dockerfile`:
75+
76+
- `3.3.17` — patch (full phpBB version)
77+
- `3.3` — minor
78+
- `3` — major
79+
- `latest`
80+
81+
## Standalone container
5082

5183
```console
52-
$ docker build -t phpbb .
53-
$ docker run -p 8000:80 --name phpbb-install -e PHPBB_INSTALL=true -d phpbb
84+
$ docker pull ghcr.io/fed1337/docker-phpbb:latest
85+
$ docker run -p 8000:80 --name phpbb-install -e PHPBB_INSTALL=true -d ghcr.io/fed1337/docker-phpbb:latest
5486
```
5587

5688
By default the standalone image uses SQLite. Set the DSN field to `/phpbb/sqlite/sqlite.db` during installation and leave username, password, and database name blank.
@@ -65,7 +97,7 @@ $ docker run --name phpbb \
6597
-e PHPBB_DB_NAME=phpbb \
6698
-e PHPBB_DB_USER=phpbb \
6799
-e PHPBB_DB_PASSWD=pass \
68-
-p 8000:80 -d phpbb
100+
-p 8000:80 -d ghcr.io/fed1337/docker-phpbb:latest
69101
```
70102

71103
## Environment variables
@@ -74,11 +106,11 @@ Most variables are written into phpBB's `config.php` or read by the startup scri
74106

75107
### PHPBB_INSTALL
76108

77-
If `true`, removes `config.php` and keeps the `/install/` directory for a fresh setup.
109+
If `true`, removes `config.php` and keeps the `/install/` directory for a fresh setup. When unset, the startup script deletes `install/` automatically.
78110

79111
### PHPBB_DB_DRIVER
80112

81-
Supported drivers in this image: `sqlite3`, `mysqli`, `postgres`.
113+
Supported drivers: `sqlite3`, `mysqli`.
82114

83115
Default: `sqlite3`
84116

@@ -127,14 +159,14 @@ Persistent data paths:
127159
$ ./update.sh 3.3
128160
```
129161

130-
This updates `PHPBB_VERSION` and its checksum in the `Dockerfile`.
162+
This updates `PHPBB_VERSION` and its checksum in the `Dockerfile`, then rebuild and run the [release workflow](.github/workflows/release.yml) to publish new GHCR tags.
131163

132164
## Custom configuration
133165

134-
Drop PHP settings into `/usr/local/etc/php/conf.d` and nginx site config into `/etc/nginx/http.d` by extending the image:
166+
Extend the image to add PHP or nginx settings:
135167

136168
```dockerfile
137-
FROM your-image/phpbb:latest
169+
FROM ghcr.io/fed1337/docker-phpbb:latest
138170

139171
COPY custom.ini /usr/local/etc/php/conf.d/
140172
COPY custom.conf /etc/nginx/http.d/

compose.dev.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
phpbb:
3+
build: .

compose.prod.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
phpbb:
3+
image: ghcr.io/fed1337/docker-phpbb:${PHPBB_TAG:-latest}

compose.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
volumes:
2-
mariadb-data: {}
3-
phpbb-files: {}
4-
phpbb-store: {}
5-
phpbb-avatars: {}
6-
71
services:
82
mariadb:
93
image: mariadb:lts
@@ -23,7 +17,6 @@ services:
2317
start_period: 10s
2418

2519
phpbb:
26-
build: .
2720
restart: unless-stopped
2821
depends_on:
2922
mariadb:
@@ -35,7 +28,7 @@ services:
3528
- phpbb-store:/phpbb/www/store
3629
- phpbb-avatars:/phpbb/www/images/avatars/upload
3730
environment:
38-
- PHPBB_INSTALL=${MARIADB_DATABASE:-}
31+
- PHPBB_INSTALL
3932
- PHPBB_DB_AUTOMIGRATE
4033
- PHPBB_DB_DRIVER=mysqli
4134
- PHPBB_DB_HOST=mariadb
@@ -44,3 +37,9 @@ services:
4437
- PHPBB_DB_USER=${MARIADB_USER:-phpbb}
4538
- PHPBB_DB_PASSWD=${MARIADB_PASSWORD:-phpbb}
4639
- PHPBB_DB_WAIT=true
40+
41+
volumes:
42+
mariadb-data: {}
43+
phpbb-files: {}
44+
phpbb-store: {}
45+
phpbb-avatars: {}

0 commit comments

Comments
 (0)