Skip to content

Commit

Permalink
Build OCI image for "apps/api"
Browse files Browse the repository at this point in the history
  • Loading branch information
clementguillot committed Feb 20, 2024
1 parent b7c7a89 commit 96aefa6
Show file tree
Hide file tree
Showing 5 changed files with 529 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/api/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!build/*-runner.jar
!build/lib/*
!build/quarkus-app/*
!build/native-sources/*
32 changes: 32 additions & 0 deletions apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,38 @@
"task": "quarkusBuild"
}
},
"build-native-sources": {
"executor": "@jnxplus/nx-gradle:run-task",
"options": {
"task": ["build", "-Dquarkus.package.type=native-sources"]
},
"outputs": ["{projectRoot}/build/native-sources"]
},
"patch-native-sources": {
"executor": "nx:run-commands",
"dependsOn": ["build-native-sources"],
"options": {
"command": "sed -i -e 's/--link-at-build-time//g' apps/api/build/native-sources/native-image.args"
},
"outputs": ["{projectRoot}/build/native-sources"]
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["patch-native-sources"],
"options": {
"engine": "docker",
"context": "apps/api",
"file": "apps/api/src/main/docker/Dockerfile.mandrel",
"load": true,
"metadata": {
"images": ["[ghcr.io/clementguillot/nx-cloud-ce-api"],
"tags": [
"type=schedule",
"type=sha,prefix="
]
}
}
},
"build-image": {
"executor": "@jnxplus/nx-gradle:quarkus-build-image"
},
Expand Down
19 changes: 19 additions & 0 deletions apps/api/src/main/docker/Dockerfile.mandrel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 AS build

COPY --chown=quarkus:quarkus build/native-sources /code/native-sources
USER quarkus
WORKDIR /code/native-sources
RUN native-image $(cat native-image.args)

FROM quay.io/quarkus/quarkus-micro-image:2.0

WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --from=build --chown=1001:root /code/native-sources/*-runner /work/application

EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Loading

0 comments on commit 96aefa6

Please sign in to comment.