Skip to content

Commit fe69e99

Browse files
committed
First cut to moodle-php-apache multiarch builder
First attempt to switch the automated building of moodle-php-apache images from DockerHub to GHA. Main reason being that the former doesn't support multiarch builds (only multiarch storage). Link: docker/hub-feedback#1874 Experimentally we'll be, also, sending the images to both DockerHub and GitHub registries in case we need to switch some day. This requires: 1. Some secrets to be created: - DOCKERHUB_USERNAME - DOCKERHUB_TOKEN (write perms) - DOCKERHUB_PASSWORD, grrr, descriptions cannot be updated using PATs, see peter-evans/dockerhub-description#10 - GH_USERNAME 2. Autobuilds @ DockerHub to be disabled (this takes exactly on them)
1 parent 0c2f2c7 commit fe69e99

File tree

2 files changed

+86
-7
lines changed

2 files changed

+86
-7
lines changed
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Docker multiarch publish
2+
3+
on: push
4+
5+
env:
6+
REPOSITORY: moodle-php-apache
7+
DOCKERHUB_OWNER: moodlehq
8+
GH_OWNER: moodlehq
9+
10+
jobs:
11+
Build:
12+
# Completely avoid forks to try this workflow.
13+
if: github.repository_owner == 'moodlehq'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
# Calculate the tags to be pussed to the registries.
20+
- name: Calculate image tag names
21+
id: calculatetags
22+
uses: docker/metadata-action@v3
23+
with:
24+
images: |
25+
${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}
26+
ghcr.io/${{ env.GH_OWNER }}/${{ env.REPOSITORY }}
27+
flavor: |
28+
latest=false
29+
tags: |
30+
type=raw,value=dev
31+
32+
# https://github.com/docker/setup-qemu-action#usage
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v1
35+
36+
# https://github.com/marketplace/actions/docker-setup-buildx
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v1
39+
40+
# https://github.com/docker/login-action#docker-hub
41+
- name: Login to Docker Hub
42+
uses: docker/login-action@v1
43+
with:
44+
username: ${{ secrets.DOCKERHUB_USERNAME }}
45+
password: ${{ secrets.DOCKERHUB_TOKEN }}
46+
47+
# https://github.com/docker/login-action#github-container-registry
48+
- name: Login to GitHub Container Registry
49+
uses: docker/login-action@v1
50+
with:
51+
registry: ghcr.io
52+
username: ${{ secrets.GH_USERNAME }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
# https://github.com/docker/build-push-action#multi-platform-image
56+
- name: Build and push to Docker Hub and Github registries
57+
uses: docker/build-push-action@v2
58+
with:
59+
context: .
60+
file: Dockerfile
61+
platforms: linux/amd64,linux/arm64
62+
push: true
63+
tags: ${{ steps.calculatetags.outputs.tags }}
64+
65+
# https://github.com/peter-evans/dockerhub-description
66+
# It's horrible that we need to use password here instead of PAT, because
67+
# that's only available via CLI what defeats 2FA. Anyway, we need to
68+
# auto-update de description, so using it (till available via PAT).
69+
# Link: https://github.com/peter-evans/dockerhub-description/issues/10
70+
# Note that we only update the description with the master branch version.
71+
- name: Set Docker Hub description from README.md
72+
if: github.ref == 'refs/heads/master'
73+
uses: peter-evans/dockerhub-description@v2
74+
with:
75+
username: ${{ secrets.DOCKERHUB_USERNAME }}
76+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
77+
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,31 @@ A Moodle PHP environment configured for Moodle development based on [Official PH
2020
| PHP 7.0 | Jessie | 7.0-jessie | [![Build Status](https://travis-ci.com/moodlehq/moodle-php-apache.svg?branch=7.0-jessie)](https://travis-ci.com/moodlehq/moodle-php-apache)|Jessie and PHP 7.0 EOL|
2121
| PHP 5.6 | Jessie | 5.6-jessie | [![Build Status](https://travis-ci.com/moodlehq/moodle-php-apache.svg?branch=5.6-jessie)](https://travis-ci.com/moodlehq/moodle-php-apache)|Jessie and PHP 5.6 EOL|
2222

23-
# Example usage
23+
## Example usage
2424
The following command will expose the current working directory on port 8080:
2525
```bash
2626
$ docker run --name web0 -p 8080:80 -v $PWD:/var/www/html moodlehq/moodle-php-apache:7.1
2727
```
2828

29-
# Features
30-
29+
## Features
3130
* Preconfigured with all php extensions required for Moodle development and all database drivers
3231
* Serves wwroot configured at /var/www/html/
33-
* Verified by [automated tests](https://travis-ci.com/moodlehq/moodle-php-apache)
34-
35-
# Directories
32+
* For PHP 7.3 and up, both `linux/amd64` and `linux/arm64` images are being built. Note that `linux/arm64` doesn't support the sqlsrv and oci extensions yet. Other than that, both architectures work exactly the same.
33+
* Verified by [automated tests](https://travis-ci.com/moodlehq/moodle-php-apache).
34+
* Autobuilt from GHA, on push.
3635

36+
## Directories
3737
To faciliate testing and easy setup the following directories are created and owned by www-data by default:
38+
3839
* `/var/www/moodledata`
3940
* `/var/www/phpunitdata`
4041
* `/var/www/behatdata`
4142
* `/var/www/behatfaildumps`
4243

4344

44-
# See also
45+
## See also
4546
This container is part of a set of containers for Moodle development, see also:
47+
4648
* [moodle-docker](https://github.com/moodlehq/moodle-docker) a docker-composer based set of tools to get Moodle development running with zero configuration
4749
* [moodle-db-mssql](https://github.com/moodlehq/moodle-db-mssql) Microsoft SQL Server for Linux configured for Moodle development
4850
* [moodle-db-oracle](https://github.com/moodlehq/moodle-db-oracle) Oracle XE configured for Moodle development

0 commit comments

Comments
 (0)