|
| 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 | +``` |
0 commit comments