-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-native
49 lines (38 loc) · 1.62 KB
/
Dockerfile-native
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
FROM ghcr.io/graalvm/native-image-community:21-ol9 AS builder
# Install tar and gzip to extract the Maven binaries
# RUN microdnf update \
# && microdnf install --nodocs \
# tar \
# gzip \
# && microdnf clean all \
# && rm -rf /var/cache/yum
# Install Maven
# Source:
# 1) https://github.com/carlossg/docker-maven/blob/925e49a1d0986070208e3c06a11c41f8f2cada82/openjdk-17/Dockerfile
# 2) https://maven.apache.org/download.cgi
ARG USER_HOME_DIR="/root"
ARG SHA=a555254d6b53d267965a3404ecb14e53c3827c09c3b94b5678835887ab404556bfaf78dcfe03ba76fa2508649dca8531c74bca4d5846513522404d48e8c4ac8b
ARG MAVEN_DOWNLOAD_URL=https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${MAVEN_DOWNLOAD_URL} \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
# Set the working directory to /home/app
WORKDIR /build
# Copy the source code into the image for building
COPY . /build
# Build
RUN mvn -Pnative native:compile -DskipTests
# The deployment Image
#FROM docker.io/oraclelinux:9-slim #200MB
#FROM cgr.dev/chainguard/wolfi-base:latest #104MB
FROM alpine:latest #99M
RUN apk add gcompat
EXPOSE 8080
# Copy the native executable into the containers
COPY --from=builder /build/target/mongo-test .
ENTRYPOINT ["/mongo-test"]