diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..508d711 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.19-buster as builder + +# Create and change to the app directory. +WORKDIR /app + +# Retrieve application dependencies. +# This allows the container build to reuse cached dependencies. +# Expecting to copy go.mod and if present go.sum. +COPY go.* ./ +RUN go mod download + +# Copy local code to the container image. +COPY . ./ + +# Build the binary. +RUN go build -v -o etl ./cmd/etl/main.go + +# Use the official Debian slim image for a lean production container. +FROM debian:buster-slim +RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# Copy the binary to the production image from the builder stage. +COPY --from=builder /app/etl /app/etl + +# Run the web service on container startup. +CMD ["/app/etl"]