Skip to content

Commit eeae23a

Browse files
authored
docs: add migrate service to self hosting guide (#425)
* docs: add migrate service to self hosting guide * chore: remove build from readme compose
1 parent d81950b commit eeae23a

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

README.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,39 +57,61 @@ The easiest way to deploy Kan is through Railway. We've partnered with Railway t
5757

5858
### Docker Compose
5959

60-
Alternatively, you can self-host Kan with Docker Compose. This will set up everything for you including your postgres database.
60+
Alternatively, you can self-host Kan with Docker Compose. This will set up everything for you including your postgres database and automatically run migrations.
6161

62-
1. Create a new file called `docker-compose.yml` and paste the following configuration:
62+
1. Create a `.env` file with your environment variables (see [Environment Variables](#environment-variables-) section below)
63+
64+
2. Use the provided `docker-compose.yml` file or create your own with the following configuration:
6365

6466
```yaml
6567
services:
68+
migrate:
69+
image: ghcr.io/kanbn/kan-migrate:latest
70+
container_name: kan-migrate
71+
networks:
72+
- kan-network
73+
environment:
74+
- POSTGRES_URL=${POSTGRES_URL}
75+
depends_on:
76+
postgres:
77+
condition: service_healthy
78+
restart: "no"
79+
6680
web:
6781
image: ghcr.io/kanbn/kan:latest
6882
container_name: kan-web
6983
ports:
70-
- "3000:3000"
84+
- "${WEB_PORT:-3000}:3000"
7185
networks:
7286
- kan-network
87+
env_file:
88+
- .env
7389
environment:
74-
NEXT_PUBLIC_BASE_URL: http://localhost:3000
75-
BETTER_AUTH_SECRET: your_auth_secret
76-
POSTGRES_URL: postgresql://kan:your_postgres_password@postgres:5432/kan_db
77-
NEXT_PUBLIC_ALLOW_CREDENTIALS: true
90+
- NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL}
91+
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
92+
- POSTGRES_URL=${POSTGRES_URL}
93+
- NEXT_PUBLIC_ALLOW_CREDENTIALS=true
7894
depends_on:
79-
- postgres
95+
migrate:
96+
condition: service_completed_successfully
8097
restart: unless-stopped
8198

8299
postgres:
83100
image: postgres:15
84101
container_name: kan-db
85102
environment:
86-
POSTGRES_DB: kan_db
87-
POSTGRES_USER: kan
88-
POSTGRES_PASSWORD: your_postgres_password
103+
- POSTGRES_DB=kan_db
104+
- POSTGRES_USER=kan
105+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
89106
ports:
90107
- 5432:5432
91108
volumes:
92109
- kan_postgres_data:/var/lib/postgresql/data
110+
healthcheck:
111+
test: ["CMD-SHELL", "pg_isready -U kan -d kan_db"]
112+
interval: 5s
113+
timeout: 5s
114+
retries: 10
93115
restart: unless-stopped
94116
networks:
95117
- kan-network
@@ -101,23 +123,23 @@ volumes:
101123
kan_postgres_data:
102124
```
103125
104-
2. Start the containers in detached mode:
126+
3. Start the containers in detached mode:
105127
106128
```bash
107129
docker compose up -d
108130
```
109131

110-
3. Access Kan at http://localhost:3000
132+
The `migrate` service will automatically run database migrations before the web service starts. The application will be available at http://localhost:3000 (or the port specified in `WEB_PORT`).
111133

112-
The application will be running in the background. You can manage the containers using these commands:
134+
**Managing containers:**
113135

114136
- To stop the containers: `docker compose down`
115137
- To view logs: `docker compose logs -f`
138+
- To view logs for a specific service: `docker compose logs -f web` or `docker compose logs -f migrate`
116139
- To restart the containers: `docker compose restart`
140+
- To rebuild after code changes: `docker compose up -d --build`
117141

118-
For the complete Docker Compose configuration, see [docker-compose.yml](./docker-compose.yml) in the repository.
119-
120-
> **Note**: The Docker Compose configuration shown above is a minimal example. For a complete setup with all features (email, OAuth, file uploads, etc.), you'll need to create a `.env` file with the required environment variables. See the Environment Variables section below for the full list of available options.
142+
For the complete Docker Compose configuration with all optional features, see [docker-compose.yml](./docker-compose.yml) in the repository.
121143

122144
## Local Development 🧑‍💻
123145

0 commit comments

Comments
 (0)