-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Dockerfile for CLI verapdf (#404)
* FEAT: Dockerfile for CLI verapdf - added Dockerfile that: - downloads and installs veraPDF to the `app-installer` container; - builds a custom Alpine JRE on the jre-builder - copies both of the above to an Alpine docker container. - added basic build and run instructions to the README. - added GitHub actions for pushing cli image
- Loading branch information
1 parent
c4cafb0
commit 8c81baa
Showing
4 changed files
with
183 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Publish image to GitHub Packages | ||
on: | ||
push: | ||
tags: | ||
- v1.27.* | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: veraPDF/cli | ||
|
||
jobs: | ||
publish: | ||
if: github.repository == 'veraPDF/veraPDF-apps' | ||
name: Build and push Docker image to GitHub packages | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for GitHub | ||
id: meta | ||
uses: docker/metadata-action@v2 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Calculate version | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
id: version | ||
run: echo "::set-output name=version::${TAG##*.}" | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
file: Dockerfile | ||
build-args: | | ||
VERAPDF_VERSION=1.27 | ||
VERAPDF_MINOR_VERSION=${{ steps.version.outputs.version }} | ||
VERAPDF_INSTALLER_FOLDER=develop | ||
tags: ghcr.io/verapdf/cli:dev,ghcr.io/verapdf/cli:${{ github.ref_name }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
send-notification: | ||
runs-on: ubuntu-latest | ||
needs: [checkout-and-build, merge] | ||
if: | | ||
always() && | ||
github.repository == 'veraPDF/veraPDF-apps' && | ||
(contains(needs.*.result, 'failure') || | ||
contains(needs.*.result, 'skipped') || | ||
contains(needs.*.result, 'cancelled')) | ||
steps: | ||
- name: Send notification if build or push failed | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} | ||
uses: voxmedia/github-action-slack-notify-build@v1 | ||
with: | ||
channel_id: C03E3JJGLQL | ||
status: FAILED | ||
color: danger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/ | ||
# First build the app on a maven open jdk 11 container | ||
ARG VERAPDF_VERSION | ||
ARG VERAPDF_MINOR_VERSION | ||
ARG VERAPDF_INSTALLER_FOLDER | ||
FROM eclipse-temurin:11-jdk-alpine AS app-installer | ||
ENV VERAPDF_VERSION=${VERAPDF_VERSION:-1.26} | ||
ENV VERAPDF_MINOR_VERSION=${VERAPDF_MINOR_VERSION:-2} | ||
ENV VERAPDF_INSTALLER_FOLDER=${VERAPDF_INSTALLER_FOLDER:-releases} | ||
|
||
WORKDIR /tmp | ||
COPY docker-install.xml . | ||
RUN wget -O /tmp/verapdf-installer.zip https://software.verapdf.org/${VERAPDF_INSTALLER_FOLDER}/${VERAPDF_VERSION}/verapdf-greenfield-${VERAPDF_VERSION}.${VERAPDF_MINOR_VERSION}-installer.zip | ||
RUN unzip verapdf-installer.zip && java -jar ./verapdf-greenfield-${VERAPDF_VERSION}.${VERAPDF_MINOR_VERSION}/verapdf-izpack-installer-${VERAPDF_VERSION}.${VERAPDF_MINOR_VERSION}.jar docker-install.xml | ||
|
||
# Now build a Java JRE for the Alpine application image | ||
# https://github.com/docker-library/docs/blob/master/eclipse-temurin/README.md#creating-a-jre-using-jlink | ||
FROM eclipse-temurin:11-jdk-alpine AS jre-builder | ||
|
||
# Create a custom Java runtime | ||
RUN "$JAVA_HOME/bin/jlink" \ | ||
--add-modules java.base,java.logging,java.xml,jdk.crypto.ec,java.desktop,jdk.management \ | ||
--strip-debug \ | ||
--no-man-pages \ | ||
--no-header-files \ | ||
--compress=2 \ | ||
--output /javaruntime | ||
|
||
# Now the final application image | ||
FROM alpine:3 | ||
|
||
# Set for additional arguments passed to the java run command, no default | ||
ARG JAVA_OPTS | ||
ENV JAVA_OPTS=$JAVA_OPTS | ||
# Specify the veraPDF REST version if you want to (to be used in build automation) | ||
ARG VERAPDF_VERSION | ||
ENV VERAPDF_VERSION=${VERAPDF_VERSION} | ||
|
||
# Copy the JRE from the previous stage | ||
ENV JAVA_HOME=/opt/java/openjdk | ||
ENV PATH "${JAVA_HOME}/bin:${PATH}" | ||
COPY --from=jre-builder /javaruntime $JAVA_HOME | ||
|
||
# Since this is a running network service we'll create an unprivileged account | ||
# which will be used to perform the rest of the work and run the actual service: | ||
RUN addgroup -S verapdf && adduser -S -G verapdf -h /opt/verapdf verapdf | ||
RUN mkdir --parents /var/opt/verapdf/logs && chown -R verapdf:verapdf /var/opt/verapdf | ||
|
||
USER verapdf | ||
|
||
# Copy the application from the previous stage | ||
COPY --from=app-installer /opt/verapdf/ /opt/verapdf/ | ||
|
||
WORKDIR /data | ||
VOLUME /data | ||
|
||
ENTRYPOINT ["/opt/verapdf/verapdf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<AutomatedInstallation langpack="eng"> | ||
<com.izforge.izpack.panels.htmlhello.HTMLHelloPanel id="welcome"/> | ||
<com.izforge.izpack.panels.target.TargetPanel id="install_dir"> | ||
<installpath>/opt/verapdf</installpath> | ||
</com.izforge.izpack.panels.target.TargetPanel> | ||
<com.izforge.izpack.panels.packs.PacksPanel id="sdk_pack_select"> | ||
<pack index="0" name="veraPDF GUI" selected="true"/> | ||
<pack index="1" name="veraPDF Mac and *nix Scripts" selected="true"/> | ||
<pack index="2" name="veraPDF Validation model" selected="false"/> | ||
<pack index="3" name="veraPDF Documentation" selected="false"/> | ||
<pack index="4" name="veraPDF Sample Plugins" selected="false"/> | ||
</com.izforge.izpack.panels.packs.PacksPanel> | ||
<com.izforge.izpack.panels.install.InstallPanel id="install"/> | ||
<com.izforge.izpack.panels.finish.FinishPanel id="finish"/> | ||
</AutomatedInstallation> |