Skip to content

Commit 0d8f6b1

Browse files
committed
Adjust advanced doc
1 parent d7ea0b2 commit 0d8f6b1

File tree

1 file changed

+57
-44
lines changed

1 file changed

+57
-44
lines changed

docs/advanced.md

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,60 @@ The standard SuperStack replaces the stack in place.
77
Once your app is ready for production, consider adding a traffic-switcher in
88
front of your app.
99

10-
How it works:
10+
Here's how it works:
1111

1212
- We stop exposing ports in the `app` project.
13-
- A new `proxy` project is added, with ports open.
14-
- It's purpose is to direct traffic to the right application.
15-
- Apps are deployed completely separate to the live one.
13+
- A new `proxy` service is added, with ports open.
14+
- It's purpose is to direct traffic to the right application. (it also takes
15+
over TLS termination from the app layer).
16+
- Rather than upgrading the one app, apps are deployed separate to the live
17+
one. A fresh app every time.
1618

1719
This way, environments are _ephemeral, immutable and idempotent_.
1820

19-
The directory structure looks like:
20-
21+
```mermaid
22+
flowchart TD
23+
Proxy["<b>Proxy</b><br><i>Used for traffic shifting</i>"]
24+
Proxy --> App["<b>Application</b><br><i>API Gateway, Auth, APIs, Messaging, Workers, etc.</i>"]
25+
App --> Database["<b>Database</b><br><i>Optional</i>"]
2126
```
22-
proxy/
23-
compose.yaml
24-
app/
25-
a/
26-
compose.yaml
27-
.env
28-
b/
29-
compose.yaml
30-
.env
27+
28+
## 1. Adjust the Application
29+
30+
Remove the app's exposed ports, and connect to the proxy's network:
31+
32+
```yaml title="app/compose.yaml" hl_lines="6-11,13-15"
33+
services:
34+
caddy:
35+
build:
36+
context: ./caddy
37+
environment:
38+
CADDY_SITE_ADDRESS: ":80"
39+
networks:
40+
default:
41+
proxy_default:
42+
aliases:
43+
- ${COMPOSE_PROJECT_NAME}_caddy
44+
45+
networks:
46+
proxy_default:
47+
external: true
3148
```
3249
33-
## 1. Create a new project
50+
What's changed?
51+
52+
1. The exposed `ports` were removed.
53+
2. Caddy's site address has changed to `:80` (The application layer no longer
54+
handles TLS).
55+
3. We connect to the proxy's network, so the proxy can direct traffic to the
56+
app.
57+
4. A container alias was added. This alias allows the proxy to target this
58+
container, while still allowing Docker to manage the container name.
59+
60+
Additionally, the `CADDY_SITE_ADDRESS` env var can be removed from the
61+
development override file.
62+
63+
## 2. Create a new `proxy` project
3464

3565
From the root of the repository, create a new `proxy` project:
3666

@@ -75,37 +105,20 @@ services:
75105
reverse_proxy app_caddy:80
76106
```
77107

78-
## 2. Update the Application
108+
## Deployment
79109

80-
Remove the app's exposed ports, and connect to the proxy's network:
81-
82-
```yaml title="app/compose.yaml" hl_lines="6-13,15-17"
83-
services:
84-
caddy:
85-
build:
86-
context: ./caddy
87-
environment:
88-
CADDY_SITE_ADDRESS: ":80"
89-
networks:
90-
default:
91-
# This alias allows the proxy to target this container, while still
92-
# allowing Docker to manage the container name
93-
proxy_default:
94-
aliases:
95-
- ${COMPOSE_PROJECT_NAME}_caddy
110+
The directory structure looks like:
96111

97-
networks:
98-
proxy_default:
99-
external: true
100112
```
101-
102-
```yaml title="app/compose.override.yaml"
103-
# Development overrides
104-
105-
services:
106-
caddy:
107-
volumes:
108-
- ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
113+
proxy/
114+
compose.yaml
115+
app/
116+
a/
117+
compose.yaml
118+
.env
119+
b/
120+
compose.yaml
121+
.env
109122
```
110123

111124
## Deploy the Proxy

0 commit comments

Comments
 (0)