Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!pyproject.toml
!pdm.lock
!README.md
!LICENSE
!src/
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: ✨ release

# RC: `gh release create vX.Y.Z-rcN --prerelease --target <branch>` publishes the image only, not the wheel
on:
release:
types: [published]
Expand All @@ -12,6 +13,7 @@ permissions:
jobs:
publish:
name: publish artifacts
if: ${{ !github.event.release.prerelease }}
timeout-minutes: 60
runs-on: public-ledgerhq-shared-small
steps:
Expand Down Expand Up @@ -60,3 +62,54 @@ jobs:
uses: LedgerHQ/actions-security/actions/sign-blob@actions/sign-blob-1
with:
path: dist

image:
name: publish image
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
timeout-minutes: 10
uses: actions/checkout@v7

- name: Setup mise
timeout-minutes: 10
uses: jdx/mise-action@v5.2.7

- name: Get versions
id: version
env:
TAG: ${{ github.event.release.tag_name }}
run: |
{
echo "version=${TAG#v}"
echo "pdm=$(mise current pdm)"
echo "python=$(mise current python)"
} >> "$GITHUB_OUTPUT"

- name: Login to GitHub Container Registry
timeout-minutes: 10
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup buildx
timeout-minutes: 10
uses: docker/setup-buildx-action@v4

- name: Build and push image
timeout-minutes: 20
uses: docker/build-push-action@v7
with:
context: .
build-args: |
VERSION=${{ steps.version.outputs.version }}
PDM_VERSION=${{ steps.version.outputs.pdm }}
PYTHON_VERSION=${{ steps.version.outputs.python }}
tags: ghcr.io/ledgerhq/python-erc7730:${{ steps.version.outputs.version }}
push: true
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG PYTHON_VERSION

FROM python:${PYTHON_VERSION:?}-slim AS builder

WORKDIR /build
ARG PDM_VERSION
RUN pip install --no-cache-dir "pdm==${PDM_VERSION:?}"
COPY pyproject.toml pdm.lock ./
RUN pdm export --prod --output requirements.txt \
&& python -m venv /venv \
&& /venv/bin/pip install --no-cache-dir --require-hashes --requirement requirements.txt

COPY README.md LICENSE ./
COPY src src
ARG VERSION
RUN PDM_PEP517_SCM_VERSION="${VERSION:?}" /venv/bin/pip install --no-cache-dir --no-deps .

FROM python:${PYTHON_VERSION:?}-slim

LABEL org.opencontainers.image.source=https://github.com/LedgerHQ/python-erc7730
COPY --from=builder /venv /venv
ENV PATH=/venv/bin:$PATH
USER 65532:65532
EXPOSE 8730
ENTRYPOINT ["erc7730"]
CMD ["serve", "--host", "0.0.0.0", "--port", "8730"]
Loading