Dockerfile 460 B

123456789101112131415161718192021
  1. # Build image
  2. FROM golang:1.21.3 AS build
  3. WORKDIR /build
  4. # Configure known hosts
  5. RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts
  6. # Copy source
  7. COPY go.mod go.sum main.go ./
  8. # Install dependencies and build
  9. RUN go install
  10. RUN go build -o short-url-service
  11. # Distribution image
  12. FROM debian:12
  13. # Copy binary and set as command
  14. COPY --from=build /build/short-url-service /usr/local/bin/short-url-service
  15. CMD ["short-url-service"]