Skip to main content

๐Ÿ‘ฉโ€๐Ÿ’ป dotnet6 ็š„ dockerfile

ๅปบ็ซ‹ๆช”ๆกˆโ€‹

ๅœจๅฐˆๆกˆๅบ•ไธ‹ๅปบ็ซ‹ไธ€ๅ€‹ๆช”ๆกˆ dockerfile

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Foreteller-Backend.dll"]

ๅœจๅฐˆๆกˆๅบ•ไธ‹ๅปบ็ซ‹ไธ€ๅ€‹ๆช”ๆกˆ .dockerignore๏ผŒไพ†้Žๆฟพ็”จไธๅˆฐ็š„ๆช”ๆกˆ

dockerfile
.dockerignore

ๅปบ็ซ‹ imageโ€‹

docker build -t dotnet6-app .

ๅ•Ÿๅ‹• dotnet6 ๅฎนๅ™จโ€‹

docker run -p 80:3050 dotnet6-app