From 1ecc5f78934414adc699e9639205277624ec292c Mon Sep 17 00:00:00 2001 From: Gapodo Date: Mon, 4 Dec 2023 16:30:15 +0100 Subject: [PATCH] add docker dev build --- .dockerignore | 8 ++++++++ Dockerfile.dev | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile.dev diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..722a7f7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +**/node_modules/ +**/dist +**/obj +**/bin +_Build/ +Docs/ +LANCommander.PowerShell/ +LANCommander.PowerShell.Tests/ diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..0474a62 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,33 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS builderbase + +RUN apt update && apt install -y \ + curl wget git ca-certificates gnupg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ + NODE_MAJOR=20 && \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ + apt update && apt install nodejs -y && \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* && \ + echo -e "cache=/npmcache\nfund=false\nreplace-registry-host=never\n" > /etc/npmrc +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 + +FROM builderbase as builder + +ARG VERSION=0.2.3 + +WORKDIR /opt/LANCommander +RUN --mount=type=bind,source=./,target=/opt/LANCommander,rw \ + --mount=type=cache,id=lancomnpm,target=/npmcache \ + --mount=type=cache,id=lancomnuget,target=/root/.nuget/packages \ + --mount=type=bind,source=./npmrc,target=/root/.npmrc \ + cd LANCommander/wwwroot/scripts && npm install && cd /opt/LANCommander && \ + dotnet build "./LANCommander/LANCommander.csproj" /p:Version="${VERSION}" && \ + dotnet publish "./LANCommander/LANCommander.csproj" -c Release -o /_Build --self-contained --os linux -p:PublishSingleFile=true + +FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim +COPY --from=builder /_Build /opt/LANCommander +WORKDIR /opt/LANCommander + +EXPOSE 1337 + +CMD /opt/LANCommander/LANCommander