Dockerfile 527 B

1234567891011121314151617181920212223242526
  1. # Build image
  2. FROM golang:1.21 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. COPY internal ./internal
  9. # Install dependencies and build
  10. RUN go install
  11. RUN go build -o shorty
  12. # Distribution image
  13. FROM debian:12
  14. # Set default database path
  15. ENV SHORTY_DATABASE_PATH /shorty/data
  16. # Copy binary and set as command
  17. COPY --from=build /build/shorty /usr/local/bin/shorty
  18. ENTRYPOINT ["shorty"]
  19. CMD ["start"]