-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
49 lines (35 loc) · 1.36 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FROM --platform=linux/amd64 gradle:8.1.1-jdk11 as build
#Cannot use alpine as the kotlin native toolchain uses gcc in places :(
#Cannot use jdk 17 as fails to spawn helper
SHELL ["/bin/bash", "-c"]
ARG MODE=debug
# For some reason konan seems to wipe the $HOME/.konan folder between builds
# By defining this env variable konan will write cache out to a folder we are already using for caching
ENV KONAN_DATA_DIR=/home/gradle/.gradle
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y \
build-essential \
liburing-dev
COPY . /app
WORKDIR /app
RUN \
--mount=type=cache,target=/app/.gradle,rw \
--mount=type=cache,target=/app/bin/build,rw \
--mount=type=cache,target=/home/gradle/.gradle,rw \
./gradlew --stacktrace link${MODE^}ExecutableNative --no-daemon
# Copy the generated binaries out of the build volume and into the PATH
RUN \
--mount=type=cache,target=/app/bin/build,rw \
mkdir /artifacts/ && \
find /app/bin/build/ \
-maxdepth 4 \
-type f -executable \
-exec cp {} /artifacts/ \;
#FROM --platform=linux/amd64 scratch can't use scratch as theres no way to statically link glibc
FROM --platform=linux/amd64 debian:bullseye-slim
ARG BINARY=program.kexe
ENV COMMAND=${BINARY}
COPY --from=build /artifacts/$BINARY /usr/local/bin/$BINARY
CMD ["sh", "-c", "$COMMAND"]