- JavaScript 66%
- CSS 28.1%
- Python 3.5%
- Vue 2.3%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| backend | ||
| docker-data/dms/mail-config | ||
| docs | ||
| frontend | ||
| .env | ||
| docker-compose.yml | ||
| README.md | ||
Cave à Vins — Development notes
This repository contains a minimal collaborative wine notebook built with Django + DRF (backend) and Vue 3 + Vite (frontend). This README documents how to configure and run media (image) uploads in development.
Media (uploaded images)
-
The media storage path is configurable via environment variables in
.env:MEDIA_ROOT— absolute path inside the container where uploaded files are stored. Default in.env:/srv/caveavins_media.MEDIA_URL— URL prefix for serving media. Default in.env:/media/.
-
In
docker-compose.ymlthe servicewebmounts a host directory./mediainto the container at the path used byMEDIA_ROOT:./media -> /srv/caveavins_media
This makes it simple to access files on the host during development.
Permissions
- Ensure the
./mediadirectory exists and is writable by the container process. On Linux you can run:
mkdir -p ./media
sudo chown $UID:$UID ./media
Replace $UID with the user id your container runs as if different.
Backend configuration
-
Django settings read
MEDIA_ROOTandMEDIA_URLfrom the environment (seebackend/caveavins/settings.py). In developmentDEBUG=Trueso media files are served by Django automatically. -
The
Vinmodel includes anImageField(upload_to='wines/'). Uploaded files will be available under${MEDIA_ROOT}/wines/.
Frontend
-
The frontend
CreateWineFormincludes a file input for the wine label. The app sends multipart/form-data toPOST /v1/wines/when an image is present. -
The frontend expects the API to return
image_url(absolute URL) on wine objects. The serializers are configured to provide absolute URLs when a request context is available.
Build & run (development)
- Build the web image (installs Pillow):
sudo docker compose build web
- Create media folder and set permissions:
mkdir -p ./media
sudo chown $UID:$UID ./media
- Run migrations:
sudo docker compose run --rm web python manage.py makemigrations
sudo docker compose run --rm web python manage.py migrate
- Start services:
sudo docker compose up
The frontend will be at http://localhost:5173 and the Django API at http://localhost:8000.
Notes & next steps
- In production you should serve media files through a proper static files server (nginx, CDN, S3, etc.) instead of Django.
- Consider adding server-side validation (file size & mime type) and image processing (resize) as needed.
- Server-side validation is implemented: uploads are limited to JPEG/PNG and 5 MB maximum.
- Uploaded images are resized on save to a maximum width of 1200px (keeps aspect ratio) to limit storage and bandwidth.
- The default email backend is the console backend — update
EMAIL_BACKENDandDEFAULT_FROM_EMAILin the environment for sending real emails.