Skip to content

Commit 60f58d5

Browse files
authored
Microsoft SQL Server with Let's Encrypt Using Docker Compose
1 parent efe16e7 commit 60f58d5

File tree

5 files changed

+182
-114
lines changed

5 files changed

+182
-114
lines changed

.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Traefik Variables
2-
TRAEFIK_IMAGE_TAG=traefik:2.9
2+
TRAEFIK_IMAGE_TAG=traefik:3.2
3+
# Set the log level (DEBUG, INFO, WARN, ERROR)
34
TRAEFIK_LOG_LEVEL=WARN
4-
TRAEFIK_ACME_EMAIL=callvaldemar@gmail.com
5+
# The email address used by Let's Encrypt for renewal notices
6+
TRAEFIK_ACME_EMAIL=admin@example.com
7+
# The hostname used to access the Traefik dashboard and to configure domain-specific rules
58
TRAEFIK_HOSTNAME=traefik.mssql.heyvaldemar.net
69
# Basic Authentication for Traefik Dashboard
710
# Username: traefikadmin

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/00-deployment-verification.yml

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,59 @@ jobs:
1212
deploy-and-test:
1313
runs-on: ubuntu-latest
1414

15+
env:
16+
NETWORK_ONE: mssql-network
17+
NETWORK_TWO: traefik-network
18+
DOCKER_COMPOSE_FILE: mssql-server-traefik-letsencrypt-docker-compose.yml
19+
APP_HOSTNAME: mssql.heyvaldemar.net
20+
APP_TRAEFIK_HOSTNAME: traefik.romm.heyvaldemar.net
21+
COMPOSE_PROJECT_NAME: romm
22+
1523
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v4
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Create necessary Docker networks
28+
run: |
29+
docker network create $NETWORK_ONE || true
30+
docker network create $NETWORK_TWO || true
1831
19-
- name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v3
32+
- name: Start up services using Docker Compose
33+
run: docker compose -f $DOCKER_COMPOSE_FILE -p $COMPOSE_PROJECT_NAME up -d
2134

22-
- name: Create necessary Docker networks
23-
run: |
24-
docker network create traefik-network || true
25-
docker network create mssql-server-network || true
35+
- name: Modify /etc/hosts for internal routing
36+
run: |
37+
echo "127.0.0.1 $APP_HOSTNAME" | sudo tee -a /etc/hosts
38+
echo "127.0.0.1 $APP_TRAEFIK_HOSTNAME" | sudo tee -a /etc/hosts
2639
27-
- name: Start up services using Docker Compose
28-
run: docker compose -f mssql-server-traefik-letsencrypt-docker-compose.yml up -d
40+
- name: Print Docker Compose services status
41+
run: docker ps
2942

30-
- name: Modify /etc/hosts for internal routing
31-
run: |
32-
echo "127.0.0.1 mssql.heyvaldemar.net" | sudo tee -a /etc/hosts
33-
echo "127.0.0.1 traefik.mssql.heyvaldemar.net" | sudo tee -a /etc/hosts
43+
- name: Wait for SQL Server to be ready
44+
run: |
45+
echo "Checking if SQL Server port is open..."
46+
timeout 5m bash -c 'while ! nc -z $APP_HOSTNAME 1433; do \
47+
echo "Waiting for SQL Server to be ready..."; \
48+
sleep 10; \
49+
done'
3450
35-
- name: Print Docker Compose services status
36-
run: docker ps
51+
- name: Wait for the Traefik dashboard to be ready
52+
run: |
53+
echo "Checking the routing and availability of the Traefik dashboard..."
54+
timeout 5m bash -c 'while ! curl -fsSLk --write-out "%{http_code}" --output /dev/null "https://$APP_TRAEFIK_HOSTNAME" | grep -E "200|401"; do \
55+
echo "Waiting for the application to be ready..."; \
56+
sleep 10; \
57+
done'
3758
38-
- name: Wait for the application to be ready via Traefik
39-
run: |
40-
echo "Checking the routing and availability of application via Traefik..."
41-
timeout 5m bash -c 'while ! nc -z mssql.heyvaldemar.net 1433; do echo "Waiting for MS SQL Server to be ready..."; sleep 10; done'
59+
- name: Inspect Network Configuration
60+
run: |
61+
docker network inspect $NETWORK_ONE
62+
docker network inspect $NETWORK_TWO
4263
43-
- name: Inspect Network Configuration
44-
run: |
45-
docker network inspect mssql-server-network
46-
docker network inspect traefik-network
64+
- name: Show container logs on failure
65+
if: failure()
66+
run: docker compose -f $DOCKER_COMPOSE_FILE -p $COMPOSE_PROJECT_NAME logs
4767

