LoginSignup
4
4

More than 3 years have passed since last update.

軽量なSTNSのDockerイメージを作る

Last updated at Posted at 2020-12-30

STNSサーバのDockerイメージが大きいので軽量なDockerイメージを作った.

cdsl-research/stns-container

構成

マルチステージビルドを使うことでビルド環境と実行環境を分離した.

  • マルチステージビルド
    • ビルド時イメージ: golang:1.15.6-alpine3.12
    • 実行時イメージ: alpine:3.12

比較

公式の提供するDockerイメージに比べて68%のサイズ削減を実現した.

$ 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"]
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4