Commit bcfd628f authored by cnguyen2's avatar cnguyen2
Browse files

Update build pipeline

parent ef03c1a9
Pipeline #165561 passed with stages
in 8 minutes and 44 seconds
*
!src/*
!data/*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!pom.xml
image: maven:3.6.3-openjdk-11-slim
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
cache:
paths:
- .m2/repository
stages:
- build_native
- build_docker
build_native:
stage: build_native
script:
- apt-get update -qq && apt-get install -y -qq build-essential libz-dev zlib1g-dev
- curl -L https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.2.0/graalvm-ce-java11-linux-amd64-20.2.0.tar.gz > graalvm-ce-java11-linux-amd64-20.2.0.tar.gz
- tar -zxf graalvm-ce-java11-linux-amd64-20.2.0.tar.gz -C ${CI_PROJECT_DIR}/
- ${CI_PROJECT_DIR}/graalvm-ce-java11-20.2.0/bin/gu install native-image
- export GRAALVM_HOME=${CI_PROJECT_DIR}/graalvm-ce-java11-20.2.0
- mvn clean package -Pnative
- build
- push
only:
- tags
artifacts:
paths:
- ${CI_PROJECT_DIR}/target/*-runner
variables:
CONTAINER_TEMP_IMAGE: $CI_REGISTRY_IMAGE:temp-$CI_COMMIT_SHORT_SHA
build_docker:
stage: build_docker
build native:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
only:
- master
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.native --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- >
/kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.multistage
--destination $CONTAINER_TEMP_IMAGE
push latest:
stage: push
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
only:
- master
variables:
GIT_STRATEGY: none
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane cp $CONTAINER_TEMP_IMAGE $CI_REGISTRY_IMAGE:latest
push tag:
stage: push
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
only:
- tags
variables:
GIT_STRATEGY: none
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane cp $CONTAINER_TEMP_IMAGE $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
......@@ -72,6 +72,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:20.2.0-java11 AS build
COPY pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml -B de.qaware.maven:go-offline-maven-plugin:1.2.5:resolve-dependencies
COPY src /usr/src/app/src
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative clean package
## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application
# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work
COPY data/* /work/data/
EXPOSE 8080
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment