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

Using seperate build and deploy images #8

Merged
merged 1 commit into from
Sep 22, 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
32 changes: 25 additions & 7 deletions .github/workflows/buildAndPushImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,30 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u well5a --password-stdin

- name: Build the Docker image
run: docker build . --file Dockerfile --tag $IMAGE_URL/$IMAGE_NAME:$IMAGE_TAG
- 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: 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
26 changes: 19 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
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
COPY mps-transformation-terraform ./mps-transformation-terraform

# Create the necessary directory for transformation input
RUN mkdir -p /app/mps-transformation-terraform/transformationInput

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/terraform-mps-plugin-0.0.1-SNAPSHOT.jar
# Set the command to run the application
CMD ["java", "-jar", "/app/target/terraform-mps-plugin-0.0.1-SNAPSHOT.jar"]