From 8855d6f364ebea3261ea2ca5f3fb529578ccc901 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Tue, 30 Apr 2024 18:29:38 -0400 Subject: [PATCH 1/3] Add libreoffice microservice --- docker-images/libreoffice/Dockerfile | 12 ++++++++++++ docker-images/libreoffice/docker-entrypoint.sh | 16 ++++++++++++++++ docker-images/libreoffice/scyllaridae.yml | 10 ++++++++++ 3 files changed, 38 insertions(+) create mode 100644 docker-images/libreoffice/Dockerfile create mode 100755 docker-images/libreoffice/docker-entrypoint.sh create mode 100644 docker-images/libreoffice/scyllaridae.yml diff --git a/docker-images/libreoffice/Dockerfile b/docker-images/libreoffice/Dockerfile new file mode 100644 index 0000000..92e3ff2 --- /dev/null +++ b/docker-images/libreoffice/Dockerfile @@ -0,0 +1,12 @@ +ARG TAG=main +ARG DOCKER_REPOSITORY=local +FROM ${DOCKER_REPOSITORY}/scyllaridae:${TAG} AS scyllaridae + +COPY scyllaridae.yml . +COPY docker-entrypoint.sh . + +RUN apk update && \ + apk add --no-cache \ + openjdk17-jre==17.0.11_p9-r0 \ + libreoffice==7.6.3.1-r0 \ + ttf-dejavu==2.37-r5 diff --git a/docker-images/libreoffice/docker-entrypoint.sh b/docker-images/libreoffice/docker-entrypoint.sh new file mode 100755 index 0000000..cf433b3 --- /dev/null +++ b/docker-images/libreoffice/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# take input from stdin and print to stdout + +set -eou pipefail + +input_temp=$(mktemp /tmp/libreoffice-input-XXXXXX) + +cat > "$input_temp" + +libreoffice --headless --convert-to pdf "$input_temp" > /dev/null 2>&1 + +PDF="$(basename "$input_temp").pdf" +cat "/app/$PDF" + +rm "$input_temp" "/app/$PDF" diff --git a/docker-images/libreoffice/scyllaridae.yml b/docker-images/libreoffice/scyllaridae.yml new file mode 100644 index 0000000..c56a60e --- /dev/null +++ b/docker-images/libreoffice/scyllaridae.yml @@ -0,0 +1,10 @@ +allowedMimeTypes: + - "application/msword" + - "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + - "application/vnd.ms-powerpoint" + - "application/vnd.openxmlformats-officedocument.presentationml.presentation" + - "application/vnd.ms-excel" + - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" +cmdByMimeType: + default: + cmd: /app/docker-entrypoint.sh From 437ad3e3855e3cf55f9eead955d110238a43d1af Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Tue, 30 Apr 2024 18:32:19 -0400 Subject: [PATCH 2/3] fixup dockerfile --- docker-images/libreoffice/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-images/libreoffice/Dockerfile b/docker-images/libreoffice/Dockerfile index 92e3ff2..d3b518b 100644 --- a/docker-images/libreoffice/Dockerfile +++ b/docker-images/libreoffice/Dockerfile @@ -2,8 +2,8 @@ ARG TAG=main ARG DOCKER_REPOSITORY=local FROM ${DOCKER_REPOSITORY}/scyllaridae:${TAG} AS scyllaridae -COPY scyllaridae.yml . -COPY docker-entrypoint.sh . +COPY scyllaridae.yml /app/ +COPY docker-entrypoint.sh /app/ RUN apk update && \ apk add --no-cache \ From d41b74f58d628f293c0315fa159676fa70b6bd32 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Tue, 30 Apr 2024 18:39:40 -0400 Subject: [PATCH 3/3] Use context during build to match Dockerfile expectations --- .github/workflows/build-push.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 08fd48b..1c29394 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -41,15 +41,13 @@ jobs: # aka base build if [ ${{ inputs.dockerFile }} == "Dockerfile" ]; then echo "image=scyllaridae" >> $GITHUB_OUTPUT + echo "context=." >> $GITHUB_OUTPUT exit 0 fi - # put the YML file in place so it's copied into the Docker container DIR=$(dirname "${{ inputs.dockerFile }}") - cp ./$DIR/scyllaridae.yml . - # name the docker image after the folder name prefixed by scyllaridae - # e.g. scyllaridae-curl echo "image=scyllaridae-$(basename $DIR)" >> $GITHUB_OUTPUT + echo "context=$DIR" >> $GITHUB_OUTPUT id: setup - id: 'auth' @@ -71,8 +69,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v5 with: - context: . - file: ${{ inputs.dockerFile }} + context: ${{steps.setup.outputs.context}} build-args: | TAG=${{steps.extract_branch.outputs.branch}} DOCKER_REPOSITORY=us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/public