Skip to content

Commit 482a706

Browse files
author
Ware, Joseph (DLSLtd,RAL,LSCI)
committed
Publish debug container only if requested
1 parent 2128109 commit 482a706

File tree

5 files changed

+70
-21
lines changed

5 files changed

+70
-21
lines changed

.github/workflows/_container.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,6 @@ jobs:
5050
type=ref,event=tag
5151
type=raw,value=latest
5252
53-
- name: Create tags for publishing debug image
54-
id: debug-meta
55-
uses: docker/metadata-action@v5
56-
with:
57-
images: ghcr.io/${{ github.repository }}
58-
tags: |
59-
type=ref,event=tag,suffix=-debug
60-
type=raw,value=latest-debug
61-
62-
- name: Build and publish debug image to container registry
63-
if: github.ref_type == 'tag'
64-
uses: docker/build-push-action@v6
65-
env:
66-
DOCKER_BUILD_RECORD_UPLOAD: false
67-
with:
68-
context: .
69-
push: true
70-
target: debug
71-
tags: ${{ steps.debug-meta.outputs.tags }}
72-
7353
- name: Push cached image to container registry
7454
if: inputs.publish && github.ref_type == 'tag'
7555
uses: docker/build-push-action@v6

copier.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ docker:
103103
Would you like to publish your project in a Docker container?
104104
You should select this if you are making a service.
105105
106+
docker_debug:
107+
type: bool
108+
when: "{{ docker }}"
109+
help: |
110+
Would you like to publish a debug image of your service?
111+
This will increase the number of published images, but may
112+
be useful if debugging the service inside of the cluster
113+
infrastructure is required.
114+
106115
docs_type:
107116
type: str
108117
help: |

template/Dockerfile.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ COPY --chmod=o+wrX . /workspaces/{{ repo_name }}
1919
WORKDIR /workspaces/{{ repo_name }}
2020
RUN touch dev-requirements.txt && pip install -c dev-requirements.txt .
2121

22+
{% if docker_debug %}
2223
FROM build AS debug
2324

2425
{% if git_platform=="github.com" %}
@@ -39,6 +40,7 @@ RUN pip install -e .
3940
ENTRYPOINT [ "/bin/bash", "-c", "--" ]
4041
CMD [ "while true; do sleep 30; done;" ]
4142

43+
{% endif %}
4244
# The runtime stage copies the built venv into a slim runtime container
4345
FROM python:${PYTHON_VERSION}-slim AS runtime
4446
# Add apt-get system dependecies for runtime here if needed

template/{% if git_platform=="github.com" %}.github{% endif %}/workflows/ci.yml.jinja

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ jobs:
4141
permissions:
4242
contents: read
4343
packages: write
44-
{% endraw %}{% endif %}{% if sphinx %}
44+
{% endraw %}{% if docker_debug %}{% raw %}
45+
debug_container:
46+
needs: [container, test]
47+
uses: ./.github/workflows/_debug_container.yml
48+
with:
49+
publish: ${{ needs.test.result == 'success' }}
50+
permissions:
51+
contents: read
52+
packages: write
53+
{% endraw %}{% endif %}{% endif %}{% if sphinx %}
4554
docs:
4655
uses: ./.github/workflows/_docs.yml
4756

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
publish:
5+
type: boolean
6+
description: If true, pushes image to container registry
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
# Need this to get version number from last tag
17+
fetch-depth: 0
18+
19+
- name: Set up Docker Buildx
20+
id: buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log in to GitHub Docker Registry
24+
if: github.event_name != 'pull_request'
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Create tags for publishing debug image
32+
id: debug-meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}
36+
tags: |
37+
type=ref,event=tag,suffix=-debug
38+
type=raw,value=latest-debug
39+
40+
- name: Build and publish debug image to container registry
41+
if: github.ref_type == 'tag'
42+
uses: docker/build-push-action@v6
43+
env:
44+
DOCKER_BUILD_RECORD_UPLOAD: false
45+
with:
46+
context: .
47+
push: true
48+
target: debug
49+
tags: ${{ steps.debug-meta.outputs.tags }}

0 commit comments

Comments
 (0)