Created
April 25, 2020 12:19
-
-
Save DerPauli/e980302bb669838e77ebb4100917127e to your computer and use it in GitHub Desktop.
GitLabCI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:latest | |
stages: | |
- build | |
services: | |
- docker:dind | |
variables: | |
REGION: "eu-central-1" | |
EXPOSE: 8080 | |
before_script: | |
- apk add --no-cache curl jq python py-pip maven | |
- apk add --no-cache openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community | |
- pip install awscli | |
build_image: | |
stage: build | |
script: | |
- VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) | |
- NAME=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:exec) | |
- PACKAGING=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.packaging}' --non-recursive exec:exec) | |
- FILE="$NAME-$VERSION.$PACKAGING" | |
- mvn clean install -DskipTests | |
- mv "target/$FILE" "docker/ROOT.war" | |
- TAG="$(date +%Y%m%d)-$CI_JOB_ID-$VERSION" | |
- cd docker && docker build -f Dockerfile --build-arg ARTIFACT_NAME="ROOT.war" --build-arg EXPOSE="$EXPOSE" -t $REPOSITORY_URL:$TAG -t $REPOSITORY_URL:latest . | |
- $(aws ecr get-login --no-include-email --region $REGION) | |
- docker push $REPOSITORY_URL | |
only: | |
refs: | |
- master | |
- module/1 | |
- module/2 | |
- module/3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment