mu.semte.ch service which hosts images in a resized variant.
641
A service which yields resized images from high-resolution images in the backend.
It is often needed to render images at various sizes in the frontend. Uploading the images in various resolutions manually is a cumbersome effort which could be automated. The mu-image-service yields rescaled versions of images on demand and caches the intermediate results.
Add the following snippet to your docker-compose.yml
imageservice:
image: madnificent/mu-image-service:0.0.1
links:
- db:database
volumes:
- ./data/files:/share
Add the following in your dispatcher.ex
match "/images/*path" do
Proxy.forward conn, path, "http://imageservice/image/"
end
An image file compatible with the file-service with uuid imageUuid can now be requested at GET /images/${imageUuid}?height=200&width=1280. Supplying either width or height is sufficient for this service to operate.
The service uses sharp for resizing images.
In order to develop the service locally, you will need a version of sharp in the node_modules which is compatible with the Docker images. When running NPM install in the folder of the microservice on your local machine, it will fetch the binary for your development machine rather than for the Docker image. These may be compatible, but that needn't be the case.
We populated our node_modules locally by running the following:
#> cd mu-image-service
#> docker run --rm -it -v `pwd`:/app /bin/bash
$> cd /app
$> npm install
$> rm package-lock.json
$> C-d
This gives us a node_modules folder with binaries compatible with the Docker image.
This section describes the general architecture of the mu-image-service.
Some tasks could be executed to make this service more foolproof.
Content type
Image
Digest
Size
75.4 MB
Last updated
over 5 years ago
docker pull madnificent/mu-image-service