-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.simplified
38 lines (36 loc) · 1.06 KB
/
Dockerfile.simplified
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
ARG SDK_VERSION
ARG RUNTIME_VERSION
FROM mcr.microsoft.com/dotnet/aspnet:${RUNTIME_VERSION}-noble-chiseled-extra AS base
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION}-noble AS build
ARG PROJECT
ARG MIGRATIONS
WORKDIR /src/
COPY . .
RUN <<EOR
grep -q "<AssemblyName>" ${PROJECT}
if [ $? -eq 0 ]; then
sed -i ${PROJECT} -e "s|<AssemblyName>.*</AssemblyName>|<AssemblyName>main</AssemblyName>|"
else
sed -i ${PROJECT} -e "s|</PropertyGroup>|<AssemblyName>main</AssemblyName></PropertyGroup>|"
fi
EOR
RUN dotnet tool restore || true
RUN dotnet publish ${PROJECT} -c Release -o /app/publish
WORKDIR /app/publish
RUN rm -f appsettings.json appsettings.*.json || true
RUN <<EOR
mkdir /app/migrations
if [ ! -z ${MIGRATIONS} ]; then
cp -v /src/${MIGRATIONS} /app/migrations
fi
EOR
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
COPY --from=build /app/migrations /migrations/
COPY --from=busybox:uclibc /bin/cp /bin/cp
COPY --from=busybox:uclibc /bin/cat /bin/cat
COPY --from=busybox:uclibc /bin/ls /bin/ls
EXPOSE 8080
EXPOSE 8081
ENTRYPOINT ["/app/main"]