Skip to content

Commit

Permalink
Fixes #203 - Change to use Docker Maven plugin for building (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Jan 28, 2025
1 parent 61a937d commit 1b63388
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
with:
distribution: 'temurin'
java-version: 21
- name: Build WAR
run: |
mvn -B -DskipITs=true -DskipTests=true --ntp install
- name: Login to GHCR
uses: docker/login-action@v2
with:
Expand All @@ -30,5 +27,4 @@ jobs:
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build and push image
run: |
docker build -f src/main/docker/Dockerfile -t ghcr.io/piranhacloud/start:latest .
docker push ghcr.io/piranhacloud/start:latest
mvn -P docker clean install docker:push
45 changes: 45 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,51 @@
</dependency>
</dependencies>
<profiles>
<profile>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<alias>webprofile</alias>
<name>ghcr.io/piranhacloud/start:%l</name>
<build>
<buildx>
<platforms>
<platform>linux/amd64</platform>
<platform>linux/arm64</platform>
</platforms>
</buildx>
<contextDir>${basedir}</contextDir>
<dockerFile>src/main/docker/Dockerfile</dockerFile>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>push</id>
<phase>deploy</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>debug</id>
<build>
Expand Down
19 changes: 1 addition & 18 deletions src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
#
# Build the WAR file
#
FROM eclipse-temurin:21 AS builder
ENV MAVEN_VERSION 3.8.6
RUN cd /usr/local && \
curl -O https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz && \
tar xfvz apache-maven-$MAVEN_VERSION-bin.tar.gz
COPY . /root
RUN export PATH=$PATH:/usr/local/apache-maven-$MAVEN_VERSION/bin && \
cd /root && \
mvn --no-transfer-progress -DskipTests -DskipITs clean install

#
# Run the application
#
FROM ghcr.io/piranhacloud/webprofile:24.4.0
EXPOSE 8080
COPY --from=builder /root/target/piranha-start.war /home/piranha/ROOT.war
COPY target/piranha-start.war /home/piranha/ROOT.war
WORKDIR /home/piranha
USER root
RUN chown -R piranha:piranha *
Expand Down

0 comments on commit 1b63388

Please sign in to comment.