Skip to content

Commit 9e3ae4e

Browse files
committed
Adjust docs
1 parent 7627c9a commit 9e3ae4e

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

docs/bluegreen.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Blue/Green deployment runs two stacks side-by-side: one live, one idle. You
22
deploy to the idle stack, test it, and when ready, swap roles — giving
33
near-zero downtime and easy rollback.
44

5-
![Blue/Green](../assets/bluegreen.png)
5+
![Blue/Green](assets/bluegreen.png)
66

7-
## 1. Adjustments to the Compose file
7+
## 1. Adjust the Compose file
88

9-
Remove the exposed ports by removing the Caddy `ports:` section in
10-
`compose.yaml`.
9+
Remove the Caddy `ports:` section in `compose.yaml`. Instead of exposing ports
10+
in the stacks, a "front proxy" will expose ports and proxy to the active stack.
1111

1212
Set `CADDY_SITE_ADDRESS` to only `:80` (leaving TLS termination to the front
1313
proxy):
@@ -31,8 +31,8 @@ volumes:
3131
3232
## 2. Add a Front Proxy
3333
34-
The front proxy is a single container that binds `:80` and `:443` on the server
35-
and routes requests into either the Blue or Green stack.
34+
The _front proxy_ is a single container that binds ports `80` and `443` on the
35+
server and routes requests into either the Blue or Green stack.
3636

3737
On the server, create a simple `Caddyfile`:
3838

@@ -73,16 +73,33 @@ docker run -d \
7373
caddy:2
7474
```
7575

76-
## 4. Deploying
76+
## 3. Deploying/Upgrading
7777

78-
Update the idle stack:
78+
Deploying is the same as [before](deploying.md), but now we're deploying the
79+
_idle stack_. For this example, `green` is idle so that's the one we're
80+
deploying.
81+
82+
Create `blue` and `green` directories on the server and deploy `compose.yaml`
83+
into the idle stack's directory:
7984

8085
```sh
86+
scp compose.yaml youruser@yourserver:green/compose.yaml
87+
```
88+
89+
Shell into the server and bring up the idle stack:
90+
91+
```sh
92+
cd green
8193
docker compose pull
82-
docker compose -p green up -d
94+
docker compose up -d
8395
```
8496

85-
Edit the front proxy's config to flip traffic:
97+
Docker will use the directory name `green` as the project name, creating
98+
different containers, volumes and networks than the `blue` stack.
99+
100+
### Flip traffic
101+
102+
Point traffic to the `green` stack, and make `blue` idle:
86103

87104
```caddyfile title="Caddyfile"
88105
api.myapp.com {
@@ -94,12 +111,12 @@ next.myapp.com {
94111
}
95112
```
96113

97-
Restart Caddy:
114+
Reload the front proxy's config:
98115

99116
```sh
100117
docker exec front-proxy caddy reload
101118
```
102119

103120
Cutover is instant. Green is now live, and Blue is the idle stack.
104121

105-
And rollback is simple: flip the `Caddyfile` back and `caddy reload`.
122+
And rollback is simple: flip the `Caddyfile` back and `caddy reload` again.

docs/deploying.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Container Registry account), for example:
1616
caddy:
1717
build:
1818
context: ./caddy
19-
image: ghcr.io/youruser/yourapp-caddy
19+
image: ghcr.io/youruser/yourapp-caddy:0.1.0
2020

2121
postgres:
2222
build:
2323
context: ./postgres
24-
image: ghcr.io/youruser/yourapp-postgres
24+
image: ghcr.io/youruser/yourapp-postgres:0.1.0
2525
```
2626
2727
## 🛠️ 2. Build and Push your Images
@@ -35,30 +35,26 @@ docker compose push
3535

3636
## 📦 3. Deploy the Compose File
3737

38-
Copy `compose.yaml` to your server:
38+
Copy `compose.yaml` to the server:
3939

4040
```sh
4141
scp compose.yaml youruser@yourserver:
4242
```
4343

4444
## 🚀 4. Launch your Stack
4545

46-
SSH into your server and bring up the stack.
46+
SSH into your server and bring up the stack:
4747

48-
For production, avoid using `.env` files. Instead, set secrets directly:
49-
50-
```sh title=".env"
51-
JWT_SECRET=your-secret \
52-
CADDY_PORT=80 \
53-
PG_USER=admin \
54-
PG_PASS=supersecret \
55-
POSTGREST_AUTHENTICATOR_PASS=supersecret \
48+
```sh
49+
docker compose pull
5650
docker compose up -d
5751
```
5852

59-
> 💡 Avoid leaking secrets by disabling shell history.
53+
Docker compose needs secrets, so you have a few options:
6054

61-
Alternatively, use environment injection in your CI/CD.
55+
1. Write secrets to a `.env` file in plain-text (be sure to `chmod 600 .env`).
56+
1. Set env vars in the docker compose command
57+
1. Alternatively, use environment injection in your CI/CD.
6258

6359
---
6460

docs/gettingstarted.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ This `.env` file is used to configure:
6464
- **Ports** – Adjust the exposed ports (specifically, Caddy's) depending on
6565
environment or application (you may bring up multiple).
6666

67-
> ⚠️ The .env file is for development only. Never store real secrets in version
68-
> control or production. Use CI/CD environment variables or a secrets manager
69-
> instead.
67+
> ⚠️ Never store secrets in version control.
7068
7169
## 3. Start the Stack
7270

0 commit comments

Comments
 (0)