Serve to serve images
IS_DEBUG- enable debug logs;default: 0STORAGE- chose storage for your images ;oneOf(s3, disk);default: s3IMAGE_MIN_WIDTH- minimal image width to request;default: 10IMAGE_MIN_HEIGHT- minimal image height to request;default: 10IMAGE_MAX_WIDTH- maximum image width to request;default: 2000IMAGE_MAX_HEIGHT- maximum image height to request;default: 2000ALLOWED_IMAGE_TYPES- types of images that can be added;default: ["image/jpeg", "image/jpg", "image/png", "image/tiff"]IMAGE_PROCESSING_WORKERS- number of processes to resize image;default: 3
Only of you set STORAGE=s3
S3_ACCESS_KEY_ID- s3 access key id;requiredS3_SECRET_ACCESS_KEY- s3 secret access key;requiredS3_REGION_NAME- s3 region nameS3_BUCKET- s3 bucket name;requiredS3_ENDPOINT_URL- s3 endpoint url; if you're using different from aws s3 storage, like minio
add .env file in the project directory with the same variables as in .env.example
docker run --env-file .env -p 8080:8080 markantipin/image-servicepoetry install
poetry run uvicorn run:app --host 0.0.0.0 --port 8080 --workers 1docs available on http://0.0.0.0:8080/docs
- POST /api/v1/images
curl -X 'POST' \
'http://0.0.0.0:8080/api/v1/images' \
-F 'file=@file.png;type=image/png'
- GET /api/v1/images/{image_id}
curl -X 'GET' \
'http://0.0.0.0:8080/api/v1/images/bc1794c9-2be2-4d46-98ef-fa6841f0b337' \
-o file.jpg
- GET /api/v1/images/{width}x{height}/{image_id}
curl -X 'GET' \
'http://0.0.0.0:8080/api/v1/images/500x500/bc1794c9-2be2-4d46-98ef-fa6841f0b337' \
-o file.jpg
linters:
poetry run flake8 .
poetry run isort -c .tests:
poetry run coverage run -m pytest -v tests
poetry run coverage report -m --skip-empty --fail-under=90load tests
Using k6
k6 run load_tests/get_image.js