Skip to content

Commit 04c5ed9

Browse files
authored
Merge pull request #980 from rust-lang/dockerfile-refurb
2 parents 0084d8f + 5e27318 commit 04c5ed9

File tree

12 files changed

+57
-357
lines changed

12 files changed

+57
-357
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -40,83 +40,16 @@ jobs:
4040
registry: ghcr.io
4141
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}"
4242
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}"
43-
- name: Build and push 'toolchain' container
44-
env:
45-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:toolchain"
46-
uses: docker/build-push-action@v4
47-
with:
48-
context: compiler/base/
49-
file: compiler/base/Dockerfile
50-
build-args: channel=${{ matrix.channel }}
51-
target: toolchain
52-
pull: true
53-
push: true
54-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
55-
cache-from: |-
56-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
57-
${{ env.TAG_PREFIX }}--latest
58-
cache-to: type=inline
59-
- name: Build and push 'bare-sources' container
60-
env:
61-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:bare-sources"
62-
uses: docker/build-push-action@v4
63-
with:
64-
context: compiler/base/
65-
file: compiler/base/Dockerfile
66-
build-args: channel=${{ matrix.channel }}
67-
target: bare-sources
68-
pull: true
69-
push: true
70-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
71-
cache-from: |-
72-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
73-
${{ env.TAG_PREFIX }}--latest
74-
cache-to: type=inline
75-
- name: Build and push 'munge' container
76-
env:
77-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:munge"
78-
uses: docker/build-push-action@v4
79-
with:
80-
context: compiler/base/
81-
file: compiler/base/Dockerfile
82-
build-args: channel=${{ matrix.channel }}
83-
target: munge
84-
pull: true
85-
push: true
86-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
87-
cache-from: |-
88-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
89-
${{ env.TAG_PREFIX }}--latest
90-
cache-to: type=inline
91-
- name: Build and push 'sources' container
92-
env:
93-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:sources"
94-
uses: docker/build-push-action@v4
95-
with:
96-
context: compiler/base/
97-
file: compiler/base/Dockerfile
98-
build-args: channel=${{ matrix.channel }}
99-
target: sources
100-
pull: true
101-
push: true
102-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
103-
cache-from: |-
104-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
105-
${{ env.TAG_PREFIX }}--latest
106-
cache-to: type=inline
10743
- name: Build and push container
10844
uses: docker/build-push-action@v4
10945
with:
11046
context: compiler/base/
11147
file: compiler/base/Dockerfile
11248
build-args: channel=${{ matrix.channel }}
113-
pull: true
11449
push: true
11550
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}"
116-
cache-from: |-
117-
${{ env.IMAGE_NAME }}:${{ github.run_id }}
118-
${{ env.IMAGE_NAME }}:latest
119-
cache-to: type=inline
51+
cache-from: type=gha,scope=${{ matrix.channel }}
52+
cache-to: type=gha,scope=${{ matrix.channel }},mode=max
12053
build_tool_containers:
12154
name: Build ${{ matrix.tool }} tool container
12255
runs-on: ubuntu-latest
@@ -150,14 +83,11 @@ jobs:
15083
with:
15184
context: compiler/${{ matrix.tool }}/
15285
file: compiler/${{ matrix.tool }}/Dockerfile
153-
build-args: base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:sources--${{ github.run_id }}
154-
pull: true
86+
build-args: base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:${{ github.run_id }}
15587
push: true
15688
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}"
157-
cache-from: |-
158-
${{ env.IMAGE_NAME }}:${{ github.run_id }}
159-
${{ env.IMAGE_NAME }}:latest
160-
cache-to: type=inline
89+
cache-from: type=gha,scope=${{ matrix.tool }}
90+
cache-to: type=gha,scope=${{ matrix.tool }},mode=max
16191
build_backend:
16292
name: Build backend
16393
runs-on: ubuntu-latest

