Difference between revisions of "Deploy .NET to Docker"
From MgmtWiki
(→Setting up a HTTPS connection) |
(→References) |
||
Line 63: | Line 63: | ||
4 -rw-r--r-- 1 root root 28 Apr 28 20:21 test.txt | 4 -rw-r--r-- 1 root root 28 Apr 28 20:21 test.txt | ||
root@docker-s-1vcpu-1gb-sfo2-01:/home/app/TrustRegistry5/TrustRegistry/wwwroot/.well-known/acme-challenge# | root@docker-s-1vcpu-1gb-sfo2-01:/home/app/TrustRegistry5/TrustRegistry/wwwroot/.well-known/acme-challenge# | ||
+ | |||
+ | ===Refresh TLS Certificate=== | ||
+ | # Run certbot to get updated certificate | ||
+ | # Rebuild pfx file with key and full chain cert. | ||
+ | # docker-compose down | ||
+ | # docker-compute up | ||
==References== | ==References== | ||
[[Category: Best Practice]] | [[Category: Best Practice]] |
Latest revision as of 18:58, 7 September 2025
Contents
Full Title or Meme
How to move an application from Visual Studio to a Docker Container on Digital Ocean.
Context
Most Docker solutions work well with Apache or NGINX, some special considerations are needed to get a simple task from from .NET on Visual Studio.
Problems
- Most sites now use Let's Encrypt Certificates which come with simple scripts for Apache, but no help for Windows.
Solutions
Digital Ocean
There are two distinct parts of the deployment and maintenance of the application plus a little bit of glue to stick one part to the other.
- This example shows use on the DigitalOcean provider accessing it with SSH.
- DigitalOcean Droplets are Linux-based virtual machines (VMs) that run on top of virtualized hardware.
- The default username is root on most operating systems, like Ubuntu and CentOS.
- To access ssh as root sign into https://cloud.digitalocean.com/ (The DigitalOcean control panel.)
- Select the droplet to modify - this needs to be done on first use or when the root password no longer works, which can happen if too many unsuccessful sign-in attempts were made.
- From the left side menu, click Access. Now use the console,or just reset the root password, which is typically less hassle even though you will need to change the p/w on first sign-in.
- Once the root password is set just open a bash terminal on any computer and enter >>ssh root@000.000.000.000 << using the ip address of the droplet.
- For example: ssh root@165.227.49.50
Deploying the App via Github.com
- An access token is required from GitHub.
Setting up a HTTPS connection
This section shows the use of Let's Encrypt certificates, which have a life of just 3 months, but is free. Other sites have a life of one year but charge money. Two-year certificates are no longer acceptable to many browsers.
- See the wiki page Let's Encrypt for more details.
The lines shown below should work:
cd /etc/letsencrypt/
- Set up letsencrypt
dig TXT _acme-challenge.trustregistry.us @165.227.49.50
; <<>> DiG 9.18.30-0ubuntu0.20.04.2-Ubuntu <<>> TXT _acme-challenge.trustregistry.us ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 14018 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 65494 ;; QUESTION SECTION: ;_acme-challenge.trustregistry.u. IN TXT
;; Query time: 4 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ;; WHEN: Tue Jul 29 01:51:15 UTC 2025 ;; MSG SIZE rcvd: 60
ssh root@165.227.49.50
root@docker-s-1vcpu-1gb-sfo2-01:/home/app/TrustRegistry5/TrustRegistry/wwwroot/.well-known/acme-challenge# touch 1OAp1b91V9qGv4FUkha_qLfF1pM82ZzqxGkl9SvKdHc: root@docker-s-1vcpu-1gb-sfo2-01:/home/app/TrustRegistry5/TrustRegistry/wwwroot/.well-known/acme-challenge# ls -als total 24 4 -rw-r--r-- 1 root root 88 Jul 29 02:24 '$CERTBOT_TOKEN' 4 drwxr-xr-x 2 root root 4096 Jul 29 05:22 . 4 drwxr-xr-x 3 root root 4096 Apr 28 23:30 .. 0 -rw-r--r-- 1 root root 0 Jul 29 05:22 1OAp1b91V9qGv4FUkha_qLfF1pM82ZzqxGkl9SvKdHc: 0 -rw-r--r-- 1 root root 0 Jul 28 22:39 ZXVo2IBYEG-7ImB3gY908s3vqXWO_BUdjcyx51Uv0eI: 4 -rw-r--r-- 1 root root 702 Apr 28 23:27 foobar.html 4 -rw-r--r-- 1 root root 88 Jul 29 00:20 temp 4 -rw-r--r-- 1 root root 28 Apr 28 20:21 test.txt root@docker-s-1vcpu-1gb-sfo2-01:/home/app/TrustRegistry5/TrustRegistry/wwwroot/.well-known/acme-challenge#
Refresh TLS Certificate
- Run certbot to get updated certificate
- Rebuild pfx file with key and full chain cert.
- docker-compose down
- docker-compute up