The only dependencies for this project should be docker and docker-compose.
go to nginx/nginx-conf and change your the servername with your domain name or localhost
Starting the project with hot-reloading enabled (the first time it will take a while):
Change into your project directory and run:
chmod +x scripts/build.sh
./scripts/build.sh
This will build and run the docker containers, run the alembic migrations, and load the initial data (a test user).
It may take a while to build the first time it's run since it needs to fetch all the docker images.
Once you've built the images once, you can simply use regular docker-compose commands to manage your development environment, for example to start your containers:
docker-compose up -d
go to nginx/nginx-conf and change your the servername with your domain name or localhost
To run the alembic migrations (for the users table):
docker-compose run --rm backend alembic upgrade head
And navigate to http://localhost:8000
you need to locate the api docker image by running
docker container ls
docker exec -it <backend_container> bash
inside run:
certbot --nginx -d yourdocker.com -d www.yourdomain.com
you'll folllow instruction and the ssl certificate should activate
quit the container terminal
run
git restore .
if you make new changes you only need to restart the container and reactivate the ssl certification
For auto renew run
certbot --dry-run
docker-compose build
docker-compose restart
docker-compose down
Alternatively to running inside docker, it can sometimes be easier to use npm directly for quicker reloading. To run using npm:
cd frontend
npm install
npm start
This should redirect you to http://localhost:3000
cd frontend
npm install
npm test
Migrations are run using alembic. To run all migrations:
docker-compose run --rm backend alembic upgrade head
To create a new migration:
alembic revision -m "create users table"
And fill in upgrade
and downgrade
methods. For more information see
Alembic's official documentation.
There is a helper script for both frontend and backend tests:
./scripts/test.sh
docker-compose run backend pytest
any arguments to pytest can also be passed after this command
docker-compose run frontend test
This is the same as running npm test from within the frontend directory
docker-compose logs
Or for a specific service:
docker-compose logs -f name_of_service # frontend|backend|db
backend
└── app
├── alembic
│ └── versions # where migrations are located
├── api
│ └── api_v1
│ └── endpoints
├── core # config
├── db # db models
├── tests # pytest
└── main.py # entrypoint to backend
frontend
└── public
└── src
├── components
│ └── Home.tsx
├── config
│ └── index.tsx # constants
├── __tests__
│ └── test_home.tsx
├── index.tsx # entrypoint
└── App.tsx # handles routing