Skip to content

Commit b89c0ea

Browse files
markmetcalfeDerschatta
authored andcommitted
Build images using github actions
1 parent 1bee22c commit b89c0ea

File tree

3 files changed

+130
-1
lines changed

3 files changed

+130
-1
lines changed

.github/workflows/build-image.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
image:
5+
required: true
6+
type: string
7+
context:
8+
required: true
9+
type: string
10+
dockerfile:
11+
required: false
12+
type: string
13+
default: 'Dockerfile'
14+
multiarch:
15+
required: false
16+
type: boolean
17+
default: true
18+
19+
jobs:
20+
build-image:
21+
name: Build ${{ inputs.image }} image
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
fetch-depth: 1
28+
- name: Log in to Docker Hub
29+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
30+
with:
31+
username: ${{ vars.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta
35+
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
36+
with:
37+
images: totara/docker-dev-${{ inputs.image }}
38+
# Adds tags for 'x.x.x' release version and 'multiarch' if multiarch
39+
tags: |
40+
type=semver,pattern={{version}}
41+
${{ inputs.multiarch == true && 'type=raw,multiarch' || '' }}
42+
- name: Set up QEMU (to support building for both amd64 and arm64)
43+
if: ${{ inputs.multiarch == true }}
44+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
47+
with:
48+
platforms: ${{ inputs.multiarch == true && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
49+
- name: Build and push images
50+
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
51+
with:
52+
context: ${{ inputs.context }}
53+
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
54+
push: true
55+
platforms: ${{ inputs.multiarch == true && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build docker-dev images upon a new release
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
build-apache-image:
10+
name: Build Apache image
11+
uses: ./.github/workflows/build-image.yml
12+
with:
13+
image: apache
14+
context: ./apache
15+
secrets: inherit
16+
17+
build-nginx-image:
18+
name: Build Nginx image
19+
uses: ./.github/workflows/build-image.yml
20+
with:
21+
image: nginx
22+
context: ./nginx
23+
secrets: inherit
24+
25+
build-mssql-images:
26+
name: Build MSSQL images
27+
strategy:
28+
matrix:
29+
version: [2017, 2019, 2022]
30+
uses: ./.github/workflows/build-image.yml
31+
with:
32+
image: mssql${{ matrix.version }}
33+
context: ./mssql
34+
dockerfile: ${{ matrix.version }}/Dockerfile
35+
multiarch: false # Mssql does not support multiple architectures
36+
secrets: inherit
37+
38+
build-php-images:
39+
name: Build PHP base images
40+
strategy:
41+
matrix:
42+
version: [53, 54, 55, 56, 70, 71, 72, 73, 80, 81, 82, 83]
43+
uses: ./.github/workflows/build-image.yml
44+
with:
45+
image: php${{ matrix.version }}
46+
context: ./php/php${{ matrix.version }}
47+
secrets: inherit
48+
49+
build-php-debug-images:
50+
name: Build PHP debug images
51+
needs: build-php-images
52+
strategy:
53+
matrix:
54+
version: [53, 54, 55, 56, 70, 71, 72, 73, 80, 81, 82, 83]
55+
uses: ./.github/workflows/build-image.yml
56+
with:
57+
image: php${{ matrix.version }}-debug
58+
context: ./php/php${{ matrix.version }}-debug
59+
secrets: inherit
60+
61+
build-php-cron-images:
62+
name: Build PHP cron images
63+
needs: build-php-images
64+
strategy:
65+
matrix:
66+
# Note: no cron container for v5.3
67+
version: [54, 55, 56, 70, 71, 72, 73, 80, 81, 82, 83]
68+
uses: ./.github/workflows/build-image.yml
69+
with:
70+
image: php${{ matrix.version }}-cron
71+
context: ./php/php${{ matrix.version }}-cron
72+
secrets: inherit

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Release](https://img.shields.io/github/v/release/totara/totara-docker-dev)](../../releases)
44
[![Release Date](https://img.shields.io/github/release-date/totara/totara-docker-dev)](../../releases)
5-
[![Build Status](https://travis-ci.com/totara/totara-docker-dev.svg?branch=master)](https://travis-ci.com/totara/totara-docker-dev)
5+
[![Build Status](https://img.shields.io/github/actions/workflow/status/totara/totara-docker-dev/release.yml)](../../actions/workflows/release.yml)
66
[![Issues](https://img.shields.io/github/issues/totara/totara-docker-dev)](../../issues)
77
[![License](https://img.shields.io/github/license/totara/totara-docker-dev)](../../LICENCE)
88

0 commit comments

Comments
 (0)