agenda_culturel/README.md

166 lines
4.1 KiB
Markdown
Raw Normal View History

2023-09-17 11:19:14 +02:00
# Agenda culturel
L'agenda culturel est un projet django créé à partir de [Django Docker Quickstard](https://github.com/godd0t/django-docker-quickstart/) pour faciliter son développemnt et déploiement. Voir ci-dessous le readme issu de ce projet.
## Django Docker Quickstart
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
This quickstart provides an easy way to initiate a Django project using Docker. It comes with pre-configured services including PostgreSQL, Redis, Celery (worker and beat), Nginx, and Traefik, ready to run a Django web application. Additionally, it provides a few handy shortcuts for easier development.
2023-05-10 21:51:26 +02:00
2023-05-15 15:00:20 +02:00
---
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
### Features 🚀
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
- **Django** web application framework
- **PostgreSQL** database
- **Redis** in-memory data structure store
- **Celery** worker and beat services for running background tasks asynchronously
- **Nginx** web server for serving static and media files, and proxying requests to the Django application
- **Traefik** reverse proxy for routing requests to the appropriate service and providing SSL termination
2023-05-10 21:48:56 +02:00
2023-09-17 11:19:14 +02:00
### Included Packages and Tools 🛠️
2023-05-10 21:48:56 +02:00
2023-05-15 15:00:20 +02:00
- **Pytest**: Testing framework
- **Pytest Sugar**: A pytest plugin for a better look
- **Pytest Django**: A pytest plugin providing useful tools for testing Django applications
- **Coverage**: Test coverage tool
- **Ruff**: Linter
- **Black**: Code formatter
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
### Requirements 📋
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
- Docker & Docker Compose - [Install and Use Docker](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04)
2023-05-10 14:02:09 +02:00
- Python 3.10 or higher
2023-05-15 15:00:20 +02:00
- Make (optional for shortcuts)
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
---
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
### Getting Started 🏁
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
1. **Clone the repository:**
```bash
git clone https://github.com/jmtrivial/agenda-culturel.git
2023-05-10 14:02:09 +02:00
```
2023-05-15 15:00:20 +02:00
2. **Change directory into the project:**
```bash
cd agenda-culturel
2023-05-10 14:02:09 +02:00
```
2023-05-15 15:00:20 +02:00
2023-05-15 15:37:00 +02:00
3. **Copy the `env.example` file to `.env` and update the values as needed:**
- **For Linux/macOS:**
```bash
cp env.example .env
```
- **For Windows (Command Prompt):**
```cmd
Copy-Item -Path env.example -Destination .env
```
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
---
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
### Initial Setup ⚙️
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
#### Development Prerequisites
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
1. **Create a virtual environment:**
```bash
2023-05-10 14:02:09 +02:00
python -m venv venv
```
2023-05-15 15:00:20 +02:00
2. **Activate the virtual environment:**
```bash
2023-05-10 14:02:09 +02:00
source venv/bin/activate
```
2023-05-15 15:00:20 +02:00
3. **(Optional) Install the development requirements specific to your IDE for enhanced functionality and support.**
```bash
2023-05-15 12:13:15 +02:00
pip install -r src/requirements-dev.txt
2023-05-10 14:02:09 +02:00
```
2023-05-15 15:37:00 +02:00
4. **Build the image and run the container:**
2023-05-15 15:00:20 +02:00
- If buildkit is not enabled, enable it and build the image:
```bash
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f docker-compose.yml up --build -d
```
2023-05-15 15:20:07 +02:00
2023-05-15 15:00:20 +02:00
- If buildkit is enabled, build the image:
```bash
docker-compose -f docker-compose.yml up --build -d
```
2023-05-15 15:20:07 +02:00
2023-05-15 15:00:20 +02:00
- Or, use the shortcut:
```bash
make build-dev
```
2023-05-10 14:02:09 +02:00
You can now access the application at http://localhost:8008. The development environment allows for immediate reflection of code changes.
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
#### Production Setup
2023-05-15 15:00:20 +02:00
2023-05-15 15:37:00 +02:00
1. **Build the image and run the container:**
- If buildkit is not enabled, enable it and build the image:
```bash
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f docker-compose.prod.yml up --build -d
```
2023-05-15 15:00:20 +02:00
2023-05-15 15:37:00 +02:00
- If buildkit is enabled, build the image:
2023-05-15 15:00:20 +02:00
```bash
2023-05-15 15:37:00 +02:00
docker-compose -f docker-compose.prod.yml up --build -d
```
2023-05-15 15:00:20 +02:00
- Or, use the shortcut:
2023-05-15 15:37:00 +02:00
```bash
make build-prod
```
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
---
2023-05-10 14:02:09 +02:00
2023-09-17 11:19:14 +02:00
### Shortcuts 🔑
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
This project includes several shortcuts to streamline the development process:
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
- **Create migrations:**
```bash
make make-migrations
```
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
- **Run migrations:**
```bash
make migrate
```
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
- **Run the linter:**
```bash
make lint
```
2023-05-10 14:02:09 +02:00
2023-05-15 15:00:20 +02:00
- **Run the formatter:**
```bash
make format
```
2023-05-10 21:48:56 +02:00
2023-05-15 15:00:20 +02:00
- **Run the tests:**
```bash
make test
```
2023-05-10 21:48:56 +02:00
2023-05-15 15:00:20 +02:00
- **Create a super user:**
```bash
make super-user
```
2023-05-10 21:48:56 +02:00
2023-05-15 15:00:20 +02:00
- **Build and run dev environment:**
```bash
make build-dev
```
2023-05-10 21:48:56 +02:00
2023-05-15 15:00:20 +02:00
- **Build and run prod environment:**
```bash
make build-prod
```
---