-
Notifications
You must be signed in to change notification settings - Fork 646
Expand file tree
/
Copy pathDockerfile.chiseled
More file actions
81 lines (65 loc) · 3.19 KB
/
Dockerfile.chiseled
File metadata and controls
81 lines (65 loc) · 3.19 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG TARGETARCH
RUN mkdir /data \
&& chown -R $APP_UID:$APP_UID /data
WORKDIR /src
# Copy csproj and restore as distinct layers
COPY libs/client/*.csproj libs/client/
COPY libs/cluster/*.csproj libs/cluster/
COPY libs/common/*.csproj libs/common/
COPY libs/host/*.csproj libs/host/
COPY libs/server/*.csproj libs/server/
COPY libs/resources/*.csproj libs/resources/
COPY libs/storage/Tsavorite/cs/src/core/*.csproj libs/storage/Tsavorite/cs/src/core/
COPY libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/*.csproj libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/
COPY main/GarnetServer/*.csproj main/GarnetServer/
COPY metrics/HdrHistogram/*.csproj metrics/HdrHistogram/
COPY Directory.Build.props Directory.Build.props
COPY Directory.Packages.props Directory.Packages.props
COPY Version.props Version.props
COPY .editorconfig .editorconfig
RUN dotnet restore main/GarnetServer/GarnetServer.csproj -a $TARGETARCH
# Copy everthing else and publish app
COPY Garnet.snk Garnet.snk
COPY libs/ libs/
COPY main/ main/
COPY metrics/ metrics/
COPY test/testcerts test/testcerts
# Set protected mode to no for Docker images
RUN sed -i 's/"ProtectedMode": "yes",/"ProtectedMode": "no",/' /src/libs/host/defaults.conf
WORKDIR /src/main/GarnetServer
RUN dotnet publish -a $TARGETARCH -c Release -o /app --no-restore --self-contained false -f net10.0 -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
# Delete xmldoc files
RUN find /app -name '*.xml' -delete
# --- Lua and libaio builder stage ---
FROM ubuntu:24.04 AS libs-builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends liblua5.4-0 libaio1t64 \
&& ARCH="$(uname -m)" \
&& case "$ARCH" in x86_64) MULTIARCH="x86_64-linux-gnu";; aarch64) MULTIARCH="aarch64-linux-gnu";; *) MULTIARCH="$ARCH-linux-gnu";; esac \
&& mkdir -p /staging/lua /staging/libaio \
&& cp "/usr/lib/${MULTIARCH}/liblua5.4.so.0" /staging/lua/ \
&& ln -sf "liblua5.4.so.0" /staging/lua/liblua54.so \
&& cp "/usr/lib/${MULTIARCH}/libaio.so.1t64" /staging/libaio/ \
&& ln -sf "libaio.so.1t64" /staging/libaio/libaio.so.1 \
&& rm -rf /var/lib/apt/lists/*
# --- .NET build and layout prep ---
FROM mcr.microsoft.com/dotnet/runtime:10.0-noble AS prep-runtime
# prep-runtime image HAS /bin/sh, so we can script here
COPY --from=libs-builder /staging/lua /lua
RUN DN_DIR=$(ls -d /usr/share/dotnet/shared/Microsoft.NETCore.App/* | head -n1) \
&& cp /lua/liblua54.so "$DN_DIR/liblua54.so"
# Final stage/image
FROM mcr.microsoft.com/dotnet/runtime:10.0-noble-chiseled AS runtime
WORKDIR /app
COPY --from=build --chown=$APP_UID:$APP_UID /data /data
# Copy the pre-symlinked .NET shared directory from prep-runtime
COPY --from=prep-runtime /usr/share/dotnet/shared /usr/share/dotnet/shared
# Copy libaio for native device support (copy the real file, then symlink in the chiseled image via prep-runtime)
COPY --from=libs-builder /staging/libaio/libaio.so.1t64 /usr/lib/libaio.so.1t64
COPY --from=libs-builder /staging/libaio/libaio.so.1 /usr/lib/libaio.so.1
COPY --from=build /app .
VOLUME /data
# For inter-container communication.
EXPOSE 6379
ENTRYPOINT ["/app/GarnetServer"]