diff --git a/.github/workflows/buildAndPushImage.yml b/.github/workflows/buildAndPushImage.yml index 99e996a..163c11f 100644 --- a/.github/workflows/buildAndPushImage.yml +++ b/.github/workflows/buildAndPushImage.yml @@ -40,6 +40,7 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + # Build and push the regular image - name: Build and push uses: docker/build-push-action@v6 with: @@ -49,3 +50,16 @@ jobs: push: true tags: ${{ env.IMAGE_URL }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} provenance: false + + # Build and push the slim image + - name: Build and push slim image + 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 }}-slim + build-args: | # Set the SLIM env variable to 1 for the build + SLIM=1 + provenance: false diff --git a/Dockerfile b/Dockerfile index 07b68c0..63ec828 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,24 @@ COPY mps-transformation-terraform ./mps-transformation-terraform # Create the necessary directory for transformation input RUN mkdir -p /app/mps-transformation-terraform/transformationInput +# Conditionally comment out the line 'executor.execute(prepareMps)' if SLIM=1 +ARG SLIM +RUN if [ "$SLIM" != "1" ]; then \ + sed -i 's/executor\.execute(prepareMps)/\/\/ executor.execute(prepareMps)/' /app/src/main/java/ust/tad/terraformmpsplugin/analysis/TransformationService.java; \ + fi + # Build the project, using multiple threads and skipping tests RUN mvn -T 2C -q clean package -DskipTests +# Download MPS iff SLIM!=1 +RUN if [ "$SLIM" != "1" ]; then \ + cd mps-transformation-terraform && \ + ./gradlew prepareMps; \ + fi + +# Remove JBR tarball and MPS/Plugin zips +RUN rm -rf /app/mps-transformation-terraform/build/download + # Stage 2: Create a minimal runtime image using OpenJDK 11 JRE FROM openjdk:11-jre-slim