init a Dockerfile
This commit is contained in:
parent
a68287d847
commit
866619c539
3 changed files with 27 additions and 17 deletions
37
Dockerfile
37
Dockerfile
|
|
@ -1,25 +1,32 @@
|
||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
# Learn about building .NET container images:
|
# Learn about building .NET container images:
|
||||||
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
|
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||||
ARG TARGETARCH=amd64
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
EXPOSE 443
|
||||||
|
|
||||||
WORKDIR /source
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["/src", "/src"]
|
||||||
|
COPY "Directory.Packages.props" "Directory.Packages.props"
|
||||||
|
|
||||||
# Copy project file and restore as distinct layers
|
RUN dotnet nuget add source https://isn.pschneider.fr/v3/index.json --allow-insecure-connections
|
||||||
COPY --link src src
|
|
||||||
COPY --link Directory.Packages.props .
|
|
||||||
|
|
||||||
RUN dotnet nuget add source https://isn.pschneider.fr/v3/index.json
|
# Just to see if two lines above work
|
||||||
RUN dotnet restore -a $TARGETARCH src/Yavsc/Yavsc.csproj
|
RUN dotnet nuget list source
|
||||||
|
|
||||||
|
RUN dotnet restore "/src/Yavsc/Yavsc.csproj"
|
||||||
|
|
||||||
# Copy source code and publish app
|
# Copy source code and publish app
|
||||||
RUN dotnet publish -a $TARGETARCH --no-restore -o /app src/Yavsc/Yavsc.csproj
|
|
||||||
|
|
||||||
# Runtime stage
|
WORKDIR "/src/Yavsc"
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:10.0-alpine
|
RUN dotnet build "Yavsc.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "Yavsc.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --link --from=build /app .
|
COPY --from=publish /app/publish .
|
||||||
USER $APP_UID
|
ENTRYPOINT ["dotnet", "Yavsc.dll"]
|
||||||
ENTRYPOINT ["./Yavsc"]
|
|
||||||
|
|
||||||
|
|
|
||||||
5
Makefile
5
Makefile
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
CONFIG=Debug
|
CONFIG=Debug
|
||||||
FRAMEWORK=net8.0
|
FRAMEWORK=net9.0
|
||||||
DESTDIR=/tmp/yavsc
|
DESTDIR=/tmp/yavsc
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
@ -34,4 +34,7 @@ publish:
|
||||||
install: publish
|
install: publish
|
||||||
sudo chown -R www-data:www-data $(DESTDIR)/srv/www/yavsc
|
sudo chown -R www-data:www-data $(DESTDIR)/srv/www/yavsc
|
||||||
|
|
||||||
|
docker-image:
|
||||||
|
docker build .
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,4 @@
|
||||||
<ProjectReference Include="../Yavsc.Server/Yavsc.Server.csproj" />
|
<ProjectReference Include="../Yavsc.Server/Yavsc.Server.csproj" />
|
||||||
<ProjectReference Include="../Yavsc.Abstract/Yavsc.Abstract.csproj" />
|
<ProjectReference Include="../Yavsc.Abstract/Yavsc.Abstract.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue