Skip to content

Commit 09e8117

Browse files
committed
1 parent d103266 commit 09e8117

5 files changed

Lines changed: 86 additions & 4 deletions

File tree

.copier-answers.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 4.0.1-2-g5294bde
2+
_commit: 4.1.0
33
_src_path: https://github.com/DiamondLightSource/python-copier-template.git
44
author_email: tom.cobb@diamond.ac.uk
55
author_name: Tom Cobb
@@ -10,6 +10,7 @@ description: An expanded https://github.com/DiamondLightSource/python-copier-tem
1010
to illustrate how it looks with all the options enabled.
1111
distribution_name: dls-python-copier-template-example
1212
docker: true
13+
docker_debug: true
1314
docs_type: sphinx
1415
git_platform: github.com
1516
github_org: DiamondLightSource

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua
2424

2525
This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.
2626

27-
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/4.0.1/how-to.html).
27+
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/4.1.0/how-to.html).
Lines changed: 49 additions & 0 deletions
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 }}

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ jobs:
4242
contents: read
4343
packages: write
4444

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+
4554
docs:
4655
uses: ./.github/workflows/_docs.yml
4756

Dockerfile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,33 @@ ENV PATH=/venv/bin:$PATH
1414

1515
# The build stage installs the context into the venv
1616
FROM developer AS build
17-
COPY . /context
18-
WORKDIR /context
17+
# Requires buildkit 0.17.0
18+
COPY --chmod=o+wrX . /workspaces/python-copier-template-example
19+
WORKDIR /workspaces/python-copier-template-example
1920
RUN touch dev-requirements.txt && pip install -c dev-requirements.txt .
2021

22+
23+
FROM build AS debug
24+
25+
26+
# Set origin to use ssh
27+
RUN git remote set-url origin git@github.com:DiamondLightSource/python-copier-template-example.git
28+
29+
30+
# For this pod to understand finding user information from LDAP
31+
RUN apt update
32+
RUN DEBIAN_FRONTEND=noninteractive apt install libnss-ldapd -y
33+
RUN sed -i 's/files/ldap files/g' /etc/nsswitch.conf
34+
35+
# Make editable and debuggable
36+
RUN pip install debugpy
37+
RUN pip install -e .
38+
39+
# Alternate entrypoint to allow devcontainer to attach
40+
ENTRYPOINT [ "/bin/bash", "-c", "--" ]
41+
CMD [ "while true; do sleep 30; done;" ]
42+
43+
2144
# The runtime stage copies the built venv into a slim runtime container
2245
FROM python:${PYTHON_VERSION}-slim AS runtime
2346
# Add apt-get system dependecies for runtime here if needed

0 commit comments

Comments
 (0)