-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile
44 lines (32 loc) · 1.11 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
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0.401-1-bookworm-slim AS build
WORKDIR /build
COPY *.sln ./
COPY **/*.csproj ./
RUN dotnet sln list | grep ".csproj" \
| while read -r line; do \
mkdir -p $(dirname $line); \
mv $(basename $line) $(dirname $line); \
done;
RUN dotnet restore --use-current-runtime
COPY . .
RUN dotnet publish Refresh.GameServer -c Release --property:OutputPath=/build/publish/ --no-restore --no-self-contained
# Final running container
FROM mcr.microsoft.com/dotnet/runtime:8.0.8-bookworm-slim AS final
# Add non-root user
RUN set -eux && \
apt update && \
apt install -y gosu curl && \
rm -rf /var/lib/apt/lists/* && \
gosu nobody true && \
groupadd -g 1001 refresh && \
useradd -m --home /refresh -u 1001 -g refresh refresh &&\
mkdir -p /refresh/data && \
mkdir -p /refresh/app
COPY --from=build /build/publish/publish /refresh/app
COPY --from=build /build/scripts/docker-entrypoint.sh /refresh
RUN chown -R refresh:refresh /refresh && \
chmod +x /refresh/docker-entrypoint.sh
ENV PRIV_CMD gosu
ENV PRIV_USER refresh
ENTRYPOINT ["/refresh/docker-entrypoint.sh", "GameServer"]