File tree Expand file tree Collapse file tree 6 files changed +71
-21
lines changed
{% if git_platform=="github.com" %}.github{% endif %}/workflows Expand file tree Collapse file tree 6 files changed +71
-21
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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+
106115docs_type :
107116 type : str
108117 help : |
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ component_lifecycle: experimental
66description : An expanded https://github.com/DiamondLightSource/python-copier-template to illustrate how it looks with all the options enabled.
77distribution_name : dls-python-copier-template-example
88docker : true
9+ docker_debug : true
910docs_type : sphinx
1011git_platform : github.com
1112github_org : DiamondLightSource
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ COPY --chmod=o+wrX . /workspaces/{{ repo_name }}
1919WORKDIR /workspaces/{{ repo_name }}
2020RUN touch dev-requirements.txt && pip install -c dev-requirements.txt .
2121
22+ {% if docker_debug %}
2223FROM build AS debug
2324
2425{% if git_platform =="github.com" %}
@@ -39,6 +40,7 @@ RUN pip install -e .
3940ENTRYPOINT [ "/bin/bash", "-c", "--" ]
4041CMD [ "while true; do sleep 30; done;" ]
4142
43+ {% endif %}
4244# The runtime stage copies the built venv into a slim runtime container
4345FROM python:${PYTHON_VERSION}-slim AS runtime
4446# Add apt-get system dependecies for runtime here if needed
Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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 }}
You can’t perform that action at this time.
0 commit comments