diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..30c1193 --- /dev/null +++ b/.github/workflows/docker.yml @@ -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/login-action@v3.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5.5.1 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + + - name: Build and push Docker image + uses: docker/build-push-action@v5.3.0 + 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') \ No newline at end of file diff --git a/.gitignore b/.gitignore index 813f04d..27fd672 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.class *.prefs -.* *~ **/target/** *.afm diff --git a/Dockerfile b/Dockerfile index 900c374..43b23be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 . diff --git a/pdfact-api/pom.xml b/pdfact-api/pom.xml index cb3cf3a..da130f7 100644 --- a/pdfact-api/pom.xml +++ b/pdfact-api/pom.xml @@ -7,6 +7,7 @@ pdfact pdfact-parent 0.0.1-SNAPSHOT + ../pom.xml pdfact-api @@ -40,6 +41,11 @@ 0.0.1-SNAPSHOT compile + + org.slf4j + slf4j-simple + 1.7.36 + @@ -48,4 +54,78 @@ UTF-8 + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4.1 + + + build-api + package + + single + + + + + pdfact.api.PdfApi + + + true + + + + jar-with-dependencies + + ${project.root.dirs.bin} + ${project.basename} + false + false + + + + + + + + maven-antrun-plugin + 1.8 + + + package + + run + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + + + + \ No newline at end of file