.github/workflows/cron.yml

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -41,83 +41,16 @@ jobs:
4141
with:
4242
username: "${{ env.DOCKER_HUB_USERNAME }}"
4343
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
44-
- name: Build and push 'toolchain' container
45-
env:
46-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:toolchain"
47-
uses: docker/build-push-action@v4
48-
with:
49-
context: compiler/base/
50-
file: compiler/base/Dockerfile
51-
build-args: channel=${{ matrix.channel }}
52-
target: toolchain
53-
pull: true
54-
push: true
55-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
56-
cache-from: |-
57-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
58-
${{ env.TAG_PREFIX }}--latest
59-
cache-to: type=inline
60-
- name: Build and push 'bare-sources' container
61-
env:
62-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:bare-sources"
63-
uses: docker/build-push-action@v4
64-
with:
65-
context: compiler/base/
66-
file: compiler/base/Dockerfile
67-
build-args: channel=${{ matrix.channel }}
68-
target: bare-sources
69-
pull: true
70-
push: true
71-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
72-
cache-from: |-
73-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
74-
${{ env.TAG_PREFIX }}--latest
75-
cache-to: type=inline
76-
- name: Build and push 'munge' container
77-
env:
78-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:munge"
79-
uses: docker/build-push-action@v4
80-
with:
81-
context: compiler/base/
82-
file: compiler/base/Dockerfile
83-
build-args: channel=${{ matrix.channel }}
84-
target: munge
85-
pull: true
86-
push: true
87-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
88-
cache-from: |-
89-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
90-
${{ env.TAG_PREFIX }}--latest
91-
cache-to: type=inline
92-
- name: Build and push 'sources' container
93-
env:
94-
TAG_PREFIX: "${{ env.IMAGE_NAME }}:sources"
95-
uses: docker/build-push-action@v4
96-
with:
97-
context: compiler/base/
98-
file: compiler/base/Dockerfile
99-
build-args: channel=${{ matrix.channel }}
100-
target: sources
101-
pull: true
102-
push: true
103-
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}"
104-
cache-from: |-
105-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
106-
${{ env.TAG_PREFIX }}--latest
107-
cache-to: type=inline
10844
- name: Build and push container
10945
uses: docker/build-push-action@v4
11046
with:
11147
context: compiler/base/
11248
file: compiler/base/Dockerfile
11349
build-args: channel=${{ matrix.channel }}
114-
pull: true
11550
push: true
11651
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}"
117-
cache-from: |-
118-
${{ env.IMAGE_NAME }}:${{ github.run_id }}
119-
${{ env.IMAGE_NAME }}:latest
120-
cache-to: type=inline
52+
cache-from: type=gha,scope=${{ matrix.channel }}
53+
cache-to: type=gha,scope=${{ matrix.channel }},mode=max
12154
- name: Pull container
12255
run: docker pull ${{ env.IMAGE_NAME }}:${{ github.run_id }}
12356
- name: Rename container
@@ -165,14 +98,11 @@ jobs:
16598
with:
16699
context: compiler/${{ matrix.tool }}/
167100
file: compiler/${{ matrix.tool }}/Dockerfile
168-
build-args: base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:sources--${{ github.run_id }}
169-
pull: true
101+
build-args: base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:${{ github.run_id }}
170102
push: true
171103
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}"
172-
cache-from: |-
173-
${{ env.IMAGE_NAME }}:${{ github.run_id }}
174-
${{ env.IMAGE_NAME }}:latest
175-
cache-to: type=inline
104+
cache-from: type=gha,scope=${{ matrix.tool }}
105+
cache-to: type=gha,scope=${{ matrix.tool }},mode=max
176106
- name: Pull container
177107
run: docker pull ${{ env.IMAGE_NAME }}:${{ github.run_id }}
178108
- name: Rename container

ci/workflows.yml

Lines changed: 11 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -50,102 +50,19 @@ components:
5050
- build_compiler_containers_job_env: &build_compiler_containers_job_env
5151
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-rust-${{ matrix.channel }}
5252

