Since the Docker image of the STNS server is large, I made a lightweight Docker image.
The build environment and execution environment are separated by using multi-stage build.
--Multi-stage build --Build-time image: golang: 1.15.6-alpine3.12 --Runtime image: alpine: 3.12
We have achieved a ** 68% size reduction ** compared to the officially provided Docker image.
$ docker images | grep stns
stns-server latest 98a315731b33 41 minutes ago 69.2MB
stns/stns latest 597e448def6a 9 days ago 219MB
Dockerfile
FROM golang:1.15.6-alpine3.12 AS builder
WORKDIR /tmp
ENV BUILD=/artifacts
RUN apk --no-cache update && \
apk --no-cache upgrade && \
apk --no-cache add make alpine-sdk gcc openssl libcurl git && \
git clone https://github.com/STNS/STNS.git && \
cd STNS/ && \
mkdir -p $BUILD && \
make install MODDIR=$BUILD BINDIR=$BUILD
FROM alpine:3.12
EXPOSE 1104/tcp
WORKDIR /stns
COPY --from=builder /artifacts /stns
COPY config.toml /stns
ENTRYPOINT ["/stns/stns", "--config", "/stns/config.toml", "server"]
Recommended Posts