Skip to content

Commit

Permalink
feat: info about the used weasyprint docker-image version (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbezliapovich authored Jul 31, 2024
1 parent ad27a7a commit b63b7c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- id: rp
if: github.event_name != 'pull_request' && github.ref_name == 'main'
uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4
uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4
with:
release-type: simple
include-v-in-tags: false
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USERNAME }}
Expand Down Expand Up @@ -54,21 +54,21 @@ jobs:
} >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ steps.tags.outputs.tags }}
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
- name: Build and push
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6
with:
context: .
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: APP_VERSION=${{ steps.meta.outputs.version }}
build-args: APP_IMAGE_VERSION=${{ steps.meta.outputs.version }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.12.4-slim@sha256:740d94a19218c8dd584b92f804b1158f85b0d241e5215ea26ed2dcade2b9d138
LABEL maintainer="Team Polarion (CLEW/WZU/POLARION) <polarion@sbb.ch>"
ARG APP_VERSION
ARG APP_IMAGE_VERSION

RUN apt-get update && \
apt-get --yes --no-install-recommends install python3-cffi python3-brotli libpango-1.0-0 libpangoft2-1.0-0 fonts-liberation chromium && \
Expand All @@ -10,7 +10,7 @@ RUN apt-get update && \

ENV WORKING_DIR=/opt/weasyprint
ENV CHROME_EXECUTABLE_PATH=/usr/bin/chromium
ENV WEASYPRINT_SERVICE_VERSION=$APP_VERSION
ENV WEASYPRINT_SERVICE_VERSION=$APP_IMAGE_VERSION

WORKDIR ${WORKING_DIR}

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Service providing REST API to use WeasyPrint functionality

```bash
docker build \
--build-arg APP_VERSION=62.3.0 \
--build-arg APP_IMAGE_VERSION=62.4.0 \
--file Dockerfile \
--tag weasyprint-service:62.3.0 .
--tag weasyprint-service:62.4.0 .
```

## Start Docker container
Expand All @@ -16,7 +16,7 @@ Service providing REST API to use WeasyPrint functionality
docker run --detach \
--publish 9080:9080 \
--name weasyprint-service \
weasyprint-service:62.3.0
weasyprint-service:62.4.0
```

## Stop Docker container
Expand Down
5 changes: 3 additions & 2 deletions app/WeasyprintController.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def version():
return {
"python": platform.python_version(),
"weasyprint": weasyprint.__version__,
"weasyprintServiceVersion": os.environ.get('WEASYPRINT_SERVICE_VERSION')
"weasyprintService": os.environ.get('WEASYPRINT_SERVICE_VERSION')
}


Expand All @@ -41,8 +41,9 @@ def convert_html():

response = Response(output_pdf, mimetype="application/pdf", status=200)
response.headers.add("Content-Disposition", "attachment; filename=" + file_name)
response.headers.add("Weasyprint-Version", weasyprint.__version__)
response.headers.add("Python-Version", platform.python_version())
response.headers.add("Weasyprint-Version", weasyprint.__version__)
response.headers.add("Weasyprint-Service-Version", os.environ.get('WEASYPRINT_SERVICE_VERSION'))
return response

except AssertionError as e:
Expand Down

0 comments on commit b63b7c5

Please sign in to comment.