-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Dockerfile.koyeb
57 lines (42 loc) · 2.26 KB
/
Dockerfile.koyeb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
## Stage 1: Build with Maven builder image with native capabilities
# Use the Quarkus Mandrel builder image based on JDK 21, which includes native build tools.
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 AS build
# Copy the Maven wrapper script and directory into the container, setting correct ownership to the 'quarkus' user.
COPY --chown=quarkus:quarkus --chmod=0755 mvnw /code/mvnw
COPY --chown=quarkus:quarkus .mvn /code/.mvn
# Copy the pom.xml file, which is required for downloading dependencies.
COPY --chown=quarkus:quarkus pom.xml /code/
# Switch to the 'quarkus' user for security purposes.
USER quarkus
# Set the working directory to /code.
WORKDIR /code
# Use the Maven Dependency Plugin to download all dependencies offline (for caching purposes).
RUN ./mvnw dependency:resolve -U
# RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline
# Copy the source code (src directory) to the container.
COPY src /code/src
# Build the application with the native profile to create a native executable.
RUN ./mvnw package -Dnative
## Stage 2: Create the final Docker image
# Use a lightweight Quarkus micro image for running the application.
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10
######################### Set up environment for POI #############################
RUN microdnf update && microdnf install freetype fontconfig && microdnf clean all
######################### Set up environment for POI #############################
# Set the working directory to /work.
WORKDIR /work/
# Copy the native executable from the build stage into the /work directory.
# Shared objects to be dynamically loaded at runtime as needed,
COPY --from=build /code/target/*.properties /code/target/*.so /work/
COPY --from=build /code/target/*-runner /work/application
# Set up correct permissions for the user '1001' to ensure security and proper access control.
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work
# Expose port 8000 for the application to listen on.
EXPOSE 8000
# Switch to user '1001' to avoid running the application as root.
USER 1001
# Start the application and bind it to all network interfaces (0.0.0.0).
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]