53-
- build_compiler_containers_toolchain: &build_compiler_containers_toolchain
54-
name: "Build and push 'toolchain' container"
55-
env:
56-
TAG_PREFIX: ${{ env.IMAGE_NAME }}:toolchain
57-
uses: docker/build-push-action@v4
58-
with:
59-
context: compiler/base/
60-
file: compiler/base/Dockerfile
61-
build-args: |-
62-
channel=${{ matrix.channel }}
63-
target: toolchain
64-
pull: true
65-
push: true
66-
tags: |-
67-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
68-
cache-from: |-
69-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
70-
${{ env.TAG_PREFIX }}--latest
71-
cache-to: type=inline
72-
73-
- build_compiler_containers_bare_sources: &build_compiler_containers_bare_sources
74-
name: "Build and push 'bare-sources' container"
75-
env:
76-
TAG_PREFIX: ${{ env.IMAGE_NAME }}:bare-sources
77-
uses: docker/build-push-action@v4
78-
with:
79-
context: compiler/base/
80-
file: compiler/base/Dockerfile
81-
build-args: |-
82-
channel=${{ matrix.channel }}
83-
target: bare-sources
84-
pull: true
85-
push: true
86-
tags: |-
87-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
88-
cache-from: |-
89-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
90-
${{ env.TAG_PREFIX }}--latest
91-
cache-to: type=inline
92-
93-
- build_compiler_containers_munge: &build_compiler_containers_munge
94-
name: "Build and push 'munge' container"
95-
env:
96-
TAG_PREFIX: ${{ env.IMAGE_NAME }}:munge
97-
uses: docker/build-push-action@v4
98-
with:
99-
context: compiler/base/
100-
file: compiler/base/Dockerfile
101-
build-args: |-
102-
channel=${{ matrix.channel }}
103-
target: munge
104-
pull: true
105-
push: true
106-
tags: |-
107-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
108-
cache-from: |-
109-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
110-
${{ env.TAG_PREFIX }}--latest
111-
cache-to: type=inline
112-
113-
- build_compiler_containers_sources: &build_compiler_containers_sources
114-
name: "Build and push 'sources' container"
115-
env:
116-
TAG_PREFIX: ${{ env.IMAGE_NAME }}:sources
117-
uses: docker/build-push-action@v4
118-
with:
119-
context: compiler/base/
120-
file: compiler/base/Dockerfile
121-
build-args: |-
122-
channel=${{ matrix.channel }}
123-
target: sources
124-
pull: true
125-
push: true
126-
tags: |-
127-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
128-
cache-from: |-
129-
${{ env.TAG_PREFIX }}--${{ github.run_id }}
130-
${{ env.TAG_PREFIX }}--latest
131-
cache-to: type=inline
132-
133-
- build_compiler_containers_final: &build_compiler_containers_final
53+
- build_compiler_containers: &build_compiler_containers
13454
name: "Build and push container"
13555
uses: docker/build-push-action@v4
13656
with:
13757
context: compiler/base/
13858
file: compiler/base/Dockerfile
13959
build-args: |-
14060
channel=${{ matrix.channel }}
141-
pull: true
14261
push: true
14362
tags: |-
14463
${{ env.IMAGE_NAME }}:${{ github.run_id }}
145-
cache-from: |-
146-
${{ env.IMAGE_NAME }}:${{ github.run_id }}
147-
${{ env.IMAGE_NAME }}:latest
148-
cache-to: type=inline
64+
cache-from: type=gha,scope=${{ matrix.channel }}
65+
cache-to: type=gha,scope=${{ matrix.channel }},mode=max
14966

15067
- build_tool_containers_job: &build_tool_containers_job
15168
name: "Build ${{ matrix.tool }} tool container"
@@ -159,22 +76,19 @@ components:
15976
- build_tool_containers_job_env: &build_tool_containers_job_env
16077
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-tool-${{ matrix.tool }}
16178

162-
- build_tool_containers_final: &build_tool_containers_final
79+
- build_tool_containers: &build_tool_containers
16380
name: "Build and push container"
16481
uses: docker/build-push-action@v4
16582
with:
16683
context: compiler/${{ matrix.tool }}/
16784
file: compiler/${{ matrix.tool }}/Dockerfile
16885
build-args: |-
169-
base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:sources--${{ github.run_id }}
170-
pull: true
86+
base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:${{ github.run_id }}
17187
push: true
17288
tags: |-
17389
${{ env.IMAGE_NAME }}:${{ github.run_id }}
174-
cache-from: |-
175-
${{ env.IMAGE_NAME }}:${{ github.run_id }}
176-
${{ env.IMAGE_NAME }}:latest
177-
cache-to: type=inline
90+
cache-from: type=gha,scope=${{ matrix.tool }}
91+
cache-to: type=gha,scope=${{ matrix.tool }},mode=max
17892

17993
- pull_containers: &pull_containers
18094
name: "Pull containers"
@@ -236,11 +150,7 @@ workflows:
236150
- *checkout_pr
237151
- *docker_buildx
238152
- *login_ghcr
239-
- *build_compiler_containers_toolchain
240-
- *build_compiler_containers_bare_sources
241-
- *build_compiler_containers_munge
242-
- *build_compiler_containers_sources
243-
- *build_compiler_containers_final
153+
- *build_compiler_containers
244154

245155
build_tool_containers:
246156
<<: *build_tool_containers_job
@@ -252,7 +162,7 @@ workflows:
252162
- *checkout_pr
253163
- *docker_buildx
254164
- *login_ghcr
255-
- *build_tool_containers_final
165+
- *build_tool_containers
256166

257167
build_backend:
258168
name: "Build backend"
@@ -566,11 +476,7 @@ workflows:
566476
- *docker_buildx
567477
- *login_ghcr
568478
- *login_docker_hub
569-
- *build_compiler_containers_toolchain
570-
- *build_compiler_containers_bare_sources
571-
- *build_compiler_containers_munge
572-
- *build_compiler_containers_sources
573-
- *build_compiler_containers_final
479+
- *build_compiler_containers
574480

575481
- *pull_current_container
576482
- *rename_current_container
@@ -588,7 +494,7 @@ workflows:
588494
- *docker_buildx
589495
- *login_ghcr
590496
- *login_docker_hub
591-
- *build_tool_containers_final
497+
- *build_tool_containers
592498

593499
- *pull_current_container
594500
- *rename_current_container

0 commit comments

Comments
 (0)