Add Dockerfile (#31)

* Add Dockerfile

* Add docker run mode
This commit is contained in:
muzi 2020-03-13 21:28:19 +08:00 committed by GitHub
parent 119925e7f9
commit cb4beb54f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM golang:alpine as builder
RUN apk update ;\
apk add alpine-sdk ;\
git clone https://github.com/webp-sh/webp_server_go /build ;\
cd /build ;\
sed -i 's/\/path\/to\/exhaust/\/opt\/exhaust/g' config.json ;\
sed -i 's/\/path\/to\/pics/\/opt\/pics/g' config.json ;\
sed -i 's/127.0.0.1/0.0.0.0/g' config.json
WORKDIR /build
RUN go build -o webp-server .
FROM alpine
COPY --from=builder /build/webp-server /usr/bin/webp-server
COPY --from=builder /build/config.json /etc/config.json
WORKDIR /opt
VOLUME /opt/exhaust
CMD ["/usr/bin/webp-server", "--config", "/etc/config.json"]

View File

@ -102,6 +102,15 @@ systemctl daemon-reload
systemctl enable webp-server.service systemctl enable webp-server.service
systemctl start webp-server.service systemctl start webp-server.service
``` ```
#### docker
We've build docker images on [hub.docker.com](https://hub.docker.com/repository/docker/webpsh/webps). If you want to run webp-server insider docker container, you can run the command below,
```shell
docker run -d -p 3333:3333 -v /path/to/pics:/opt/pics --name webps webpsh/webps
```
The path `path/to/pics` is your images serving in local. The path `/opt/pics` unable modify because it define in the `config.json` when building docker image. The cache folder of `EXHAUST_PATH` default define in `/opt/exhaust` , you can also mount the local dir for the cache folder by using `-v /path/to/exhaust:/opt/exhaust` option.
### 4. Nginx proxy_pass ### 4. Nginx proxy_pass
Let Nginx to `proxy_pass http://localhost:3333/;`, and your webp-server is on-the-fly Let Nginx to `proxy_pass http://localhost:3333/;`, and your webp-server is on-the-fly
#### WordPress example #### WordPress example