-
Notifications
You must be signed in to change notification settings - Fork 658
/
Copy pathDockerfile
93 lines (72 loc) · 2.52 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
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
# "build" image
ARG CONTAINER_RUNTIME=jammy
# NOT A BUG: we can't build on alpine so we use jammy as a base image
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build
ARG RUNTIME=linux-x64
WORKDIR /build
COPY ./LICENSE.md .
COPY ./LICENSE_CONTRIBUTIONS.md .
COPY ./NOTICE.html .
COPY ./docker ./scripts
WORKDIR /build/ci
COPY ./ci ./
WORKDIR /build/src
COPY ./src/EventStore.sln ./src/*/*.csproj ./src/Directory.Build.* ./
RUN for file in $(ls *.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done
RUN dotnet restore --runtime=${RUNTIME}
COPY ./src .
WORKDIR /build/.git
COPY ./.git/ .
RUN /build/scripts/build.sh /build/src /build/published-tests
# "test" image
FROM mcr.microsoft.com/dotnet/sdk:8.0-${CONTAINER_RUNTIME} as test
WORKDIR /build
COPY --from=build ./build/published-tests ./published-tests
COPY --from=build ./build/ci ./ci
COPY --from=build ./build/scripts ./scripts
COPY --from=build ./build/src/EventStore.Core.Tests/Services/Transport/Tcp/test_certificates/ca/ca.crt /usr/local/share/ca-certificates/ca_eventstore_test.crt
RUN mkdir ./test-results
CMD ["/build/scripts/test.sh"]
# "publish" image
FROM build as publish
ARG RUNTIME=linux-x64
RUN dotnet publish --configuration=Release --runtime=${RUNTIME} --self-contained \
--framework=net8.0 --output /publish /build/src/KurrentDB
# "runtime" image
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-${CONTAINER_RUNTIME} AS runtime
ARG RUNTIME=linux-x64
ARG UID=1000
ARG GID=1000
RUN if [[ "${RUNTIME}" = "linux-musl-x64" ]];\
then \
apk update && \
apk add --no-cache \
curl; \
else \
apt update && \
apt install -y \
curl && \
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"]