You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,23 +6,93 @@ A template for developing applications for the Tour de App competition with a fr
6
6
7
7
## Initial Setup
8
8
9
-
In the frontend and backend directories, there are `.env.example` files that need to be renamed to `.env` and the values adjusted as needed.
10
-
11
-
For production development, you need to set `VITE_API_URL` to the API server URL in the `tourdeapp.yaml` file to the URL you find on the main page of your project on [tourde.cloud](https://tourde.cloud/).
9
+
In the backend directory, there is a `.env.example` file that needs to be renamed to `.env` and the values adjusted as needed.
12
10
13
11
> [!WARNING]
14
12
> If you want to change the database password, you need to change it in the `tourdeapp.yaml` file, `apps/server/.env`, and for local development in the `apps/server/package.json` file.
15
13
16
14
## Local Development
17
15
18
-
For local development, you need to run:
19
-
-**frontend** (`apps/web`), using `npm run dev` (in the correct directory - `apps/web`), it will start at [http://localhost:3001](http://localhost:3001)
20
-
-**backend** (`apps/server`), using `npm run dev` (in the correct directory - `apps/server`), it will start at [http://localhost:3000](http://localhost:3000)
21
-
-**MySQL** database, which is defined in `docker-compose.yaml`, using `npm run db` (in the `apps/server` directory), the database will run on port 3306
16
+
For local development, you need to run three services: the database, backend, and frontend. Below you'll find detailed step-by-step instructions.
17
+
18
+
### Step 1: Setting up environment variables
19
+
20
+
First, you need to set up environment variables:
21
+
22
+
1.**Backend**: In the `apps/server` directory, rename the `.env.example` file to `.env`:
23
+
```bash
24
+
cd apps/server
25
+
cp .env.example .env
26
+
```
27
+
28
+
### Step 2: Installing dependencies
29
+
30
+
Install dependencies for both parts of the application:
31
+
32
+
1.**Backend dependencies**:
33
+
```bash
34
+
cd apps/server
35
+
npm install
36
+
```
37
+
38
+
2.**Frontend dependencies**:
39
+
```bash
40
+
cd ../web
41
+
npm install
42
+
```
43
+
44
+
### Step 3: Starting the MySQL database
45
+
46
+
Start the database using a Docker container:
47
+
48
+
```bash
49
+
cd apps/server
50
+
npm run db
51
+
```
52
+
53
+
The database will run on port **3306**. Wait a few seconds for the database to fully initialize (usually 10-20 seconds).
22
54
23
55
> [!WARNING]
24
56
> The database is not persistent, data will be lost after shutting down the Docker container.
25
57
58
+
> [!TIP]
59
+
> If you need to stop the database, use `docker ps` to view running containers and `docker stop <container-id>` to stop the database container.
60
+
61
+
### Step 4: Starting the backend server
62
+
63
+
In a new terminal, start the backend:
64
+
65
+
```bash
66
+
cd apps/server
67
+
npm run dev
68
+
```
69
+
70
+
The backend will run on [http://localhost:3000](http://localhost:3000). You should see a message that the server is running and connected to the database.
71
+
72
+
### Step 5: Starting the frontend application
73
+
74
+
In another terminal, start the frontend:
75
+
76
+
```bash
77
+
cd apps/web
78
+
npm run dev
79
+
```
80
+
81
+
The frontend will run on [http://localhost:3001](http://localhost:3001). Open this address in your browser.
82
+
83
+
### Verifying everything works
84
+
85
+
1.**Frontend**: Open [http://localhost:3001](http://localhost:3001) - your application should be displayed
86
+
2.**Backend API**: Open [http://localhost:3000/api](http://localhost:3000/api) - you should see a response from the API
87
+
3.**Database**: You can connect using a MySQL client to `localhost:3306` with username `root` and password `password`
88
+
89
+
### Troubleshooting
90
+
91
+
-**Port already in use**: If any of the ports (3000, 3001, 3306) are already in use, terminate the process using it or change the port in the configuration files
92
+
-**Database won't start**: Check that you have Docker installed and running
93
+
-**Backend can't connect to database**: Wait for the database to fully initialize (usually takes 10-20 seconds after starting)
94
+
-**Node.js is not installed**: Install Node.js from [nodejs.org](https://nodejs.org/) or use a version manager like `nvm` (Linux/MacOS: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash`, Windows: download from [nvm-windows](https://github.com/coreybutler/nvm-windows))
95
+
26
96
## Production Setup (how does it run on our servers?)
27
97
28
98
How the application runs on [tourde.cloud](https://tourde.cloud/) is defined in the `tourdeapp.yaml` file in the root directory of this repository. This boilerplate includes pre-configured services:
@@ -75,23 +145,93 @@ How to submit your application can be found in our [How to deploy an app to Tour
75
145
76
146
## Prvotní nastavení
77
147
78
-
V složkách pro frontend a backend jsou `.env.example` soubory, které je potřeba přejmenovat na `.env` a upravit hodnoty dle potřeby.
79
-
80
-
Pro produkční vývoj je potřeba nastavit `VITE_API_URL` na URL API serveru v souboru `tourdeapp.yaml` na URL, kterou najdete na hlavní stránce Vašeho projektu na [tourde.cloud](https://tourde.cloud/).
148
+
V složce pro backend je `.env.example` soubor, který je potřeba přejmenovat na `.env` a upravit hodnoty dle potřeby.
81
149
82
150
> [!WARNING]
83
151
> Pokud chcete měnit heslo od databáze, je potřeba ho změnit v souboru `tourdeapp.yaml`, `apps/server/.env` a pro lokální vývoj v souboru `apps/server/package.json`.
84
152
85
153
## Lokální vývoj
86
154
87
-
Pro lokální vývoj je potřeba pustit:
88
-
-**frontend** (`apps/web`), pomocí `npm run dev` (ve správném adresáři - `apps/web`), pustí se na [http://localhost:3001](http://localhost:3001)
89
-
-**backend** (`apps/server`), pomocí `npm run dev` (ve správném adresáři - `apps/server`), pustí se na [http://localhost:3000](http://localhost:3000)
90
-
-**MySQL** databázi, která je definována v `docker-compose.yaml`, pomocí `npm run db` (v adresáři `apps/server`), databáze poběží na portu 3306
155
+
Pro lokální vývoj je potřeba spustit tři služby: databázi, backend a frontend. Níže najdete podrobné instrukce krok za krokem.
Nejprve je potřeba nastavit environmentální proměnné:
160
+
161
+
1.**Backend**: V adresáři `apps/server` přejmenujte soubor `.env.example` na `.env`:
162
+
```bash
163
+
cd apps/server
164
+
cp .env.example .env
165
+
```
166
+
167
+
### Krok 2: Instalace závislostí
168
+
169
+
Nainstalujte závislosti pro obě části aplikace:
170
+
171
+
1.**Backend závislosti**:
172
+
```bash
173
+
cd apps/server
174
+
npm install
175
+
```
176
+
177
+
2.**Frontend závislosti**:
178
+
```bash
179
+
cd ../web
180
+
npm install
181
+
```
182
+
183
+
### Krok 3: Spuštění MySQL databáze
184
+
185
+
Databázi spustíte pomocí Docker kontejneru:
186
+
187
+
```bash
188
+
cd apps/server
189
+
npm run db
190
+
```
191
+
192
+
Databáze poběží na portu **3306**. Počkejte několik sekund, než se databáze plně inicializuje (obvykle 10-20 sekund).
91
193
92
194
> [!WARNING]
93
195
> Databáze není perzistentní, data se z ní po vypnutí Docker kontejneru ztratí.
94
196
197
+
> [!TIP]
198
+
> Pokud potřebujete databázi zastavit, použijte příkaz `docker ps` pro zobrazení běžících kontejnerů a `docker stop <container-id>` pro zastavení kontejneru s databází.
199
+
200
+
### Krok 4: Spuštění backend serveru
201
+
202
+
V novém terminálu spusťte backend:
203
+
204
+
```bash
205
+
cd apps/server
206
+
npm run dev
207
+
```
208
+
209
+
Backend poběží na [http://localhost:3000](http://localhost:3000). Měli byste vidět zprávu, že server běží a je připojen k databázi.
210
+
211
+
### Krok 5: Spuštění frontend aplikace
212
+
213
+
V dalším terminálu spusťte frontend:
214
+
215
+
```bash
216
+
cd apps/web
217
+
npm run dev
218
+
```
219
+
220
+
Frontend poběží na [http://localhost:3001](http://localhost:3001). Otevřete tuto adresu v prohlížeči.
221
+
222
+
### Ověření, že vše funguje
223
+
224
+
1.**Frontend**: Otevřete [http://localhost:3001](http://localhost:3001) - měla by se zobrazit vaše aplikace
225
+
2.**Backend API**: Otevřete [http://localhost:3000/api](http://localhost:3000/api) - měli byste vidět odpověď z API
226
+
3.**Databáze**: Můžete se připojit pomocí MySQL klienta na `localhost:3306` s uživatelským jménem `root` a heslem `password`
227
+
228
+
### Řešení problémů
229
+
230
+
-**Port již používán**: Pokud některý z portů (3000, 3001, 3306) je již používán, ukončete proces, který ho používá, nebo změňte port v konfiguračních souborech
231
+
-**Databáze se nespustí**: Zkontrolujte, zda máte nainstalovaný a spuštěný Docker
232
+
-**Backend se nemůže připojit k databázi**: Počkejte, až se databáze plně inicializuje (obvykle trvá 10-20 sekund po spuštění)
233
+
-**Node.js není nainstalován**: Nainstalujte Node.js z [nodejs.org](https://nodejs.org/) nebo použijte správce verzí jako `nvm` (Linux/MacOS: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash`, Windows: stáhněte z [nvm-windows](https://github.com/coreybutler/nvm-windows))
234
+
95
235
## Produkční setup (jak se to spouští na našich serverech?)
96
236
97
237
Jak se aplikace spustí na [tourde.cloud](https://tourde.cloud/) je definováno v souboru `tourdeapp.yaml` v kořenovém adresáři tohoto repozitáře. V tomto boilerplate jsou předpřipravené služby:
0 commit comments