DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
wk
wk

Posted on

Create small ASP.NET Core Docker

  • Create project
$ dotnet new webapi --language F# --output src/MyWeb
  • Create Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:5.0-alpine AS base

WORKDIR /app
COPY src/MyWeb/MyWeb.fsproj src/MyWeb/
RUN dotnet restore src/MyWeb

COPY src/MyWeb src/MyWeb
RUN dotnet publish src/MyWeb \
    -r linux-musl-x64 \
    -c Release \
    -o /out \
    -p:PublishTrimmed=true

FROM mcr.microsoft.com/dotnet/core/runtime-deps:5.0-alpine
WORKDIR /app
COPY --from=base /out ./
CMD ./MyWeb
EXPOSE 80
  • Build image
$ docker build -f Dockerfile  -t wk/my-web .
  • Check image size
$ docker images | grep wk/my-web
wk/my-web    latest     e03dd2b6b198    4 hours ago    72.4MB

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Just kidding, it's a personal preference. But you can change your theme, font, etc. in your settings.

The more you know. 🌈