Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose with http based API #2

Merged
merged 9 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build Docker Image

on:
push:
branches:
- "main"
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'docker/**'
- 'Dockerfile'
- '.dockerignore'
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
COMMIT_SHA: ${{github.sha}}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}


- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: ${{ contains(fromJSON('["push", "release"]'), github.event_name) }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BUILD_COMMIT=$COMMIT_SHA
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.class
*.prefs
.*
*~
**/target/**
*.afm
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ WORKDIR /
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y maven

COPY pdfact-cli ./pdfact-cli
COPY pdfact-api ./pdfact-api
COPY pdfact-core ./pdfact-core
COPY resources ./resources
COPY pom.xml .

RUN mvn install -DskipTests

EXPOSE 4567

# Define the entrypoint.
ENTRYPOINT ["java", "-jar", "/bin/pdfact.jar"]
ENTRYPOINT ["java", "-cp", "/bin/pdfact.jar"]

CMD ["pdfact.api.PdfApi"]

# Build image.
# docker build -t pdfact .
Expand Down
80 changes: 80 additions & 0 deletions pdfact-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<groupId>pdfact</groupId>
<artifactId>pdfact-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>pdfact-api</artifactId>
Expand Down Expand Up @@ -40,6 +41,11 @@
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>

<properties>
Expand All @@ -48,4 +54,78 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<!-- Configure the assembly plugin to create an executable jar-file with
all dependencies -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>build-api</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>pdfact.api.PdfApi</mainClass>
</manifest>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<outputDirectory>${project.root.dirs.bin}</outputDirectory>
<finalName>${project.basename}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>

<!--
Configure the antrun plugin to create an executable resulting from the concatenation
of resources/stub.sh and the produced jar file. This will allow the jar-file to be
executable like a Linux executable file (without typing java -jar ...).
-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Concat stub.sh and the jar file to ./bin/pdfact -->
<concat destfile="${project.files.executable}" binary="yes">
<fileset file="${project.files.stub_sh}"/>
<fileset file="${project.files.jar}"/>
</concat>
<!-- Make the script executable. -->
<chmod file="${project.files.executable}" perm="755"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>