squoosh在线图片优化
使用DOCKER构建SQUOOSH容器
squoosh:一款基于Nodejs的图片压缩转换工具(无需上传任何文件)
编写镜像Dockerfile
Section titled “编写镜像Dockerfile”FROM node:20-alpineRUN set -aux; sed -i 's#https?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories; apk update; apk add git; git --versionRUN set -aux; cd /root; git clone https://github.com/GoogleChromeLabs/squoosh.git; cd squoosh; npm install; npm run build; npx -y update-browserslist-db@latestCOPY entrypoint.sh /usr/local/binWORKDIR /root/squooshEXPOSE 5000/tcpENTRYPOINT ["entrypoint.sh"]编写entrypoint.sh
Section titled “编写entrypoint.sh”#!/bin/sh npm run devdocker build -t xxx/squoosh:v0 -f ./Dockerfile .docker run -d --name squoosh -p 5000:5000 xxx/squoosh:v0