add docker dev build

infra
gapodo 2023-12-04 16:30:15 +01:00
parent 9ff3621b52
commit 1ecc5f7893
2 changed files with 41 additions and 0 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
**/node_modules/
**/dist
**/obj
**/bin
_Build/
Docs/
LANCommander.PowerShell/
LANCommander.PowerShell.Tests/

33
Dockerfile.dev Normal file
View File

@ -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