Skip to content

Commit 8285774

Browse files
Building the Docker image in github worflo
1 parent 15d0939 commit 8285774

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: DockerBuildPush
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
DOCKER_REPOSITORY: breizhcamp/konter
10+
11+
jobs:
12+
13+
docker-build-push:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v4
18+
19+
- name: Build an image from Dockerfile
20+
run: |
21+
docker build -t $DOCKER_REPOSITORY:${{ github.sha }} .
22+
23+
- name: Run Trivy vulnerability scanner
24+
uses: aquasecurity/[email protected]
25+
with:
26+
image-ref: '${{ env.DOCKER_REPOSITORY }}:${{ github.sha }}'
27+
ignore-unfixed: true
28+
format: 'sarif'
29+
output: 'trivy-results.sarif'
30+
severity: 'CRITICAL,HIGH'
31+
32+
- name: Upload Trivy scan results to GitHub Security tab
33+
uses: github/codeql-action/upload-sarif@v3
34+
with:
35+
sarif_file: 'trivy-results.sarif'
36+
37+
- name: Login to Harbor
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ vars.DOCKER_REGISTRY_URL }}
41+
username: ${{ vars.DOCKER_REGISTRY_USER }}
42+
password: ${{ secrets.DOCKER_REGISTRY_PASS }}
43+
44+
- name: Set up QEMU
45+
uses: docker/setup-qemu-action@v3
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
push: true
55+
tags: ${{ vars.DOCKER_REGISTRY_URL }}/${{ env.DOCKER_REPOSITORY }}:latest,${{ vars.DOCKER_REGISTRY_URL }}/${{ env.DOCKER_REPOSITORY }}:${{ github.sha }}

.github/workflows/docker-build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: DockerBuild
2+
3+
on:
4+
pull_request:
5+
6+
env:
7+
DOCKER_REPOSITORY: breizhcamp/konter
8+
9+
jobs:
10+
11+
docker-build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
- name: Build an image from Dockerfile
18+
run: |
19+
docker build -t $DOCKER_REPOSITORY:${{ github.sha }} .
20+
21+
- name: Run Trivy vulnerability scanner
22+
uses: aquasecurity/[email protected]
23+
with:
24+
image-ref: '${{ env.DOCKER_REPOSITORY }}:${{ github.sha }}'
25+
ignore-unfixed: true
26+
format: 'sarif'
27+
output: 'trivy-results.sarif'
28+
severity: 'CRITICAL,HIGH'
29+
30+
- name: Upload Trivy scan results to GitHub Security tab
31+
uses: github/codeql-action/upload-sarif@v3
32+
with:
33+
sarif_file: 'trivy-results.sarif'

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM eclipse-temurin:17-jdk-alpine AS build
2+
WORKDIR /workspace/app
3+
4+
COPY mvnw .
5+
COPY .mvn .mvn
6+
COPY pom.xml .
7+
COPY src src
8+
9+
RUN ./mvnw install -DskipTests
10+
WORKDIR /workspace/app/target/dependency
11+
RUN jar -xf ../*.jar
12+
13+
FROM eclipse-temurin:17-jdk-alpine
14+
VOLUME /tmp
15+
ARG DEPENDENCY=/workspace/app/target/dependency
16+
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
17+
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
18+
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
19+
ENTRYPOINT ["java","-cp","app:app/lib/*","org.breizhcamp.konter.KonterApplicationKt"]

mvnw

100644100755
File mode changed.

0 commit comments

Comments
 (0)