Skip to content

kongyim/creasant-test-webapi

Repository files navigation

creasant-test-webapi

dockerize

docker build -t creasant-test-webapi .

run image

docker run -d -p 8080:80 --name creasant-test-webapi creasant-test-webapi

useful links

  1. Create a Web API with ASP.NET Core and Visual Studio Code
  2. Dockerize a .NET Core application

step by step creating this example

1. create .NET webapi project

dotnet new webapi -o creasant-test-webapi --no-https

2. create Dockerfile (./Dockerfile)

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .

ENTRYPOINT ["dotnet", "creasant-test-webapi.dll"]

3. create docker ignore (./.dockerignore)

bin\
obj\

4. build docker image

docker build -t creasant-test-webapi .

5. run docker image as a container

docker run -d -p 8080:80 --name creasant-test-webapi creasant-test-webapi

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published