Skip to content

Commit

Permalink
attempt to speed up dotnet watch startup time when running in k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed May 22, 2024
1 parent ea236cd commit d0f3381
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/LexBoxApi/LexBoxApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
</ItemGroup>

<ItemGroup>
<Content Include="Services\HgEmptyRepo\**" CopyToOutputDirectory="Always" />
<Content Include="Services\HgEmptyRepo\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
14 changes: 11 additions & 3 deletions backend/LexBoxApi/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EXPOSE 80
EXPOSE 443
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get --no-install-recommends install -y rsync ssh
apt update && apt-get --no-install-recommends install -y tini
RUN mkdir -p /var/www && chown -R www-data:www-data /var/www
USER www-data:www-data
WORKDIR /src/backend
Expand All @@ -15,7 +15,15 @@ RUN for file in $(ls *.csproj); do dir=${file%.*} mkdir -p ${file%.*}/ && mv $fi

COPY --chown=www-data . .
WORKDIR /src/backend/LexBoxApi
RUN dotnet build #build and restore, should speed up watch run
#build here so that the build is run before container start, need to make sure the property is set both here
#and in the CMD command, otherwise it will rebuild every time the container starts
RUN dotnet build --property:InformationalVersion=dockerDev
RUN mkdir /src/frontend

#ensures the shutdown happens quickly
ENTRYPOINT ["tini", "--"]

# no need to restore because we already restored as part of building the image
CMD dotnet watch run -lp docker --property:InformationalVersion=dockerDev --no-hot-reload --no-restore
ENV ASPNETCORE_ENVIRONMENT=Development
ENV DOTNET_URLS=http://0.0.0.0:5158
CMD dotnet watch --no-hot-reload run --property:InformationalVersion=dockerDev --no-restore

0 comments on commit d0f3381

Please sign in to comment.