Dockerfile 793 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Start from the latest golang base image
  2. FROM golang:latest as builder
  3. # Add Maintainer Info
  4. LABEL maintainer="Honza Pokorny <me@honza.ca>"
  5. # Set the Current Working Directory inside the container
  6. WORKDIR /app
  7. # Copy go mod and sum files
  8. COPY go.mod go.sum ./
  9. # Copy the source from the current directory to the Working Directory inside the container
  10. COPY . .
  11. # Build the Go app
  12. RUN make
  13. ######## Start a new stage from scratch #######
  14. FROM alpine:latest
  15. RUN apk --no-cache add ca-certificates
  16. WORKDIR /root/
  17. # Copy the Pre-built binary file from the previous stage
  18. COPY --from=builder /app/include include
  19. COPY --from=builder /app/config.yaml .
  20. COPY --from=builder /app/smithy .
  21. # Expose port 8080 to the outside world
  22. EXPOSE 8080
  23. # Command to run the executable
  24. CMD ["./smithy"]