Skip to content

Commit

Permalink
Add libreoffice microservice (#8)
Browse files Browse the repository at this point in the history
* Add libreoffice microservice

* fixup dockerfile

* Use context during build to match Dockerfile expectations
  • Loading branch information
joecorall authored Apr 30, 2024
1 parent ab1657f commit 3f767c2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions docker-images/libreoffice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG TAG=main
ARG DOCKER_REPOSITORY=local
FROM ${DOCKER_REPOSITORY}/scyllaridae:${TAG} AS scyllaridae

COPY scyllaridae.yml /app/
COPY docker-entrypoint.sh /app/

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
16 changes: 16 additions & 0 deletions docker-images/libreoffice/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions docker-images/libreoffice/scyllaridae.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3f767c2

Please sign in to comment.