No description
  • JavaScript 66%
  • CSS 28.1%
  • Python 3.5%
  • Vue 2.3%
Find a file
Pharangal d9d1a78e2d
All checks were successful
Deploy / deploy (push) Successful in 4m55s
CI/CD 36eme
2026-04-07 14:07:45 +02:00
.forgejo/workflows CI/CD 36eme 2026-04-07 14:07:45 +02:00
backend base 2026-03-16 11:37:34 +01:00
docker-data/dms/mail-config base 2026-03-16 11:37:34 +01:00
docs base 2026-03-16 11:37:34 +01:00
frontend base 2026-03-16 11:37:34 +01:00
.env base 2026-03-16 11:37:34 +01:00
docker-compose.yml base 2026-03-16 11:37:34 +01:00
README.md base 2026-03-16 11:37:34 +01:00

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.yml the service web mounts a host directory ./media into the container at the path used by MEDIA_ROOT:

    ./media -> /srv/caveavins_media

    This makes it simple to access files on the host during development.

Permissions

  • Ensure the ./media directory 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_ROOT and MEDIA_URL from the environment (see backend/caveavins/settings.py). In development DEBUG=True so media files are served by Django automatically.

  • The Vin model includes an ImageField (upload_to='wines/'). Uploaded files will be available under ${MEDIA_ROOT}/wines/.

Frontend

  • The frontend CreateWineForm includes a file input for the wine label. The app sends multipart/form-data to POST /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)

  1. Build the web image (installs Pillow):
sudo docker compose build web
  1. Create media folder and set permissions:
mkdir -p ./media
sudo chown $UID:$UID ./media
  1. Run migrations:
sudo docker compose run --rm web python manage.py makemigrations
sudo docker compose run --rm web python manage.py migrate
  1. 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_BACKEND and DEFAULT_FROM_EMAIL in the environment for sending real emails.