From 1f8454fa545a045478a5689f335b6b143c2ac00e Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 16 Apr 2024 11:40:08 +0200 Subject: [PATCH] Dockerfile: add `ENTRYPOINT` directive (#3798) --- .github/workflows/docker-image.yml | 8 +++++++- Dockerfile | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 77a6a81e7..8029d6836 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,6 +32,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Get current date + run: echo "TYPST_BUILD_DATE=\"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\" >> ${GITHUB_ENV}" + - name: Setup Docker buildx uses: docker/setup-buildx-action@v3.1.0 with: @@ -59,12 +62,15 @@ jobs: outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + REVISION=${{ github.sha }} + CREATED=${{ env.TYPST_BUILD_DATE }} - name: Export digest run: | mkdir -p /tmp/digests digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" + touch "/tmp/digests/${digest#sha256:}" - name: Upload digest uses: actions/upload-artifact@v4 diff --git a/Dockerfile b/Dockerfile index 78985d4dd..b6723a013 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,7 @@ +ARG CREATED +ARG REVISION +ARG TARGETPLATFORM + FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx FROM --platform=$BUILDPLATFORM rust:alpine AS build COPY --from=xx / / @@ -11,7 +15,6 @@ RUN --mount=type=cache,target=/root/.cargo/git/db \ CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \ cargo fetch -ARG TARGETPLATFORM RUN xx-apk add --no-cache musl-dev openssl-dev openssl-libs-static RUN --mount=type=cache,target=/root/.cargo/git/db \ --mount=type=cache,target=/root/.cargo/registry/cache \ @@ -23,5 +26,16 @@ RUN --mount=type=cache,target=/root/.cargo/git/db \ xx-verify target/release/typst FROM alpine:latest -WORKDIR /root/ +LABEL org.opencontainers.image.authors="The Typst Project Developers " +LABEL org.opencontainers.image.created=${CREATED} +LABEL org.opencontainers.image.description="A markup-based typesetting system" +LABEL org.opencontainers.image.documentation="https://typst.app/docs" +LABEL org.opencontainers.image.licenses="Apache-2.0" +LABEL org.opencontainers.image.revision=${REVISION} +LABEL org.opencontainers.image.source="https://github.com/typst/typst" +LABEL org.opencontainers.image.title="Typst Docker image" +LABEL org.opencontainers.image.url="https://typst.app" +LABEL org.opencontainers.image.vendor="Typst" + COPY --from=build /app/target/release/typst /bin +ENTRYPOINT [ "/bin/typst" ]