Skip to content

Commit 2a9399a

Browse files
committed
Docker build github action
1 parent e667f25 commit 2a9399a

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docker Build
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Linux GitHub CI"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
build-docker:
11+
if: >
12+
github.event.workflow_run.conclusion == 'success' &&
13+
(github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'ghaction-docker')
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
# The checkout action is required to access the repository files,
20+
# including the Dockerfile.
21+
# It needs to checkout the specific commit that triggered the 'Linux GitHub CI' workflow.
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event.workflow_run.head_sha }}
26+
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Build and push
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
file: ./docker/gn-image/Dockerfile
45+
push: true
46+
tags: ghcr.io/${{ github.repository }}/geonetwork:${{ github.event.workflow_run.head_branch }}

docker/gn-image/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build stage
2+
FROM maven:3.8-jdk-11 AS builder
3+
4+
WORKDIR /usr/src/geonetwork
5+
6+
# Copy the entire project
7+
COPY . .
8+
9+
# Build the project and create the WAR file
10+
# The command is taken from the release-build.sh script
11+
RUN mvn clean install -DskipTests -ntp -Pwar -Pwro4j-prebuild-cache
12+
13+
# Runtime stage
14+
FROM jetty:9-jre11
15+
16+
# The geonetwork.war file is in web/target/
17+
COPY --from=builder /usr/src/geonetwork/web/target/geonetwork.war /var/lib/jetty/webapps/geonetwork.war
18+
19+
# Expose the default Jetty port
20+
EXPOSE 8080

0 commit comments

Comments
 (0)