-
-
Save anjilinux/d23c79ea8b6860e9607afe0bc3ac213f to your computer and use it in GitHub Desktop.
Multi-stage build Dockerfile for Go and Kafka with confluent-kafka-go and Alpine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM golang:alpine AS build | |
| RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories | |
| RUN apk upgrade --update-cache --available | |
| RUN apk add --no-cache \ | |
| gcc \ | |
| libc-dev \ | |
| librdkafka-dev=1.3.0-r0 \ | |
| pkgconf | |
| RUN mkdir /app | |
| WORKDIR /app | |
| ADD go.mod . | |
| ADD go.sum . | |
| RUN go mod download | |
| ADD . /app/ | |
| RUN go build -o main . | |
| FROM alpine | |
| RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories | |
| RUN apk upgrade --update-cache --available | |
| RUN apk add --no-cache \ | |
| librdkafka-dev=1.3.0-r0 | |
| WORKDIR /app | |
| COPY --from=build /app/main /app/ | |
| CMD ["/app/main"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment