-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (28 loc) · 1.08 KB
/
Dockerfile
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
# Stage 1: Compile the native binary
FROM ubuntu:23.10 AS build
RUN apt-get update
RUN apt-get install build-essential -y
RUN apt-get install libz-dev -y
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# install sdkman
RUN apt-get -qq -y install curl wget unzip zip
RUN curl -s "https://get.sdkman.io" | bash
RUN source "$HOME/.sdkman/bin/sdkman-init.sh" \
&& sdk install java 22.3.r17-nik \
&& sdk install maven 3.9.3
WORKDIR buildspace
COPY ./src src
COPY ./pom.xml .
ENV MAVEN_HOME="/root/.sdkman/candidates/maven/current"
ENV JAVA_HOME="/root/.sdkman/candidates/java/current"
ENV PATH="$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH"
RUN mvn -Pnative native:compile -X
# Stage 2: Package into a Docker image
FROM debian:trixie-slim AS runtime
# libfreetype-dev is required to prevent the below error. There might be a better solution.
# error while loading shared libraries: libfreetype.so: cannot open shared object file: No such file or directory
RUN apt update && apt install libfreetype-dev -y
WORKDIR /workspace
COPY --from=build /buildspace/target/trainticket .
EXPOSE 8080
CMD ["./trainticket"]