Running Serenity/Serene/StartSharp on Docker in .NET 8 #7030
Replies: 4 comments 11 replies
-
thanks so much for sharing |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing @edwardch, btw this is what I used before, hope it will give people more choices docker file FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
WORKDIR /src
COPY ["ContainerDemo/ContainerDemo.Web/ContainerDemo.Web.csproj", "ContainerDemo/ContainerDemo.Web/"]
COPY ["ContainerDemo/ContainerDemo.Web/nuget.config", "ContainerDemo/ContainerDemo.Web/"]
RUN dotnet restore "ContainerDemo/ContainerDemo.Web/ContainerDemo.Web.csproj"
COPY . .
WORKDIR "/src/ContainerDemo/ContainerDemo.Web"
RUN dotnet build "ContainerDemo.Web.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ContainerDemo.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ContainerDemo.Web.dll"] nuget.config file Nuget.config file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<packageSources>
<add key="public" value="https://api.nuget.org/v3/index.json" />
<add key="customfeed" value="https://packages………/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<customfeed>
<add key="Username" value="enter_your_username" />
<add key="ClearTextPassword" value="enter_your_raw_password" />
</customfeed>
</packageSourceCredentials>
</configuration> Database connection string "Data": {
"Default": {
"ConnectionString": "Server=host.docker.internal\\MSSQLSERVER,1433;Database=ContainerDemo_Default_v1;User Id=jin;Password=adminp;Encrypt=false;TrustServerCertificate=true",
"ProviderName": "System.Data.SqlClient"
},
"Northwind": {
"ConnectionString": "Server=host.docker.internal\\MSSQLSERVER,1433;Database=ContainerDemo_Northwind_v1;User Id=jin;Password=adminp;Encrypt=false;TrustServerCertificate=true",
"ProviderName": "System.Data.SqlClient"
}
}, |
Beta Was this translation helpful? Give feedback.
-
can you provide the docker compose file to connect the docker file to mssql server in vps linux server ? |
Beta Was this translation helpful? Give feedback.
-
when i run the docker file give me this error
Can someone help me? |
Beta Was this translation helpful? Give feedback.
-
Hi Serenity community!
Firstly want to say thank you to the Serenity team for all the hard work on upgrading Serenity to .NET 6 and now .NET 8!
I had an app running on Docker in .NET 6, and have now managed to get my app running in Docker with .NET 8.
(With the help from @VictorTomaili)
For those who want to run their app in Docker, here are some steps.
Add Docker support
Right click on your project then
Add > Docker Support...
This will create a
Dockerfile
.Modify Dockerfile
To get it working (the way I needed, at least), I updated the contents of this file to the following:
Override appsettings (optional)
Then add a file next to
appsettings.json
, calledappsettings.Docker.json
In this file you can override your settings, in my case it was to update connection strings accordingly to connect to a local or cloud based database.
Run
Change your app to start Docker instead of IIS or Kestrel (whatever your choice), then hit run.
And that's it.
Beta Was this translation helpful? Give feedback.
All reactions