Docker

kratos-layout Dockerfile is provided by default, and multiple stages build is recommended to get the smallest size of container images.

Dockerfile

  1. FROM golang:1.15 AS builder
  2. COPY . /src
  3. WORKDIR /src
  4. RUN GOPROXY=https://goproxy.cn make build
  5. FROM debian:stable-slim
  6. RUN apt-get update && apt-get install -y --no-install-recommends \
  7. ca-certificates \
  8. netbase \
  9. && rm -rf /var/lib/apt/lists/ \
  10. && apt-get autoremove -y && apt-get autoclean -y
  11. COPY --from=builder /src/bin /app
  12. WORKDIR /app
  13. EXPOSE 8000
  14. EXPOSE 9000
  15. VOLUME /data/conf
  16. CMD ["./server", "-conf", "/data/conf"]

Build Image

  1. docker build -t <your-docker-image-name> .

Run Container

  1. docker run --rm -p 8000:8000 -p 9000:9000 -v </path/to/your/configs>:/data/conf <your-docker-image-name>