Skip to content

Instantly share code, notes, and snippets.

@stefanotroia
Created November 5, 2019 17:10
Show Gist options
  • Save stefanotroia/2d5dee49ea7de8cfb6738837c4aa5ce6 to your computer and use it in GitHub Desktop.
Save stefanotroia/2d5dee49ea7de8cfb6738837c4aa5ce6 to your computer and use it in GitHub Desktop.
Build Docker images with Maven in Gitlab CI/CD
image: docker:latest
services:
- docker:dind
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .m2/repository
stages:
- build
- deploy
maven-build:
image: maven:3-jdk-8
stage: build
script:
- mvn install jib:build -Djib.to.auth.username=$DOCKER_USER -Djib.to.auth.password=$DOCKER_PASSWORD
only:
- development
- staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment