-
Notifications
You must be signed in to change notification settings - Fork 678
Expand file tree
/
Copy pathDockerfile
More file actions
116 lines (95 loc) · 3.53 KB
/
Copy pathDockerfile
File metadata and controls
116 lines (95 loc) · 3.53 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# for CI
# "build" image
ARG CONTAINER_RUNTIME=noble
# NOT A BUG: we can't build on alpine so we use noble as a base image
FROM mcr.microsoft.com/dotnet/sdk:10.0-noble AS build
ARG RUNTIME=linux-x64
WORKDIR /build
COPY ./LICENSE.md .
COPY ./LICENSE_CONTRIBUTIONS.md .
COPY ./NOTICE.md .
COPY ./global.json .
COPY ./KurrentDB.slnx .
WORKDIR /build/ci
COPY ./ci ./
WORKDIR /build/proto
COPY ./proto ./
WORKDIR /build/src
COPY ./src/Connectors/*/*.csproj ./Connectors/
COPY ./src/SchemaRegistry/*/*.csproj ./SchemaRegistry/
COPY ./src/*/*.csproj ./src/Directory.Build.* ./src/Directory.Packages.props ./
RUN for file in $(ls Connectors/*.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done && \
for file in $(ls SchemaRegistry/*.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done && \
for file in $(ls *.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done
RUN dotnet restore /build/KurrentDB.slnx
COPY ./src .
WORKDIR /build/.git
COPY ./.git/ .
# "test" image
FROM mcr.microsoft.com/dotnet/sdk:10.0-${CONTAINER_RUNTIME} AS test
ARG CONTAINER_RUNTIME=noble
# libgomp (the OpenMP runtime) is required by Kontext's USearch native library
RUN if [ "${CONTAINER_RUNTIME}" = "alpine" ]; then \
apk add --no-cache libgomp; \
else \
apt-get update && apt-get install -y libgomp1 && rm -rf /var/lib/apt/lists/*; \
fi
WORKDIR /build
COPY --from=build ./build/src ./src
COPY --from=build ./build/ci ./ci
COPY --from=build ./build/proto ./proto
COPY --from=build ./build/LICENSE.md ./LICENSE.md
COPY --from=build ./build/NOTICE.md ./NOTICE.md
COPY --from=build ./build/LICENSE_CONTRIBUTIONS.md ./LICENSE_CONTRIBUTIONS.md
COPY --from=build ./build/global.json ./global.json
COPY --from=build ./build/KurrentDB.slnx ./KurrentDB.slnx
COPY --from=build ./build/src/KurrentDB.Core.Testing/Services/Transport/Tcp/test_certificates/ca/ca.crt /usr/local/share/ca-certificates/ca_kurrentdb_test.crt
RUN mkdir ./test-results
SHELL ["/bin/bash", "-c"]
# "publish" image
FROM build AS publish
ARG RUNTIME=linux-x64
RUN dotnet publish --configuration=Release --runtime=${RUNTIME} --self-contained \
--framework=net10.0 --output /publish /build/src/KurrentDB
# "runtime" image
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-${CONTAINER_RUNTIME} AS runtime
ARG RUNTIME=linux-x64
ARG UID=1001
ARG GID=1001
# libgomp (the OpenMP runtime) is required by Kontext's USearch native library
RUN if [[ "${RUNTIME}" = "linux-musl-x64" ]];\
then \
apk update && \
apk add --no-cache \
curl \
libgomp; \
else \
apt update && \
apt install -y \
adduser \
curl \
libgomp1 && \
rm -rf /var/lib/apt/lists/*; \
fi
WORKDIR /opt/kurrentdb
RUN addgroup --gid ${GID} "kurrent" && \
adduser \
--disabled-password \
--gecos "" \
--ingroup "kurrent" \
--no-create-home \
--uid ${UID} \
"kurrent"
COPY --chown=kurrent:kurrent --from=publish /publish ./
RUN mkdir -p /var/lib/kurrentdb && \
mkdir -p /var/log/kurrentdb && \
mkdir -p /etc/kurrentdb && \
chown -R kurrent:kurrent /var/lib/kurrentdb /var/log/kurrentdb /etc/kurrentdb
USER kurrent
RUN printf "NodeIp: 0.0.0.0\n\
ReplicationIp: 0.0.0.0" >> /etc/kurrentdb/kurrentdb.conf
VOLUME /var/lib/kurrentdb /var/log/kurrentdb
EXPOSE 1112/tcp 1113/tcp 2113/tcp
HEALTHCHECK --interval=5s --timeout=5s --retries=24 \
CMD curl --fail --insecure https://localhost:2113/health/live || curl --fail http://localhost:2113/health/live || exit 1
ENTRYPOINT ["/opt/kurrentdb/KurrentDB"]