From 8392381306aa7f0208441a89c5ab9f0fb2e3dd67 Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Mon, 21 Sep 2020 01:52:29 +0200 Subject: [PATCH] Reduce docker image by half --- .dockerignore | 9 +++++++++ Dockerfile | 11 ++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..9163c629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.dockerignore +.env +.gitignore +.vs +.vscode +**/.git +**/.idea +**/bin +**/obj \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c0cd7f26f..bca3c3e5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,17 +6,18 @@ COPY src/Impostor.Server/Impostor.Server.csproj ./src/Impostor.Server/Impostor.S COPY src/Impostor.Shared/Impostor.Shared.csproj ./src/Impostor.Shared/Impostor.Shared.csproj COPY submodules/Hazel-Networking/Hazel/Hazel.csproj ./submodules/Hazel-Networking/Hazel/Hazel.csproj -RUN dotnet restore -r linux-x64 ./src/Impostor.Server/Impostor.Server.csproj && \ - dotnet restore -r linux-x64 ./src/Impostor.Shared/Impostor.Shared.csproj && \ - dotnet restore -r linux-x64 ./submodules/Hazel-Networking/Hazel/Hazel.csproj +RUN dotnet restore -r linux-musl-x64 ./src/Impostor.Server/Impostor.Server.csproj && \ + dotnet restore -r linux-musl-x64 ./src/Impostor.Shared/Impostor.Shared.csproj && \ + dotnet restore -r linux-musl-x64 ./submodules/Hazel-Networking/Hazel/Hazel.csproj # Copy everything else. COPY submodules/. ./submodules/ COPY src/. ./src/ -RUN dotnet publish -c release -o /app -f netcoreapp3.1 -r linux-x64 --self-contained false --no-restore ./src/Impostor.Server/Impostor.Server.csproj +RUN dotnet publish -c release -o /app -f netcoreapp3.1 -r linux-musl-x64 --self-contained false --no-restore ./src/Impostor.Server/Impostor.Server.csproj # Final image. -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine WORKDIR /app COPY --from=build /app ./ +EXPOSE 22023/udp ENTRYPOINT ["./Impostor.Server"] \ No newline at end of file