You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Microservice for responsive resize, compression and optimization of images on the fly for web pages.
8
-
9
-
Optimizing images helps reduce image weight and increases website loading speed, which is very important for both users and search engines. For these purposes, we have created a microservice that perfectly copes with this task.
By changing the src, size, format parameters, you can choose the path to the image, the final size and the image format.
35
+
By changing the src, size, format parameters,
36
+
you can choose the path to the image,
37
+
the final size and the image format.
33
38
34
39
### Use
40
+
35
41
To start the microservice in production, use the command:
42
+
36
43
```sh
37
44
docker run -d --restart always -p 3000:3000 mtsrus/image-optimize
38
45
```
39
46
40
47
### Container parameters
41
48
42
-
- `-e PORT=3000` - the port on which the microservice will be launched, default 3000.
43
-
- `-e ALLOW_SIZES="100,200,1024-1920"` - an array of allowed sizes for the resulting images, default 100-1920. Use specific values to prevent heavy loads on the server.
44
-
- `-e ALLOW_SOURCES="https%3A%2F%2Ftb.mts.ru%2F"` - url array of allowed addresses for image sources, default * (any). Use comma as separator. It is recommended to apply encodeURIComponent to url.
45
-
- `-e BASIC_AUTHS="https%3A%2F%2Ftb.mts.ru%2F"` - an array of endpoints with basic authorization parameters, default empty. Has format encodeURIComponent("url"):encodeURIComponent("login"):encodeURIComponent("password"). Use comma as separator.
46
-
- `-e SHARP_CONCURRENCY=0` - number of threads libvips' should create to process each image, default 0 (will reset to the number of CPU cores).
49
+
-`-e PORT=3000` - the port on which the microservice will be launched, default 3000.
50
+
-`-e ALLOW_SIZES="100,200,1024-1920"` - an array of allowed sizes for the resulting images,
51
+
default 100-1920. Use specific values to prevent heavy loads on the server.
52
+
53
+
-`-e ALLOW_SOURCES="https%3A%2F%2Ftb.mts.ru%2F"` - url array of allowed addresses for image sources, default * (any).
54
+
Use comma as separator. It is recommended to apply encodeURIComponent to url.
55
+
56
+
-`-e BASIC_AUTHS="https%3A%2F%2Ftb.mts.ru%2F"` - an array of endpoints with basic authorization parameters, default empty.
57
+
Has format encodeURIComponent("url"):encodeURIComponent("login"):encodeURIComponent("password"). Use comma as separator.
58
+
59
+
-`-e SHARP_CONCURRENCY=0` - number of threads libvips' should create to process each image,
60
+
default 0 (will reset to the number of CPU cores).
47
61
48
62
### Components for web
49
-
To optimize images in the browser, there is a component for React. You can find it [by following the link](https://github.com/MobileTeleSystems/image-optimize-react). The component itself determines the most suitable image parameters and requests it from this microservice.
63
+
64
+
To optimize images in the browser, there is a component for React. You can find it
65
+
[by following the link](https://github.com/MobileTeleSystems/image-optimize-react).
66
+
The component itself determines the most suitable image parameters and requests it from this microservice.
0 commit comments