Commit 2258e355 authored by Carsten Heidmann's avatar Carsten Heidmann Committed by femiadeyemi
Browse files

add GitLab CI configuration needed to build and push a Docker image

parent 931f46a1
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml
name: Docker
on:
push:
branches: [ master ]
release:
types: [published]
jobs:
docker_build:
name: Create and push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: helmholtzcloud/cerebrum
tag_with_ref: true
tags: latest
stages:
- build
- test
- pre_package
- package
- deploy
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
DOCKER_IMAGE_TAGGED: helmholtzcloud/cerebrum:$CI_COMMIT_SHA
DOCKER_IMAGE_LATEST: helmholtzcloud/cerebrum:latest
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- ".m2/repository"
include:
- local: .gitlab/ci/ci.yml
- local: .gitlab/ci/create-docker-image-ci.yml
\ No newline at end of file
ci_build:
only:
- master
- tags
- merge_requests
stage: build
image: maven:3-jdk-11
script: "mvn -B package --file pom.xml"
maven_build:
only:
- master
- tags
- merge_requests
stage: pre_package
dependencies:
- ci_build
image: maven:3-jdk-11
script: "mvn install"
artifacts:
paths:
- "target/*.jar"
expire_in: 600 seconds
tags:
- "docker"
docker_push:
only:
- master
stage: package
image: docker:19.03.11
services:
- name: docker:19.03.11-dind
alias: docker
before_script:
- docker info
script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker build -t $DOCKER_IMAGE_LATEST .
# - docker build -t $DOCKER_IMAGE_TAGGED .
# - docker push $DOCKER_IMAGE_TAGGED
# - docker tag $DOCKER_IMAGE_TAGGED $DOCKER_IMAGE_LATEST
- docker push $DOCKER_IMAGE_LATEST
dependencies:
- maven_build
Supports Markdown
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