Skip to content

Commit

Permalink
fix: add architecture compatibility flag to native build (#131)
Browse files Browse the repository at this point in the history
* fix: add architecture compatibility flag to native build

* ci: wrong place for the parameter

* ci: remove duplication of additional build arg

* ci: update to native arch for better compatibility

* ci: march compatibility

* feat: downgrade java version to 17
  • Loading branch information
Ricardo Campos authored Nov 7, 2023
1 parent 39f6c8e commit b1ac0f1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
32 changes: 19 additions & 13 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# Quarkus Images
# https://github.com/quarkusio/quarkus-images
### Builder
FROM ghcr.io/graalvm/native-image:ol8-java17-22 AS build

# "Provides the native-image executable. Used by the Maven and Gradle plugin from Quarkus to build linux64 executables"
FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:jdk-21 AS build
# Copy
WORKDIR /app
COPY pom.xml mvnw ./
COPY src ./src
COPY .mvn/ ./.mvn

# Image defaults to /project; copy controlled by .dockerignore
COPY --chown=quarkus:quarkus . ./
# Build
RUN ./mvnw package -Pnative -DskipTests

# "A base image to run Quarkus native application using UBI Micro"
FROM quay.io/quarkus/quarkus-micro-image:2.0
### Deployer
FROM gcr.io/distroless/java-base:nonroot AS deploy
ARG PORT=8080

# Copy
WORKDIR /app
COPY --from=build /app/target/results ./results

# Port and health check
EXPOSE 8080
HEALTHCHECK --interval=300s --timeout=3s CMD curl -f http://localhost:8080
USER 1001
EXPOSE ${PORT}
HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"'

# Startup
COPY --chown=1001:root --from=build /project/target/results /app
USER 1001
CMD ["/app", "-Dquarkus.http.host=0.0.0.0"]
ENTRYPOINT ["/app/results"]
4 changes: 2 additions & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</licenses>

<properties>
<java.version>21</java.version>
<jdk.version>21</jdk.version>
<java.version>17</java.version>
<jdk.version>17</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skip.integration.tests>true</skip.integration.tests>
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ management.endpoint.health.show-details = always
springdoc.enable-native-support = true

# https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.2
quarkus.native.additional-build-args=-march=x86-64-v2
quarkus.native.additional-build-args=-march=native

# Database, and JPA
spring.datasource.driver-class-name = org.postgresql.Driver
Expand Down

0 comments on commit b1ac0f1

Please sign in to comment.