Skip to content

Commit 3472998

Browse files
luklapserootroot
authored
SQL Server module in the docker-compose.yml (#136)
* Sqlite * publish * google * URLS * docker file work * docker files * docker https * docker setting * sql server * readme docker file * Update Readme.md * Update docker-compose.yml Merge mytest and master error Co-authored-by: root <root@instance-2.asia-east1-c.c.secure-grove-367912.internal> Co-authored-by: root <root@blogweb.asia-east2-a.c.secure-grove-367912.internal>
1 parent 4f28cb7 commit 3472998

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
bin/
22
obj/
33
*.db
4+
Publish/
45
/packages/
56
riderModule.iml
67
/_ReSharper.Caches/

Readme.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ This blog also offers an RSS feed ([RSS 2.0 specification](https://validator.w3.
190190

191191
## Host Web in Docker containers
192192

193+
### https http port and CA certificate
194+
193195
To deploy with docker, you need to modify the variables in the docker-compose.yml file.
194196
```yml
195197
volumes:
@@ -203,4 +205,30 @@ volumes:
203205
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/aspnetapp.pfx
204206
- ASPNETCORE_ENVIRONMENT=Production
205207
```
206-
After modifying the settings, you can use the docker command `docker compose up -d`.
208+
After modifying the settings, you can use the docker command `docker compose up -d`
209+
Deploy the web.
210+
If you don't use HTTPS, you can remove the related options.
211+
212+
### Sql Server
213+
214+
If you use Sql Server, you can add a sql server in `docker-compose.yml`.
215+
``` yml
216+
sql:
217+
image: mcr.microsoft.com/mssql/server:2022-latest
218+
container_name: sql
219+
expose:
220+
- 1433 #you can use other ports
221+
volumes:
222+
- sqlvolume:/var/opt/mssql
223+
environment:
224+
- ACCEPT_EULA=Y
225+
- MSSQL_SA_PASSWORD= #your sql password
226+
networks:
227+
- web_net
228+
volumes: # creates a shared data volume named sqlvolume if you use sqlserver
229+
sqlvolume:
230+
```
231+
Note the ConnectionString format of Sql Server needs to be consistent:
232+
```
233+
"ConnectionString": "Data Source=sql;Initial Catalog =master;User ID =sa;Password=<YOURPASSWORD>;TrustServerCertificate=True;MultiSubnetFailover=True"
234+
```

docker-compose.yml

+27-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,38 @@ services:
66
ports:
77
- 80:80
88
- 443:443
9+
restart: always
910
volumes:
11+
- ./src/LinkDotNet.Blog.Web/appsettings.json:/app/appsettings.json
1012
- /root/.aspnet/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
1113
- ./Blog.db:/app/Blog.db # Sqlite datebase
1214
- /root/aspnetapp.pfx:/app/aspnetapp.pfx # ssl certificate
1315
environment:
1416
- ASPNETCORE_URLS=http://+:80;https://+:443
15-
- ASPNETCORE_HTTPS_PORT=80
17+
- ASPNETCORE_HTTPS_PORT=443
1618
- ASPNETCORE_Kestrel__Certificates__Default__Password= # Your certificate password
1719
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/aspnetapp.pfx
18-
- ASPNETCORE_ENVIRONMENT=Production
20+
- ASPNETCORE_ENVIRONMENT=Production
21+
networks:
22+
- web_net
23+
######################################
24+
depends_on:
25+
- sql
26+
sql: # if you use SqlServer
27+
image: mcr.microsoft.com/mssql/server:2022-latest
28+
container_name: sql
29+
expose:
30+
- 1433
31+
restart: always
32+
volumes:
33+
- sqlvolume:/var/opt/mssql
34+
environment:
35+
- ACCEPT_EULA=Y
36+
- MSSQL_SA_PASSWORD= #your sql password
37+
networks:
38+
- web_net
39+
volumes: # creates a shared data volume named sqlvolume if you use sqlserver
40+
sqlvolume:
41+
###########################################
42+
networks:
43+
web_net:

0 commit comments

Comments
 (0)