2024-10-09 11:54:00 +02:00
|
|
|
# How to setup the Project
|
|
|
|
|
|
|
|
## Table of Contents
|
|
|
|
1. [Prerequisites](#prerequisites)
|
|
|
|
2. [Setup](#setup)
|
2024-10-10 09:41:40 +02:00
|
|
|
3. [Applying Migrations](#applying-migrations)
|
2024-10-09 11:54:00 +02:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
# Prerequisites
|
|
|
|
Docker installed on the system.
|
|
|
|
|
|
|
|
For the frontend it might be necessary to install pnpm and its requirements
|
|
|
|
|
|
|
|
For a production environment you may change the database user/password in the `.env` file and the corresponding `dev-compose.yml` or build your own!
|
|
|
|
|
|
|
|
# Setup
|
|
|
|
To execute the database and backend run the following command in the root directory of the project
|
|
|
|
```bash
|
|
|
|
docker compose -f dev-compose.yml up -d
|
|
|
|
```
|
2024-10-09 17:31:36 +02:00
|
|
|
or if you only want to execute 1 or n containers the syntax is the following
|
|
|
|
```bash
|
|
|
|
docker compose -f dev-compose.yml up -d postgres backend frontend
|
|
|
|
```
|
|
|
|
this starts all the containers however you can just remove them as you like. If you want to stop all docker containers run
|
|
|
|
```bash
|
2024-10-09 18:09:24 +02:00
|
|
|
docker compose -f dev-compose.yml down
|
2024-10-10 09:41:40 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
# Applying Migrations
|
|
|
|
If migrations haven't been applied yet you can apply them with the following commands:
|
|
|
|
|
|
|
|
*Note: Plase ensure the database is running*
|
|
|
|
|
|
|
|
1. remove old docker image to rebuild
|
|
|
|
```bash
|
|
|
|
docker image remove apfelnetzwerk-backend
|
|
|
|
```
|
|
|
|
|
|
|
|
2. check which dockers are running
|
|
|
|
```bash
|
|
|
|
docker ps
|
|
|
|
```
|
|
|
|
|
|
|
|
3. attach a shell to the running postgres docker container
|
|
|
|
```bash
|
|
|
|
docker exec -it <it/name> /bin/bash
|
|
|
|
```
|
|
|
|
|
|
|
|
4. apply migrations
|
|
|
|
```bash
|
|
|
|
#(go into the crates folder)
|
|
|
|
cd crates
|
|
|
|
#run migrations
|
|
|
|
sea-orm-cli migrate fresh
|
2024-10-09 17:31:36 +02:00
|
|
|
```
|