Skip to content

Commit 46bbbd7

Browse files
committed
Add development guide, Add postgres database update info
1 parent 2183841 commit 46bbbd7

File tree

7 files changed

+1533
-1804
lines changed

7 files changed

+1533
-1804
lines changed

docs/development/intro.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Introduction
6+
7+
Welcome to the **Development** section of the solidtime documentation!
8+
9+
This guide is for developers who want to contribute to solidtime or learn more about its architecture.

docs/development/local-setup.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Local Development Setup
6+
7+
:::info
8+
This local setup is **ONLY intended for development** purposes. **DO NOT** use this if you want to actually use solidtime, even if you want to run it locally.
9+
If just want to use solidtime, please follow the [self-hosting guide](../self-hosting/intro.md).
10+
:::
11+
12+
13+
## Prerequisites
14+
15+
- Docker and Docker Compose installed on your system. TODO link
16+
17+
## Setup
18+
19+
The local setup is an extended version of [Laravel Sail](https://laravel.com/docs/12.x/sail#main-content).
20+
21+
To start you need to download or clone the repository f.e. with:
22+
23+
```bash
24+
git clone [email protected]:solidtime-io/solidtime.git
25+
```
26+
27+
After that, execute the following commands **inside the project folder**:
28+
29+
```bash
30+
docker run --rm \
31+
--pull=always \
32+
-v "$(pwd)":/opt \
33+
-w /opt \
34+
laravelsail/php83-composer:latest \
35+
bash -c "composer install --ignore-platform-reqs"
36+
37+
cp .env.example .env
38+
```
39+
40+
Before you can run the application, you need to set up the environment variables in the `.env` file.
41+
Make sure to set the `FORWARD_DB_PORT` inside your `.env` file to a port that is not already used by your system.
42+
43+
By default, the PostgreSQL database is set up to run on port `54329` on your host machine, so you can use that port if it is not already in use.
44+
45+
```bash
46+
./vendor/bin/sail up -d
47+
48+
./vendor/bin/sail artisan key:generate
49+
50+
./vendor/bin/sail artisan migrate:fresh --seed
51+
52+
./vendor/bin/sail php artisan passport:install
53+
54+
./vendor/bin/sail npm install
55+
56+
./vendor/bin/sail npm run build
57+
```
58+
59+
**Optional: sail Alias**
60+
61+
If you want to use the `sail` command instead of `./vendor/bin/sail`, you can add the following alias to your shell configuration file (e.g. `.bashrc`, `.zshrc`):
62+
63+
```bash
64+
alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'
65+
```
66+
67+
### Setup with Reverse Proxy
68+
69+
Using a Traefik reverse proxy is currently required for the local development setup to work properly.
70+
The `docker-compose.yml` file already contains configurations for Traefik, but you need to set up the reverse proxy yourself.
71+
72+
You can follow the following [this guide to set up the reverse proxy](https://github.com/korridor/reverse-proxy-docker-traefik?tab=readme-ov-file#setup-for-local-development).
73+
74+
Afterward, add the following entries to your `/etc/hosts`:
75+
76+
```
77+
127.0.0.1 solidtime.test
78+
127.0.0.1 playwright.solidtime.test
79+
127.0.0.1 vite.solidtime.test
80+
127.0.0.1 mail.solidtime.test
81+
```
82+
83+
Then restart the Docker containers with:
84+
85+
```bash
86+
./vendor/bin/sail down
87+
./vendor/bin/sail up -d
88+
```
89+
90+
You should now be able to access the application at [http://solidtime.test](http://solidtime.test) and the Vite server at [http://vite.solidtime.test](http://vite.solidtime.test).
91+
92+
### Running E2E Tests
93+
94+
`./vendor/bin/sail up -d ` will automatically start a Playwright UI server that you can access at `https://playwright.solidtime.test`.
95+
Make sure that you use HTTPS otherwise the resources will not be loaded correctly.
96+
97+
### Recording E2E Tests
98+
99+
To record E2E tests, you need to install and execute playwright locally (outside the Docker container) using:
100+
101+
```bash
102+
npx playwright install
103+
npx playwright codegen solidtime.test
104+
```
105+
106+
### E2E Troubleshooting
107+
108+
If E2E tests are not working at all, make sure you do not have the Vite server running and just run `npm run build` to update the version.
109+
If the E2E tests are not working consistently and fail with a timeout during the authentication, you might want to delete the `test-results/.auth` directory to force new test accounts to be created.
110+
111+
### Generate ZOD Client
112+
113+
The Zodius HTTP client is generated using the following command:
114+
115+
```bash
116+
npm run zod:generate
117+
```

docs/self-hosting/guides/docker.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,29 @@ docker compose exec scheduler php artisan migrate --force
223223
```bash
224224
docker system prune -a -f
225225
```
226+
227+
### Postgres database
228+
229+
#### Collation version mismatch
230+
231+
If you get an error about a collation version mismatch, you need to update the collation of the database.
232+
233+
The warning might look like this:
234+
235+
```
236+
WARNING: database "<your_database_name>" has a collation version mismatch
237+
```
238+
239+
You can fix this by running the following command:
240+
241+
```bash
242+
docker compose exec database psql -U <your_database_username>
243+
```
244+
245+
This will open a Postgres shell. Then you can run the following command to update the collation:
246+
247+
```sql
248+
REINDEX DATABASE <your_database_name>;
249+
250+
ALTER DATABASE <your-database-name> REFRESH COLLATION VERSION;
251+
```

docusaurus.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ const config: Config = {
107107
position: 'left',
108108
label: 'Self-hosting',
109109
},
110+
{
111+
type: 'doc',
112+
docId: 'development/intro',
113+
position: 'left',
114+
label: 'Development',
115+
},
110116
{
111117
href: 'https://www.solidtime.io',
112118
label: 'Homepage',

0 commit comments

Comments
 (0)