https://github.com/biplobpustcse/dotnet8webapi-with-docker
Dot Net 8 Web API
https://github.com/biplobpustcse/dotnet8webapi-with-docker
csharp docker dotnet8
Last synced: 2 months ago
JSON representation
Dot Net 8 Web API
- Host: GitHub
- URL: https://github.com/biplobpustcse/dotnet8webapi-with-docker
- Owner: biplobpustcse
- Created: 2024-01-10T19:29:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-22T02:53:57.000Z (over 2 years ago)
- Last Synced: 2025-01-12T20:46:34.859Z (over 1 year ago)
- Topics: csharp, docker, dotnet8
- Language: C#
- Homepage:
- Size: 13.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dot Net 8 Web API With Docker
#### Docker File
```
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["DotNet8WebAPI/DotNet8WebAPI.csproj", "DotNet8WebAPI/"]
RUN dotnet restore "./DotNet8WebAPI/./DotNet8WebAPI.csproj"
COPY . .
WORKDIR "/src/DotNet8WebAPI"
RUN dotnet build "./DotNet8WebAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./DotNet8WebAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DotNet8WebAPI.dll"]
```
#### Instead, go to the parent directory, with the .sln file and use the docker -f option to specify the Dockerfile to use in the subfolder:
#### Create image
```
docker build -t counter-image -f DotNet8WebAPI/Dockerfile .
```
#### It worked for me.
#### Create container
```
docker run -p 4201:8080 --name your-container-name your-image-name
```
#### You can run only using Visual stdio terminal
```
docker run -it --rm -p 8080:80 --name weatherapi-container weatherapi-image:latest
```