Skip to content

Commit afb260c

Browse files
committed
Split dockerfiles into versioned and sha'ed
This is definitely not going to work first time...
1 parent 6bc0c0f commit afb260c

File tree

10 files changed

+349
-165
lines changed

10 files changed

+349
-165
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "Build Base Image"
2+
description: "Builds the correct base image depending on the idris version"
3+
4+
inputs:
5+
idris-version:
6+
description: "The Idris version to build"
7+
required: false
8+
default: "latest"
9+
push:
10+
description: "Whether to push the image to Docker Hub"
11+
required: false
12+
default: false
13+
load:
14+
description: "Whether to load the image into the local Docker daemon"
15+
required: false
16+
default: false
17+
tags:
18+
description: "The tag to use for the image"
19+
required: false
20+
default: idris-base-img
21+
labels:
22+
description: "The labels to apply to the image"
23+
required: false
24+
default: ""
25+
platforms:
26+
description: "The platforms to build for"
27+
required: false
28+
default: "linux/amd64"
29+
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Get Latest Idris Commit SHA
34+
id: get-sha
35+
uses: ./.github/actions/get-idris-sha
36+
37+
- name: Build Base (versioned)
38+
uses: docker/[email protected]
39+
if: ${{ inputs.idris-version != 'latest' }}
40+
with:
41+
context: .
42+
platforms: ${{ inputs.platforms }}
43+
file: base.Dockerfile
44+
build-args: |
45+
IDRIS_VERSION=${{ inputs.idris-version }}
46+
tags: ${{ inputs.tags }}
47+
load: ${{ inputs.load }}
48+
push: ${{ inputs.push }}
49+
labels: ${{ inputs.labels }}
50+
# When doing matrix builds, we need to scope the image
51+
# https://github.com/moby/buildkit/issues/2885
52+
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
53+
cache-to: type=gha,mode=max,scope=build-base-${{ inputs.idris-version }}
54+
55+
- name: Build Base (latest)
56+
uses: docker/[email protected]
57+
if: ${{ inputs.idris-version == 'latest' }}
58+
with:
59+
context: .
60+
platforms: ${{ inputs.platforms }}
61+
file: base-sha.Dockerfile
62+
build-args: |
63+
IDRIS_VERSION=${{ inputs.idris-version }}
64+
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
65+
tags: ${{ inputs.tags }}
66+
load: ${{ inputs.load }}
67+
push: ${{ inputs.push }}
68+
labels: ${{ inputs.labels }}
69+
# When doing matrix builds, we need to scope the image
70+
# https://github.com/moby/buildkit/issues/2885
71+
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
72+
cache-to: type=gha,mode=max,scope=build-base-${{ inputs.idris-version }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: "Build Base Image"
2+
description: "Builds the correct base image depending on the idris version"
3+
4+
inputs:
5+
idris-lsp-version:
6+
description: "The Idris version to build"
7+
required: false
8+
default: "latest"
9+
idris-version:
10+
description: "The Idris version to build"
11+
required: false
12+
default: "latest"
13+
base-img:
14+
description: "Tag of the base image to use. Should be from base.Dockerfile"
15+
required: true
16+
push:
17+
description: "Whether to push the image to Docker Hub"
18+
required: false
19+
default: false
20+
load:
21+
description: "Whether to load the image into the local Docker daemon"
22+
required: false
23+
default: false
24+
tags:
25+
description: "The tag to use for the image"
26+
required: false
27+
default: idris-devcontainer-img
28+
labels:
29+
description: "The labels to apply to the image"
30+
required: false
31+
default: ""
32+
platforms:
33+
description: "The platforms to build for"
34+
required: false
35+
default: "linux/amd64"
36+
37+
runs:
38+
using: composite
39+
steps:
40+
- name: Get Latest Idris Commit SHA
41+
id: get-sha
42+
uses: ./.github/actions/get-idris-sha
43+
44+
- name: Build Devcontainer (versioned)
45+
if: ${{ inputs.idris-lsp-version != 'latest' }}
46+
uses: docker/[email protected]
47+
with:
48+
context: .
49+
file: devcontainer.Dockerfile
50+
platforms: ${{ inputs.platforms }}
51+
build-args: |
52+
IDRIS_LSP_VERSION=${{ inputs.idris-lsp-version }}
53+
IDRIS_VERSION=${{ inputs.idris-version }}
54+
BASE_IMG=${{ inputs.base-img }}
55+
tags: ${{ inputs.tags }}
56+
load: ${{ inputs.load }}
57+
push: ${{ inputs.push }}
58+
labels: ${{ inputs.labels }}
59+
cache-from: type=gha,scope=build-devcontainer-${{ inputs.idris-lsp-version }}
60+
cache-to: type=gha,mode=max,scope=build-devcontainer-${{ inputs.idris-lsp-version }}
61+
62+
- name: Build Devcontainer (latest)
63+
if: ${{ inputs.idris-lsp-version == 'latest' }}
64+
uses: docker/[email protected]
65+
with:
66+
context: .
67+
file: devcontainer-sha.Dockerfile
68+
platforms: ${{ inputs.platforms }}
69+
build-args: |
70+
IDRIS_LSP_VERSION=${{ inputs.idris-lsp-version }}
71+
IDRIS_LSP_SHA=${{ steps.get-sha.outputs.lsp-sha }}
72+
IDRIS_VERSION=${{ inputs.idris-version }}
73+
IDRIS_SHA=${{ steps.get-sha.outputs.idris-sha }}
74+
BASE_IMG=${{ inputs.base-img }}
75+
tags: ${{ inputs.tags }}
76+
load: ${{ inputs.load }}
77+
push: ${{ inputs.push }}
78+
labels: ${{ inputs.labels }}
79+
cache-from: type=gha,scope=build-devcontainer-${{ inputs.idris-lsp-version }}
80+
cache-to: type=gha,mode=max,scope=build-devcontainer-${{ inputs.idris-lsp-version }}

.github/workflows/version-base-build-test.yml

Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,10 @@ jobs:
3535
- name: Test docker buildx
3636
run: docker buildx ls
3737

38-
- name: Get Latest Idris Commit SHA
39-
id: get-sha
40-
uses: ./.github/actions/get-idris-sha
41-
42-
# mainly just for caching purposes - makes it faster to build later on
43-
# build in arm (or my oracle server) as well so we can make the most use of our time in the build step
44-
- name: Build Base
45-
uses: docker/[email protected]
38+
- name: Build Base Image
39+
uses: ./.github/actions/build-base-img
4640
with:
47-
context: .
48-
platforms: linux/amd64,linux/arm64
49-
file: base.Dockerfile
50-
build-args: |
51-
IDRIS_VERSION=${{ inputs.idris-version }}
52-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
53-
# When doing matrix builds, we need to scope the image
54-
# https://github.com/moby/buildkit/issues/2885
55-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
56-
cache-to: type=gha,mode=max,scope=build-base-${{ inputs.idris-version }}
41+
idris-version: ${{ inputs.idris-version }}
5742

5843
base-test-1:
5944
name: Test 1 Base
@@ -67,22 +52,13 @@ jobs:
6752

6853
- name: Set up Docker Buildx
6954
uses: docker/setup-buildx-action@v2
70-
71-
- name: Get Latest Idris Commit SHA
72-
id: get-sha
73-
uses: ./.github/actions/get-idris-sha
74-
75-
- name: Build Base
76-
uses: docker/[email protected]
55+
56+
- name: Build Base Image
57+
uses: ./.github/actions/build-base-img
7758
with:
78-
context: .
79-
file: base.Dockerfile
80-
build-args: |
81-
IDRIS_VERSION=${{ inputs.idris-version }}
82-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
59+
idris-version: ${{ inputs.idris-version }}
60+
load: true
8361
tags: ${{ env.TAG }}
84-
load: true
85-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
8662

8763
- name: Setup Bats and Bats libs
8864
uses: brokenpip3/[email protected]
@@ -115,23 +91,14 @@ jobs:
11591

11692
- name: Set up Docker Buildx
11793
uses: docker/setup-buildx-action@v2
118-
119-
- name: Get Latest Idris Commit SHA
120-
id: get-sha
121-
uses: ./.github/actions/get-idris-sha
122-
123-
- name: Build Base
124-
uses: docker/[email protected]
94+
95+
- name: Build Base Image
96+
uses: ./.github/actions/build-base-img
12597
with:
126-
context: .
127-
file: base.Dockerfile
128-
build-args: |
129-
IDRIS_VERSION=${{ inputs.idris-version }}
130-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
98+
idris-version: ${{ inputs.idris-version }}
99+
load: true
131100
tags: ${{ env.TAG }}
132-
load: true
133-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
134-
101+
135102
- name: Run Test
136103
run: |
137104
docker run ${{ env.TAG }} /bin/bash -c "make test"
@@ -165,23 +132,13 @@ jobs:
165132
with:
166133
# since we're using a local registry
167134
driver-opts: network=host
168-
169-
- name: Get Latest Idris Commit SHA
170-
id: get-sha
171-
uses: ./.github/actions/get-idris-sha
172-
173-
- name: Build Base
174-
uses: docker/[email protected]
135+
136+
- name: Build Base Image
137+
uses: ./.github/actions/build-base-img
175138
with:
176-
context: .
177-
file: base.Dockerfile
178-
build-args: |
179-
IDRIS_VERSION=${{ inputs.idris-version }}
180-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
181-
tags: ${{ env.BASE_TAG }}
182-
# push to local registry
139+
idris-version: ${{ inputs.idris-version }}
183140
push: true
184-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
141+
tags: ${{ env.BASE_TAG }}
185142

186143
- name: Run `docker image ls`
187144
run: docker image ls

.github/workflows/version-base-deploy.yml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,20 @@ jobs:
3939
username: ${{ github.actor }}
4040
password: ${{ secrets.GITHUB_TOKEN }}
4141

42-
- name: Get Latest Idris Commit SHA
43-
id: get-sha
44-
uses: ./.github/actions/get-idris-sha
45-
4642
- name: Docker meta
4743
id: create-meta
4844
uses: docker/metadata-action@v4
4945
with:
5046
images: ${{ github.repository }}/base
5147

52-
- name: Build Base
53-
uses: docker/build-[email protected]
48+
- name: Build Base Image
49+
uses: ./.github/actions/build-base-img
5450
with:
55-
context: .
56-
platforms: linux/amd64,linux/arm64
57-
file: base.Dockerfile
58-
build-args: |
59-
IDRIS_VERSION=${{ inputs.idris-version }}
60-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
51+
idris-version: ${{ inputs.idris-version }}
52+
push: true
6153
tags: ghcr.io/${{ github.repository }}/base:${{ inputs.idris-version }}
6254
labels: ${{ steps.create-meta.outputs.labels }}
63-
push: true
64-
# When doing matrix builds, we need to scope the image
65-
# https://github.com/moby/buildkit/issues/2885
66-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
55+
platforms: linux/amd64,linux/arm64
6756

6857
deploy-consumers:
6958
name: Deploy Consumer - ${{ matrix.dockerfile }} ${{ inputs.idris-version }}
@@ -99,28 +88,18 @@ jobs:
9988
username: ${{ github.actor }}
10089
password: ${{ secrets.GITHUB_TOKEN }}
10190

102-
- name: Get Latest Idris Commit SHA
103-
id: get-sha
104-
uses: ./.github/actions/get-idris-sha
105-
106-
- name: Build Base
107-
uses: docker/[email protected]
91+
- name: Build Base Image
92+
uses: ./.github/actions/build-base-img
10893
with:
109-
context: .
110-
file: base.Dockerfile
111-
build-args: |
112-
IDRIS_VERSION=${{ inputs.idris-version }}
113-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
114-
tags: ${{ env.BASE_TAG }}
115-
# push to local registry
94+
idris-version: ${{ inputs.idris-version }}
11695
push: true
117-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
96+
tags: ${{ env.BASE_TAG }}
11897

11998
- name: Docker meta
12099
id: create-meta
121100
uses: docker/metadata-action@v4
122101
with:
123-
images: ${{ github.repository }}/base
102+
images: ${{ github.repository }}/${{ matrix.dockerfile }}
124103

125104
- name: Build ${{ matrix.dockerfile}}
126105
uses: docker/[email protected]

.github/workflows/version-devcontainer-build-test.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,25 @@ jobs:
3535
with:
3636
# since we're using a local registry
3737
driver-opts: network=host
38-
39-
- name: Get Latest Idris Commit SHA
40-
id: get-sha
41-
uses: ./.github/actions/get-idris-sha
4238

43-
# Building base because devcontainer image depends on it for idris binary
44-
# only using cache-from because this should already be cached (we won't be writing to cache)
45-
- name: Build Base
46-
uses: docker/[email protected]
39+
- name: Build Base Image
40+
uses: ./.github/actions/build-base-img
4741
with:
48-
context: .
49-
file: base.Dockerfile
50-
build-args: |
51-
IDRIS_VERSION=${{ inputs.idris-version }}
52-
IDRIS_SHA=${{ steps.get-sha.outputs.sha }}
53-
tags: ${{ env.BASE_TAG }}
54-
# push to local registry
42+
idris-version: ${{ inputs.idris-version }}
5543
push: true
56-
cache-from: type=gha,scope=build-base-${{ inputs.idris-version }}
57-
44+
tags: ${{ env.BASE_TAG }}
45+
5846
- name: Run `docker image ls`
5947
run: docker image ls
60-
61-
- name: Build Devcontainer
62-
uses: docker/build-[email protected]
48+
49+
- name: Build Devcontainer Image
50+
uses: ./.github/actions/build-devcontainer-img
6351
with:
64-
context: .
65-
file: devcontainer.Dockerfile
66-
build-args: |
67-
IDRIS_LSP_VERSION=${{ inputs.idris-lsp-version }}
68-
IDRIS_LSP_SHA=${{ steps.get-sha.outputs.lsp-sha }}
69-
IDRIS_VERSION=${{ inputs.idris-version }}
70-
IDRIS_SHA=${{ steps.get-sha.outputs.idris-sha }}
71-
BASE_IMG=${{ env.BASE_TAG }}
52+
idris-lsp-version: ${{ inputs.idris-lsp-version }}
53+
idris-version: ${{ inputs.idris-version }}
7254
load: true
73-
tags: ${{ env.TAG }}
74-
cache-from: type=gha,scope=build-devcontainer-${{ inputs.idris-lsp-version }}
75-
cache-to: type=gha,mode=max,scope=build-devcontainer-${{ inputs.idris-lsp-version }}
76-
55+
tags: ${{ env.TAG }}
56+
base-tag: ${{ env.BASE_TAG }}
7757

7858
- name: Setup Bats and Bats libs
7959
uses: brokenpip3/[email protected]

0 commit comments

Comments
 (0)