Skip to content

Commit

Permalink
Merge pull request #4 from UST-DeMAF/new-image
Browse files Browse the repository at this point in the history
Using seperate build and deploy images
  • Loading branch information
heidrifx authored Sep 22, 2024
2 parents 2d6961d + 7dae0ea commit 381ef85
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/buildAndPushImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u well5a --password-stdin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64

- name: Build the Docker image
run: docker build . --file Dockerfile --tag $IMAGE_URL/$IMAGE_NAME:$IMAGE_TAG
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push the Docker image
run: docker push $IMAGE_URL/$IMAGE_NAME:$IMAGE_TAG
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.IMAGE_URL }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
provenance: false
24 changes: 17 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
FROM alpine:latest
# Stage 1: Build the application using Maven with Eclipse Temurin JDK 11
FROM maven:3.8.6-eclipse-temurin-11 AS build

RUN apk upgrade --no-cache \
&& apk add --no-cache bash curl gcompat libstdc++ maven openjdk11

RUN mkdir -p /app/target
# Set the working directory for the build stage
WORKDIR /app

# Copy the Maven project file and source code into the container
COPY pom.xml .
COPY src ./src

RUN mvn clean package -DskipTests
# Build the project, using multiple threads and skipping tests
RUN mvn -T 2C -q clean package -DskipTests

# Stage 2: Create a minimal runtime image using OpenJDK 11 JRE
FROM openjdk:11-jre-slim

# Set the working directory for the runtime stage
WORKDIR /app

# Copy all built files from the build stage to the runtime stage
COPY --from=build /app /app

CMD java -jar target/helm-plugin-0.0.1-SNAPSHOT.jar
# Set the command to run the application
CMD ["java", "-jar", "/app/target/helm-plugin-0.0.1-SNAPSHOT.jar"]

0 comments on commit 381ef85

Please sign in to comment.