Docker Deployment

Micro easily runs inside docker containers

Prebuilt Images

Prebuilt images are available on Docker Hub

Install Micro

  1. docker pull micro/micro

Compose

Run a local deployment using docker compose

  1. consul:
  2. command: -server -bootstrap -rejoin
  3. image: progrium/consul:latest
  4. hostname: "registry"
  5. ports:
  6. - "8300:8300"
  7. - "8400:8400"
  8. - "8500:8500"
  9. - "8600:53/udp"
  10. api:
  11. command: --registry_address=registry:8500 --register_interval=5 --register_ttl=10 api
  12. build: .
  13. links:
  14. - consul
  15. ports:
  16. - "8080:8080"
  17. proxy:
  18. command: --registry_address=registry:8500 --register_interval=5 --register_ttl=10 proxy
  19. build: .
  20. links:
  21. - consul
  22. ports:
  23. - "8081:8081"
  24. web:
  25. command: --registry_address=registry:8500 --register_interval=5 --register_ttl=10 web
  26. build: .
  27. links:
  28. - consul
  29. ports:
  30. - "8082:8082"

Build from scratch

A Dockerfile is included in the repo

  1. FROM alpine:3.2
  2. RUN apk add --update ca-certificates && \
  3. rm -rf /var/cache/apk/* /tmp/*
  4. ADD micro /micro
  5. WORKDIR /
  6. ENTRYPOINT [ "/micro" ]

Build Binary

  1. CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' -i -o micro ./main.go

Build Image

  1. docker build -t micro .