Created
December 16, 2021 01:15
-
-
Save thedewpoint/4e92f676a201a061998d76a21c6d1388 to your computer and use it in GitHub Desktop.
gitlabs ci for jib image to ecr
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
cache: | |
key: mavencache | |
paths: | |
- ./.m2/repository | |
services: | |
- docker:dind | |
variables: | |
# Instruct Testcontainers to use the daemon of DinD. | |
DOCKER_HOST: "tcp://docker:2375" | |
# Instruct Docker not to start over TLS. | |
DOCKER_TLS_CERTDIR: "" | |
# Improve performance with overlayfs. | |
DOCKER_DRIVER: overlay2 | |
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID | |
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY | |
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION | |
AWS_ECR: "<ecr-account>.dkr.ecr.us-east-1.amazonaws.com/repo-name" | |
MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=./.m2/repository" | |
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" | |
stages: | |
- login | |
- package | |
aws: | |
image: | |
name: amazon/aws-cli | |
entrypoint: [""] | |
stage: login | |
script: | |
- aws ecr get-login-password --region $AWS_DEFAULT_REGION >> password.txt | |
artifacts: | |
paths: | |
- password.txt | |
package: | |
needs: | |
- job: aws | |
artifacts: true | |
image: adoptopenjdk/maven-openjdk11 | |
stage: package | |
script: | |
- mvn compile $MAVEN_CLI_OPTS jib:build -Djib.to.image=$AWS_ECR:latest -Djib.to.auth.username=AWS -Djib.to.auth.password=$(cat password.txt) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment