From 24bec70ad9e64bf856291fc2494b7bc2cfef1546 Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Tue, 17 Sep 2024 23:29:14 +0200 Subject: [PATCH] starting CI/CD Signed-off-by: Peter Siegmund --- .github/dependabot.yml | 11 +++++++++++ Dockerfile | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..da93583 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "weekly" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2c4915 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Stage that builds the application, a prerequisite for the running stage +FROM eclipse-temurin:21-jdk-jammy as build + +ARG SERVICE_ROOT + +RUN apt-get update -qq + +# Stop running as root at this point +RUN useradd -m app +WORKDIR /usr/src/app/ +RUN chown app:app /usr/src/app/ +USER app + +# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies +COPY --chown=app ${SERVICE_ROOT}/gradle/ ./gradle +COPY --chown=app ${SERVICE_ROOT}/gradlew ${SERVICE_ROOT}/build.gradle ${SERVICE_ROOT}/settings.gradle ./ + +# Copy all needed project files to a folder +COPY --chown=app:app ${SERVICE_ROOT}/src ./src + +# Build the production package +RUN ./gradlew clean build -x test + +# Running stage: the part that is used for running the application +FROM eclipse-temurin:21-jre-jammy + +RUN useradd -m app +USER app + +COPY --chown=app --from=build /usr/src/app/build/libs/*-SNAPSHOT.jar /usr/app/app.jar + +EXPOSE 8080 +CMD java -jar /usr/app/app.jar