larsense commited on
Commit
ab26fdc
·
1 Parent(s): a0a31a4
Files changed (2) hide show
  1. Dockerfile +26 -7
  2. docker-compose.yml +4 -3
Dockerfile CHANGED
@@ -1,10 +1,29 @@
1
- FROM webpsh/webp-server-go
2
 
3
- # 创建必要的目录
4
- RUN mkdir -p /opt/pics /opt/exhaust /opt/metadata
 
 
 
5
 
6
- # 设置端口
7
- EXPOSE 3333
 
 
 
8
 
9
- # 使用默认的启动命令
10
- CMD ["/webp-server"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM golang:1.24-bookworm AS builder
2
 
3
+ ARG IMG_PATH=/opt/pics
4
+ ARG EXHAUST_PATH=/opt/exhaust
5
+ RUN apt update && apt install --no-install-recommends libvips-dev -y && mkdir /build
6
+ COPY go.mod /build
7
+ RUN cd /build && go mod download
8
 
9
+ COPY . /build
10
+ RUN cd /build && sed -i "s|.\/pics|${IMG_PATH}|g" config.json \
11
+ && sed -i "s|\"\"|\"${EXHAUST_PATH}\"|g" config.json \
12
+ && sed -i 's/127.0.0.1/0.0.0.0/g' config.json \
13
+ && go build -ldflags="-s -w" -o webp-server .
14
 
15
+ FROM debian:bookworm-slim
16
+
17
+ RUN apt update && apt install --no-install-recommends libvips ca-certificates libjemalloc2 libtcmalloc-minimal4 curl -y && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/archives/*
18
+
19
+ COPY ./assets /build/assets
20
+ # Install libam with correct arch
21
+ RUN dpkg -i /build/assets/libaom3_3.11.0-1_$(dpkg --print-architecture).deb && \
22
+ rm /build/assets/libaom3_3.11.0-1_$(dpkg --print-architecture).deb
23
+
24
+ COPY --from=builder /build/webp-server /usr/bin/webp-server
25
+ COPY --from=builder /build/config.json /etc/config.json
26
+
27
+ WORKDIR /opt
28
+ VOLUME /opt/exhaust
29
+ CMD ["/usr/bin/webp-server", "--config", "/etc/config.json"]
docker-compose.yml CHANGED
@@ -2,12 +2,13 @@ version: '3'
2
 
3
  services:
4
  webp:
5
- image: webpsh/webp-server-go
6
- # image: ghcr.io/webp-sh/webp_server_go
 
7
  restart: always
8
  volumes:
9
  - ./path/to/pics:/opt/pics
10
  - ./exhaust:/opt/exhaust
11
  - ./metadata:/opt/metadata
12
  ports:
13
- - 127.0.0.1:8000:3333
 
2
 
3
  services:
4
  webp:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
  restart: always
9
  volumes:
10
  - ./path/to/pics:/opt/pics
11
  - ./exhaust:/opt/exhaust
12
  - ./metadata:/opt/metadata
13
  ports:
14
+ - 127.0.0.1:8000:3333