Skip to content

Commit f56f436

Browse files
authored
docker file and https (#134)
* docker files * docker https * docker setting
1 parent 0f54892 commit f56f436

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin/
22
obj/
3+
*.db
34
/packages/
45
riderModule.iml
56
/_ReSharper.Caches/

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
2+
WORKDIR /app
3+
EXPOSE 80
4+
EXPOSE 443
5+
6+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
7+
WORKDIR /src/LinkDotNet.Blog.Web
8+
COPY ./ /
9+
RUN dotnet restore "LinkDotNet.Blog.Web.csproj"
10+
RUN dotnet build "LinkDotNet.Blog.Web.csproj" -c Release -o /app/build
11+
12+
FROM build AS publish
13+
RUN dotnet publish "LinkDotNet.Blog.Web.csproj" -c Release -o /app/publish
14+
15+
FROM base AS final
16+
WORKDIR /app
17+
COPY --from=publish /app/publish .
18+
ENTRYPOINT ["dotnet", "LinkDotNet.Blog.Web.dll"]

Readme.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,22 @@ Furthermore, the following tags are set:
188188

189189
## RSS Feed
190190
This blog also offers an RSS feed ([RSS 2.0 specification](https://validator.w3.org/feed/docs/rss2.html)), which can be consumed by your users or programs like Feedly. Just append `feed.rss` to your URL or click on the RSS feed icon in the navigation bar to get the feed. The RSS feed does not expose the whole content of a given blog post but its title and short description including some other tags like preview image, publishing date and so on.
191+
192+
## Host Web in Docker containers
193+
194+
To deploy with docker, you need to modify the variables in the docker-compose.yml file.
195+
```yml
196+
volumes:
197+
- /root/.aspnet/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
198+
- ./Blog.db:/app/Blog.db #SQlite datebase consistent with appsettings.json
199+
- /root/aspnetapp.pfx:/app/aspnetapp.pfx #ssl certificate
200+
environment:
201+
- ASPNETCORE_URLS=http://+:80;https://+:443
202+
- ASPNETCORE_HTTPS_PORT=80
203+
- ASPNETCORE_Kestrel__Certificates__Default__Password= #your certificate password
204+
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/aspnetapp.pfx
205+
- ASPNETCORE_ENVIRONMENT=Production
206+
```
207+
After modifying the settings, you can use the docker command`docker compose up -d`
208+
Deploy the web.
209+
If you don't use HTTPS, you can remove the related options.

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
dotnet:
3+
image: linkdotnet.blog.web
4+
build: ./
5+
container_name: dotnetBlog
6+
ports:
7+
- 80:80 #You can modify the port you want
8+
- 443:443
9+
volumes:
10+
- /root/.aspnet/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
11+
- ./Blog.db:/app/Blog.db #SQlite datebase
12+
- /root/aspnetapp.pfx:/app/aspnetapp.pfx #ssl certificate
13+
environment:
14+
- ASPNETCORE_URLS=http://+:80;https://+:443
15+
- ASPNETCORE_HTTPS_PORT=80
16+
- ASPNETCORE_Kestrel__Certificates__Default__Password= #your certificate password
17+
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/aspnetapp.pfx
18+
- ASPNETCORE_ENVIRONMENT=Production

0 commit comments

Comments
 (0)