Add Docker support with CI workflow and runtime configuration
Build and Push Docker Image / build-and-push (push) Failing after 1m52s
Build and Push Docker Image / build-and-push (push) Failing after 1m52s
- Added `Dockerfile` to build a Docker image for the JavadocViewerService. - Implemented a Gitea-based CI workflow (`deploy-image.yml`) to build and push the Docker image. - Updated `settings.local.json` to expand permissions for the service. - Included `-DskipTests` to Maven arguments in `JavadocService.java`.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(java -version)"
|
||||
"Bash(java -version)",
|
||||
"WebFetch(domain:github.com)",
|
||||
"Bash(find /Users/thilo/development/java/JavadocViewerService -not -path */target/* -not -path */.mvn/* -not -path */.maven/* -not -path */.git/* -type f -o -type d)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ gitea.server_url && fromJSON('{}') || '' }}${{ vars.GITEA_HOST || 'git.mein-gateway.de' }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Compute image name and tag
|
||||
id: meta
|
||||
run: |
|
||||
OWNER=$(echo "${{ gitea.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
||||
IMAGE_NAME=$(echo "javadocviewerservice" | tr '[:upper:]' '[:lower:]')
|
||||
REGISTRY="${{ vars.GITEA_HOST || 'git.mein-gateway.de' }}"
|
||||
FULL_IMAGE="${REGISTRY}/${OWNER}/${IMAGE_NAME}"
|
||||
|
||||
REF="${{ gitea.ref_name }}"
|
||||
if [ "${REF}" = "main" ]; then
|
||||
TAG="latest"
|
||||
else
|
||||
TAG=$(echo "${REF}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g')
|
||||
fi
|
||||
|
||||
echo "image=${FULL_IMAGE}" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
echo "Image: ${FULL_IMAGE}:${TAG}"
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Stage 1: Build the JAR using Maven
|
||||
FROM maven:3.9-eclipse-temurin-17 AS builder
|
||||
|
||||
LABEL org.opencontainers.image.description="JavadocViewerService serves and manages Javadoc documentation from Git repositories."
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Copy pom.xml and download dependencies first (for Docker cache)
|
||||
COPY pom.xml .
|
||||
RUN mvn dependency:go-offline
|
||||
|
||||
# Copy the full source tree and build the application
|
||||
COPY src ./src
|
||||
RUN mvn clean package -DskipTests
|
||||
|
||||
# Stage 2: Minimal runtime image
|
||||
FROM eclipse-temurin:17-jdk-jammy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Optional: add tini to manage signals properly
|
||||
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a non-root user
|
||||
RUN useradd -m jvsuser
|
||||
USER jvsuser
|
||||
|
||||
# Copy the built jar from the builder stage
|
||||
COPY --from=builder /build/target/*.jar /app/jvs.jar
|
||||
|
||||
VOLUME ["/app/javadoc-storage", "/app/database"]
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["java", "-jar", "jvs.jar"]
|
||||
@@ -87,7 +87,8 @@ public class JavadocService {
|
||||
"--no-transfer-progress",
|
||||
"-Dlombok.delombok.skip=true",
|
||||
"-Dcheckstyle.skip=true",
|
||||
"-Djacoco.skip=true"
|
||||
"-Djacoco.skip=true",
|
||||
"-DskipTests"
|
||||
);
|
||||
pb.directory(repoDir);
|
||||
pb.redirectErrorStream(true);
|
||||
|
||||
Reference in New Issue
Block a user