48-
- name: Shutdown Docker Compose services
49-
if: always()
50-
run: docker compose -f mssql-server-traefik-letsencrypt-docker-compose.yml down
68+
- name: Shutdown Docker Compose services
69+
if: always()
70+
run: docker compose -f $DOCKER_COMPOSE_FILE -p $COMPOSE_PROJECT_NAME down

README.md

Lines changed: 79 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,82 @@ Deploy Microsoft SQL Server using Docker Compose:
2424

2525
💡 For confirming database connectivity, consider employing [DBeaver](https://dbeaver.io/), a robust database management tool. Connect using the `sa` user credentials and the password that was previously set in the `.env` file. This approach ensures a secure and efficient verification process.
2626

27-
# Author
28-
29-
I’m Vladimir Mikhalev, the [Docker Captain](https://www.docker.com/captains/vladimir-mikhalev/), but my friends can call me Valdemar.
30-
31-
🌐 My [website](https://www.heyvaldemar.com/) with detailed IT guides\
32-
🎬 Follow me on [YouTube](https://www.youtube.com/channel/UCf85kQ0u1sYTTTyKVpxrlyQ?sub_confirmation=1)\
33-
🐦 Follow me on [Twitter](https://twitter.com/heyValdemar)\
34-
🎨 Follow me on [Instagram](https://www.instagram.com/heyvaldemar/)\
35-
🧵 Follow me on [Threads](https://www.threads.net/@heyvaldemar)\
36-
🐘 Follow me on [Mastodon](https://mastodon.social/@heyvaldemar)\
37-
🧊 Follow me on [Bluesky](https://bsky.app/profile/heyvaldemar.bsky.social)\
38-
🎸 Follow me on [Facebook](https://www.facebook.com/heyValdemarFB/)\
39-
🎥 Follow me on [TikTok](https://www.tiktok.com/@heyvaldemar)\
40-
💻 Follow me on [LinkedIn](https://www.linkedin.com/in/heyvaldemar/)\
41-
🐈 Follow me on [GitHub](https://github.com/heyvaldemar)
42-
43-
# Communication
44-
45-
👾 Chat with IT pros on [Discord](https://discord.gg/AJQGCCBcqf)\
46-
📧 Reach me at ask@sre.gg
47-
48-
# Give Thanks
49-
50-
💎 Support on [GitHub](https://github.com/sponsors/heyValdemar)\
51-
🏆 Support on [Patreon](https://www.patreon.com/heyValdemar)\
52-
🥤 Support on [BuyMeaCoffee](https://www.buymeacoffee.com/heyValdemar)\
53-
🍪 Support on [Ko-fi](https://ko-fi.com/heyValdemar)\
54-
💖 Support on [PayPal](https://www.paypal.com/paypalme/heyValdemarCOM)
27+
## Author
28+
29+
hey everyone,
30+
31+
💾 I’ve been in the IT game for over 20 years, cutting my teeth with some big names like [IBM](https://www.linkedin.com/in/heyvaldemar/), [Thales](https://www.linkedin.com/in/heyvaldemar/), and [Amazon](https://www.linkedin.com/in/heyvaldemar/). These days, I wear the hat of a DevOps Consultant and Team Lead, but what really gets me going is Docker and container technology - I’m kind of obsessed!
32+
33+
💛 I have my own IT [blog](https://www.heyvaldemar.com/), where I’ve built a [community](https://discord.gg/AJQGCCBcqf) of DevOps enthusiasts who share my love for all things Docker, containers, and IT technologies in general. And to make sure everyone can jump on this awesome DevOps train, I write super detailed guides (seriously, they’re foolproof!) that help even newbies deploy and manage complex IT solutions.
34+
35+
🚀 My dream is to empower every single person in the DevOps community to squeeze every last drop of potential out of Docker and container tech.
36+
37+
🐳 As a [Docker Captain](https://www.docker.com/captains/vladimir-mikhalev/), I’m stoked to share my knowledge, experiences, and a good dose of passion for the tech. My aim is to encourage learning, innovation, and growth, and to inspire the next generation of IT whizz-kids to push Docker and container tech to its limits.
38+
39+
Let’s do this together!
40+
41+
## My 2D Portfolio
42+
43+
🕹️ Click into [sre.gg](https://www.sre.gg/) — my virtual space is a 2D pixel-art portfolio inviting you to interact with elements that encapsulate the milestones of my DevOps career.
44+
45+
## My Courses
46+
47+
🎓 Dive into my [comprehensive IT courses](https://www.heyvaldemar.com/courses/) designed for enthusiasts and professionals alike. Whether you're looking to master Docker, conquer Kubernetes, or advance your DevOps skills, my courses provide a structured pathway to enhancing your technical prowess.
48+
49+
🔑 [Each course](https://www.udemy.com/user/heyvaldemar/) is built from the ground up with real-world scenarios in mind, ensuring that you gain practical knowledge and hands-on experience. From beginners to seasoned professionals, there's something here for everyone to elevate their IT skills.
50+
51+
## My Services
52+
53+
💼 Take a look at my [service catalog](https://www.heyvaldemar.com/services/) and find out how we can make your technological life better. Whether it's increasing the efficiency of your IT infrastructure, advancing your career, or expanding your technological horizons — I'm here to help you achieve your goals. From DevOps transformations to building gaming computers — let's make your technology unparalleled!
54+
55+
## Patreon Exclusives
56+
57+
🏆 Join my [Patreon](https://www.patreon.com/heyvaldemar) and dive deep into the world of Docker and DevOps with exclusive content tailored for IT enthusiasts and professionals. As your experienced guide, I offer a range of membership tiers designed to suit everyone from newbies to IT experts.
58+
59+
## My Recommendations
60+
61+
📕 Check out my collection of [essential DevOps books](https://kit.co/heyvaldemar/essential-devops-books)\
62+
🖥️ Check out my [studio streaming and recording kit](https://kit.co/heyvaldemar/my-studio-streaming-and-recording-kit)\
63+
📡 Check out my [streaming starter kit](https://kit.co/heyvaldemar/streaming-starter-kit)
64+
65+
## Follow Me
66+
67+
🎬 [YouTube](https://www.youtube.com/channel/UCf85kQ0u1sYTTTyKVpxrlyQ?sub_confirmation=1)\
68+
🐦 [X / Twitter](https://twitter.com/heyvaldemar)\
69+
🎨 [Instagram](https://www.instagram.com/heyvaldemar/)\
70+
🐘 [Mastodon](https://mastodon.social/@heyvaldemar)\
71+
🧵 [Threads](https://www.threads.net/@heyvaldemar)\
72+
🎸 [Facebook](https://www.facebook.com/heyvaldemarFB/)\
73+
🧊 [Bluesky](https://bsky.app/profile/heyvaldemar.bsky.social)\
74+
🎥 [TikTok](https://www.tiktok.com/@heyvaldemar)\
75+
💻 [LinkedIn](https://www.linkedin.com/in/heyvaldemar/)\
76+
📣 [daily.dev Squad](https://app.daily.dev/squads/devopscompass)\
77+
🧩 [LeetCode](https://leetcode.com/u/heyvaldemar/)\
78+
🐈 [GitHub](https://github.com/heyvaldemar)
79+
80+
## Community of IT Experts
81+
82+
👾 [Discord](https://discord.gg/AJQGCCBcqf)
83+
84+
## Refill My Coffee Supplies
85+
86+
💖 [PayPal](https://www.paypal.com/paypalme/heyvaldemarCOM)\
87+
🏆 [Patreon](https://www.patreon.com/heyvaldemar)\
88+
💎 [GitHub](https://github.com/sponsors/heyvaldemar)\
89+
🥤 [BuyMeaCoffee](https://www.buymeacoffee.com/heyvaldemar)\
90+
🍪 [Ko-fi](https://ko-fi.com/heyvaldemar)
91+
92+
🌟 **Bitcoin (BTC):** bc1q2fq0k2lvdythdrj4ep20metjwnjuf7wccpckxc\
93+
🔹 **Ethereum (ETH):** 0x76C936F9366Fad39769CA5285b0Af1d975adacB8\
94+
🪙 **Binance Coin (BNB):** bnb1xnn6gg63lr2dgufngfr0lkq39kz8qltjt2v2g6\
95+
💠 **Litecoin (LTC):** LMGrhx8Jsx73h1pWY9FE8GB46nBytjvz8g
96+
97+
<div align="center">
98+
99+
### Show some 💜 by starring some of the [repositories](https://github.com/heyValdemar?tab=repositories)!
100+
101+
![octocat](https://user-images.githubusercontent.com/10498744/210113490-e2fad07f-4488-4da8-a656-b9abbdd8cb26.gif)
102+
103+
</div>
104+
105+
![footer](https://user-images.githubusercontent.com/10498744/210157572-1fca0242-8af2-46a6-bfa3-666ffd40ebde.svg)

mssql-server-traefik-letsencrypt-docker-compose.yml

Lines changed: 40 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,3 @@
1-
# Microsoft SQL Server with Let's Encrypt Using Docker Compose
2-
3-
# The complete installation guide is available on my website https://www.heyvaldemar.com/install-mssql-server-using-docker-compose/
4-
5-
# Change variables in the `.env` to meet your requirements.
6-
# Note that the `.env` file should be in the same directory as `mssql-server-traefik-letsencrypt-docker-compose.yml`.
7-
8-
# Create networks for your services before deploying the configuration using the commands:
9-
# `docker network create traefik-network`
10-
# `docker network create mssql-server-network`
11-
12-
# Deploy Microsoft SQL Server using Docker Compose:
13-
# `docker compose -f mssql-server-traefik-letsencrypt-docker-compose.yml -p mssql-server up -d`
14-
15-
# For confirming database connectivity, consider employing DBeaver https://dbeaver.io/, a robust database management tool.
16-
# Connect using the `sa` user credentials and the password that was previously set in the `.env` file. This approach ensures a secure and efficient verification process.
17-
18-
# Author
19-
# I’m Vladimir Mikhalev, the Docker Captain, but my friends can call me Valdemar.
20-
# https://www.docker.com/captains/vladimir-mikhalev/
21-
22-
# My website with detailed IT guides: https://www.heyvaldemar.com/
23-
# Follow me on YouTube: https://www.youtube.com/channel/UCf85kQ0u1sYTTTyKVpxrlyQ?sub_confirmation=1
24-
# Follow me on Twitter: https://twitter.com/heyValdemar
25-
# Follow me on Instagram: https://www.instagram.com/heyvaldemar/
26-
# Follow me on Threads: https://www.threads.net/@heyvaldemar
27-
# Follow me on Mastodon: https://mastodon.social/@heyvaldemar
28-
# Follow me on Bluesky: https://bsky.app/profile/heyvaldemar.bsky.social
29-
# Follow me on Facebook: https://www.facebook.com/heyValdemarFB/
30-
# Follow me on TikTok: https://www.tiktok.com/@heyvaldemar
31-
# Follow me on LinkedIn: https://www.linkedin.com/in/heyvaldemar/
32-
# Follow me on GitHub: https://github.com/heyvaldemar
33-
34-
# Communication
35-
# Chat with IT pros on Discord: https://discord.gg/AJQGCCBcqf
36-
# Reach me at ask@sre.gg
37-
38-
# Give Thanks
39-
# Support on GitHub: https://github.com/sponsors/heyValdemar
40-
# Support on Patreon: https://www.patreon.com/heyValdemar
41-
# Support on BuyMeaCoffee: https://www.buymeacoffee.com/heyValdemar
42-
# Support on Ko-fi: https://ko-fi.com/heyValdemar
43-
# Support on PayPal: https://www.paypal.com/paypalme/heyValdemarCOM
44-
451
networks:
462
mssql-server-network:
473
external: true
@@ -71,11 +27,17 @@ services:
7127
retries: 3
7228
start_period: 60s
7329
labels:
30+
# Enable Traefik for this container
7431
- "traefik.enable=true"
32+
# Define TCP router rules for MS SQL to match all incoming requests (HostSNI)
7533
- "traefik.tcp.routers.mssql.rule=HostSNI(`*`)"
34+
# Assign the MS SQL router to a named Traefik service
7635
- "traefik.tcp.routers.mssql.service=mssql"
36+
# Use the 'MS SQL' (custom) entry point
7737
- "traefik.tcp.routers.mssql.entrypoints=sql"
78-
- "traefik.tcp.services.mssql.loadbalancer.server.port=1433"
38+
# Define the internal container port for routing to the MS SQL service
39+
- "traefik.tcp.services.mssql.loadbalancer.server.port=11434"
40+
# Specify which Docker network Traefik should use for routing
7941
- "traefik.docker.network=traefik-network"
8042
restart: unless-stopped
8143
depends_on:
@@ -85,28 +47,43 @@ services:
8547
traefik:
8648
image: ${TRAEFIK_IMAGE_TAG}
8749
command:
50+
# Set the log level (DEBUG, INFO, WARN, ERROR)
8851
- "--log.level=${TRAEFIK_LOG_LEVEL}"
89-
- "--accesslog=true"
52+
# Enable the built-in API and web-based dashboard on /dashboard
9053
- "--api.dashboard=true"
91-
- "--api.insecure=true"
54+
# Enable the /ping endpoint so we can health-check Traefik
9255
- "--ping=true"
56+
# Assign the /ping endpoint to a dedicated entry point on port 8082
9357
- "--ping.entrypoint=ping"
94-
- "--entryPoints.ping.address=:8082"
95-
- "--entryPoints.web.address=:80"
96-
- "--entryPoints.websecure.address=:443"
58+
- "--entrypoints.ping.address=:8082"
59+
# Define the primary HTTP entry point on port 80
60+
- "--entrypoints.web.address=:80"
61+
# Define the secure (HTTPS) entry point on port 443
62+
- "--entrypoints.websecure.address=:443"
9763
- "--entryPoints.sql.address=:1433"
64+
# Enable the Docker provider to detect containers and their labels
9865
- "--providers.docker=true"
66+
# Point Traefik to the Docker socket
9967
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
100-
- "--providers.docker.exposedByDefault=false"
68+
# Prevent automatic exposure of all containers; only expose containers
69+
# with "traefik.enable=true"
70+
- "--providers.docker.exposedbydefault=false"
71+
# Use ACME (Let's Encrypt) to generate/renew certificates via TLS challenge
10172
- "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
73+
# The email address used by Let's Encrypt for renewal notices
10274
- "--certificatesresolvers.letsencrypt.acme.email=${TRAEFIK_ACME_EMAIL}"
75+
# The file where ACME certificates are stored inside the container
10376
- "--certificatesresolvers.letsencrypt.acme.storage=/etc/traefik/acme/acme.json"
77+
# Enable Prometheus metrics
10478
- "--metrics.prometheus=true"
79+
# Configure Prometheus histogram buckets
10580
- "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
106-
- "--global.checkNewVersion=true"
107-
- "--global.sendAnonymousUsage=false"
81+
# Check for newer Traefik versions and optionally log that info
82+
- "--global.checknewversion=true"
83+
# Disable sending anonymous usage data to the Traefik maintainers
84+
- "--global.sendanonymoususage=false"
10885
volumes:
109-
- /var/run/docker.sock:/var/run/docker.sock
86+
- /var/run/docker.sock:/var/run/docker.sock:ro
11087
- traefik-certificates:/etc/traefik/acme
11188
networks:
11289
- traefik-network
@@ -121,16 +98,22 @@ services:
12198
retries: 3
12299
start_period: 5s
123100
labels:
101+
# Enable Traefik for this container.
124102
- "traefik.enable=true"
103+
# A router to expose the Traefik dashboard
125104
- "traefik.http.routers.dashboard.rule=Host(`${TRAEFIK_HOSTNAME}`)"
126-
- "traefik.http.routers.dashboard.service=api@internal"
127105
- "traefik.http.routers.dashboard.entrypoints=websecure"
128-
- "traefik.http.services.dashboard.loadbalancer.server.port=8080"
129106
- "traefik.http.routers.dashboard.tls=true"
130107
- "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
131-
- "traefik.http.services.dashboard.loadbalancer.passhostheader=true"
108+
- "traefik.http.routers.dashboard.service=api@internal"
109+
# asic Authentication for the Traefik dashboard
132110
- "traefik.http.routers.dashboard.middlewares=authtraefik"
133111
- "traefik.http.middlewares.authtraefik.basicauth.users=${TRAEFIK_BASIC_AUTH}"
112+
# Specify the internal server port to the dashboard service
113+
- "traefik.http.services.dashboard.loadbalancer.server.port=8080"
114+
# Pass the original Host header to the backend
115+
- "traefik.http.services.dashboard.loadbalancer.passhostheader=true"
116+
# HTTP -> HTTPS redirect for all hosts
134117
- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
135118
- "traefik.http.routers.http-catchall.entrypoints=web"
136119
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"

0 commit comments

Comments
 (0)