Skip to content

Commit 0d05673

Browse files
doc: update document
1 parent 03f316e commit 0d05673

File tree

1 file changed

+104
-67
lines changed

1 file changed

+104
-67
lines changed

docker/README.md

Lines changed: 104 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,106 @@
1-
### Docker - Build at Building Server
2-
1+
You need three folders:
2+
3+
0. server for setup - generate your token and seed the data
4+
- `docker/stack-auth-setup`
5+
```sh
6+
git clone https://github.com/ShaunDyson-leetcode/stack.git
7+
```
8+
9+
1. server for builder - build your own token
10+
- `docker/stack-auth-builder`
11+
```sh
12+
git clone https://github.com/ShaunDyson-leetcode/stack.git
13+
```
14+
2. server for services - run your docker
15+
- `docker/stack-auth-services`
16+
```sh
17+
wget https://github.com/ShaunDyson-leetcode/stack/archive/refs/heads/dev.zip -O repo.zip && unzip -j repo.zip "stack-dev/docker/stack-auth-services/*" -d stack-auth-services && rm repo.zip
18+
```
19+
20+
### Setup
21+
22+
Go to folder `docker/stack-auth-setup`
23+
24+
0. **Pre-install**
25+
```sh
26+
cd docker/stack-auth-setup
27+
pnpm i --ignore-workspace
28+
```
329
1. **Update Environment Variables**
430
- Navigate to `docker/setup` and update the `.env` file:
531
```sh
6-
cd docker/setup
732
cp .env.development .env
8-
cd ../..
933
```
10-
1134
2. **Create Tokens**
12-
- Install dependencies and run the key generation script:
35+
- Run the key generation script:
1336
```sh
14-
cd docker/setup
15-
pnpm i --ignore-workspace
1637
pnpm tsx scripts/generateKeys.ts
17-
cd ../..
1838
```
19-
39+
- Copy them to `.env` under the `generated by generateKeys.ts` section.
2040
3. **Configure Hosts**
21-
- Set the following environment variables:
22-
```env
23-
NEXT_PUBLIC_STACK_URL=https://api.stack-auth.internal
24-
NEXT_PUBLIC_STACK_SVIX_SERVER_URL=https://svix-api.stack-auth.internal
25-
NEXT_PUBLIC_STACK_HEAD_TAGS=[{ "tagName": "script", "attributes": {}, "innerHTML": "// insert head tags here" }]
26-
```
27-
28-
4. **Sentry Integration**
2941
- Set up Sentry variables according to [Sentry's documentation](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup):
3042
```env
3143
NEXT_PUBLIC_SENTRY_DSN=
3244
NEXT_PUBLIC_SENTRY_ORG=
3345
NEXT_PUBLIC_SENTRY_PROJECT=
3446
SENTRY_AUTH_TOKEN=
3547
```
48+
- The following environment variables are not necessary to update:
49+
```env
50+
NEXT_PUBLIC_STACK_URL=https://api.stack-auth.internal
51+
NEXT_PUBLIC_STACK_SVIX_SERVER_URL=https://svix-api.stack-auth.internal
52+
NEXT_PUBLIC_STACK_HEAD_TAGS=[{ "tagName": "script", "attributes": {}, "innerHTML": "// insert head tags here" }]
3653
37-
5. **Generate Builder Environment**
54+
# db connection
55+
STACK_DATABASE_CONNECTION_STRING=postgres://postgres:${POSTGRES_STACKFRAME_PASSWORD}@127.0.0.1:5432/stackframe
56+
STACK_DIRECT_DATABASE_CONNECTION_STRING=postgres://postgres:${POSTGRES_STACKFRAME_PASSWORD}@127.0.0.1:5432/stackframe
57+
```
58+
- Setup db connection (Optional if you use our docker server setup)
59+
- It will be used to deploy prisma data.
60+
4. **Generate Builder Environment file**
3861
- Run the builder environment generation script:
3962
```sh
40-
cd docker/setup
4163
pnpm dotenv -c -- tsx scripts/generateBuilderEnv.ts
42-
cd ../..
43-
```
44-
45-
6. **Build Docker Images**
46-
- Navigate to `docker/builder` and build:
47-
```sh
48-
cd docker/builder
49-
docker compose build
50-
cd ..
51-
```
52-
53-
---
54-
55-
### Services at Deployment Server
56-
57-
1. **Prepare Environment Files**
58-
- Copy the `.env.dashboard` configuration:
59-
```sh
60-
cd docker/setup
61-
pnpm dotenv -c -- tsx scripts/generateDashboardEnv.ts
62-
cd ../..
6364
```
65+
- Copy this to the builder server.
6466
65-
2. **Configure `.env` File**
67+
5. **Prepare Services Environment Files**
6668
- Populate `.env` in `docker/services` with required values from `setup/.env`:
6769
- `POSTGRES_STACKFRAME_PASSWORD`
6870
- `POSTGRES_SVIX_PASSWORD`
6971
- `SVIX_JWT_SECRET`
70-
71-
3. **Configure `.env.backend` File**
72-
- Include necessary secrets like `STACK_SERVER_SECRET` and `STACK_SVIX_API_KEY`.
73-
- Generate the `STACK_SVIX_API_KEY`:
74-
```sh
75-
docker compose up svix-server -d
76-
docker exec -it <container_id> sh
77-
svix-server jwt generate
78-
```
79-
80-
4. **Configure Sentry Variables**
81-
- Copy Sentry-related variables into `.env.sentry` from `setup/.env`.
82-
83-
5. **SSL Certificates**
84-
- Place SSL files in the `certs` directory.
85-
86-
6. **Start Docker Services**
87-
- Start services in detached mode:
72+
- Copy the `.env.dashboard` configuration:
8873
```sh
89-
cd docker/services
90-
docker compose up -d
74+
pnpm dotenv -c -- tsx scripts/generateDashboardEnv.ts
9175
```
92-
93-
7. **Initialize Data**
76+
- Uncomment `DEPTH_ZERO_SELF_SIGNED_CERT` if self-trust SSL is needed.
77+
- Copy the `.env.backend` configuration:
78+
- Include necessary secrets like `STACK_SERVER_SECRET` and `STACK_SVIX_API_KEY`.
79+
- Generate the `STACK_SVIX_API_KEY`:
80+
```sh
81+
docker compose up svix-server -d
82+
docker exec -it <container_id> sh
83+
svix-server jwt generate
84+
```
85+
- **Configure Sentry Variables**
86+
Copy Sentry-related variables into `.env.sentry` from `setup/.env`.
87+
6. **Initialize Data**
88+
- After starting services:
89+
- Update db IP for your services server.
9490
- If deploying and building on the same server, run initialization:
9591
```sh
96-
cd docker/setup
92+
cd docker/stack-auth-setup
9793
cp -r ../../apps/backend/prisma/ .
9894
pnpm prisma generate
9995
pnpm prisma migrate deploy
10096
pnpm dotenv -c -- tsx scripts/seed.ts
10197
```
102-
- Use `pnpm prisma studio` to update ProjectUser, adding `"internal"` to `managedProjectIds`.
98+
- Use `pnpm prisma studio` to update `ProjectUser`, adding `"internal"` to `managedProjectIds`.
99+
100+
7. **Network**
101+
- Add `https://stack-auth.internal`, `svix-api.stack-auth.internal`, `api.stack-auth.internal` to your DNS hosts.
102+
- Expose ports:
103+
- 443
103104
104105
8. **User Signup**
105106
- Access `https://stack-auth.internal` and complete the signup process.
@@ -109,4 +110,40 @@
109110
- In the Admin project:
110111
- Disable localhost.
111112
- Add `https://stack-auth.internal` to domains.
112-
- Set user to "verified" for otp.
113+
- Set user to "verified" for OTP.
114+
115+
### Build
116+
Go to the builder server.
117+
118+
**Build Docker Images**
119+
- Navigate to `docker/builder` and build:
120+
```sh
121+
docker compose build
122+
```
123+
124+
### Start Services
125+
126+
0. **SSL Certificates**
127+
- Place SSL files in the `certs` directory.
128+
```sh
129+
openssl genrsa -out stack-auth.key 2048
130+
openssl req -new -key stack-auth.key -out stack-auth.csr
131+
openssl x509 -req -days 365 -in stack-auth.csr -signkey stack-auth.key -out stack-auth.crt
132+
```
133+
134+
1. **Start Docker Services**
135+
- Pull `stack-auth/dashboard` and `stack-auth/backend`.
136+
- Start services in detached mode:
137+
```sh
138+
docker compose up -d
139+
```
140+
141+
### Questions!
142+
143+
1. Self-host and self-signed cert
144+
145+
- Dashboard `DEPTH_ZERO_SELF_SIGNED_CERT`
146+
- Browser visit:
147+
- `https://stack-auth.internal`
148+
- `svix-api.stack-auth.internal`
149+
- `api.stack-auth.internal`

0 commit comments

Comments
 (0)