Introduction to Building Quarkus in Gitlab
1. Introduction In this article, we will look at two different ways on how we can build a Quarkus project in GitLab 2. Using a Maven Image a...
https://www.czetsuyatech.com/2021/07/javaee-quarkus-on-gitlab.html
1. Introduction
In this article, we will look at two different ways on how we can build a Quarkus project in GitLab
2. Using a Maven Image and Install Script
This is the fix version of the solution here https://github.com/quarkusio/quarkus/issues/6531#issuecomment-592996056
2.1 .gitlab-ci.yaml
image: maven:3.6.3-openjdk-11-slim variables: # This will supress any download for dependencies and plugins or upload messages which would clutter the console log. # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used # when running from the command line. # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins. MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" cache: paths: - .m2/repository stages: - build - release - deploy before_script: - echo " ------------------------------- Global > Before Script -------------------------------" - echo $CI_COMMIT_BRANCH - apt-get update -qq - apt-get install -y -qq build-essential libz-dev zlib1g-dev build-native: stage: build script: - chmod +x install-graal.sh && ./install-graal.sh jdk11 - export GRAALVM_HOME=${CI_PROJECT_DIR}/graalvm-ce-java11-20.1.0 - mvn clean install -P native
2.2 install-graal.sh
#!/usr/bin/env bash echo "Downloading GraalVM" curl -L https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.1.0/graalvm-ce-java11-linux-amd64-20.1.0.tar.gz > graalvm-ce-java11-linux-amd64-20.1.0.tar.gz tar -zxf graalvm-ce-java11-linux-amd64-20.1.0.tar.gz -C ${CI_PROJECT_DIR}/ ls -la echo "Installing GraalVM via gu" ${CI_PROJECT_DIR}/graalvm-ce-java11-20.1.0/bin/gu install native-image
3. Using graalvm-ce image for building natively and docker-git image for testing
Here is the .gitlab-ci.yaml file that I used
image: maven:3.6.3-openjdk-11 variables: # This will supress any download for dependencies and plugins or upload messages which would clutter the console log. # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used # when running from the command line. # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins. MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" cache: paths: - .m2/repository - target/lib before_script: - echo " ------------------------------- Global > Before Script -------------------------------" - echo $CI_COMMIT_BRANCH stages: - build - release - deploy build: stage: build before_script: - ls -la script: - mvn package -DskipTests tests: stage: build image: docker:git before_script: - "which maven || (apk add maven)" - apk add openjdk11 - docker ps services: - docker:dind script: - mvn docker:start test docker:stop build-native: stage: build image: oracle/graalvm-ce:20.1.0-java11 before_script: - yum install wget -y - wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo - yum install -y apache-maven - export GRAALVM_HOME=/opt/graalvm-ce-java11-20.1.0/ - gu install native-image script: - ./mvnw package -Pnative -DskipTests - ls -la artifacts: expire_in: 7 days paths: - ${CI_PROJECT_DIR}/target/**/*-runner.jar only: - masterBoth configurations are tested and running on GitLab @Aug 2020.
Here's a version that deploys to Amazon ECS https://czetsuya-tech.blogspot.com/2020/08/build-quarkus-in-gitlab-and-deploy-on-amazon-ecs.html.html
Post a Comment