Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized Dockerfile, bump version #318

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,10 @@ RUN cd /build && sed -i "s|.\/pics|${IMG_PATH}|g" config.json \
&& sed -i 's/127.0.0.1/0.0.0.0/g' config.json \
&& go build -ldflags="-s -w" -o webp-server .

FROM debian:bookworm-slim as libwebp
RUN apt update && apt install -y wget gcc make autoconf automake libtool libgif-dev \
libjpeg-dev libjpeg62-turbo libjpeg62-turbo-dev libpng-dev libpng-tools libpng16-16 libtiff-dev libtiff6 libtiffxx6
RUN mkdir libwebp && mkdir -p /build/usr && mkdir /build/usr/lib/ && cd libwebp && \
wget https://chromium.googlesource.com/webm/libwebp/+archive/refs/heads/1.3.2.tar.gz && \
tar xf 1.3.2.tar.gz && rm -f 1.3.2.tar.gz && \
./autogen.sh && \
./configure --prefix=/build/usr --libdir=/build/usr/lib --enable-everything && \
make && make install

FROM debian:bookworm-slim

RUN apt update && apt install --no-install-recommends libvips ca-certificates libjemalloc2 libtcmalloc-minimal4 -y && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/archives/*

# for CVE-2023-4863
RUN dpkg --remove --force-depends libwebp-dev libwebp7 libwebpdemux2 libwebpmux3
COPY --from=libwebp /build/usr/lib/* /usr/lib/temp-linux-gnu/
RUN mv /usr/lib/temp-linux-gnu/* /usr/lib/$(uname -m)-linux-gnu/ && ldconfig

COPY --from=builder /build/webp-server /usr/bin/webp-server
COPY --from=builder /build/config.json /etc/config.json

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
ProxyMode bool
Prefetch bool
Config = NewWebPConfig()
Version = "0.10.7"
Version = "0.10.8"
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
ConvertLock = cache.New(5*time.Minute, 10*time.Minute)
RemoteRaw = "./remote-raw"
Expand Down
8 changes: 4 additions & 4 deletions encoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ func convertImage(rawPath, optimizedPath, imageType string, extraParams config.E

switch imageType {
case "webp":
err = webpEncoder(img, rawPath, optimizedPath, extraParams)
err = webpEncoder(img, rawPath, optimizedPath)
case "avif":
err = avifEncoder(img, rawPath, optimizedPath, extraParams)
err = avifEncoder(img, rawPath, optimizedPath)
}

return err
}

func avifEncoder(img *vips.ImageRef, rawPath string, optimizedPath string, extraParams config.ExtraParams) error {
func avifEncoder(img *vips.ImageRef, rawPath string, optimizedPath string) error {
var (
buf []byte
quality = config.Config.Quality
Expand Down Expand Up @@ -163,7 +163,7 @@ func avifEncoder(img *vips.ImageRef, rawPath string, optimizedPath string, extra
return nil
}

func webpEncoder(img *vips.ImageRef, rawPath string, optimizedPath string, extraParams config.ExtraParams) error {
func webpEncoder(img *vips.ImageRef, rawPath string, optimizedPath string) error {
var (
buf []byte
quality = config.Config.Quality
Expand Down
2 changes: 1 addition & 1 deletion encoder/prefetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func PrefetchImages() {
var sTime = time.Now()
log.Infof("Prefetching using %d cores", config.Jobs)
var finishChan = make(chan int, config.Jobs)
for _ = range config.Jobs {
for range config.Jobs {
finishChan <- 1
}

Expand Down
2 changes: 1 addition & 1 deletion webp-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func init() {
▘ ▘▝▀▘▀▀ ▘ ▝▀ ▝▀▘▘ ▘ ▝▀▘▘ ▝▀ ▝▀

WebP Server Go - v%s
Develop by WebP Server team. https://github.com/webp-sh`, config.Version)
Developed by WebP Server team. https://github.com/webp-sh`, config.Version)
// main init is the last one to be called
flag.Parse()
// process cli params
Expand Down
Loading