2023-01-12 13:49:16 +00:00
|
|
|
FROM golang:alpine AS builder
|
|
|
|
# Set necessary environmet variables needed for our image
|
|
|
|
ENV GO111MODULE=on \
|
|
|
|
GOOS=linux \
|
|
|
|
GOARCH=amd64 \
|
|
|
|
CGO_ENABLED=0
|
|
|
|
WORKDIR /build
|
|
|
|
# Add the required build libraries
|
2023-01-12 15:09:39 +00:00
|
|
|
|
2023-01-12 13:49:16 +00:00
|
|
|
# Copy and download dependency using go mod
|
|
|
|
ADD ./src/go.* /build/
|
|
|
|
RUN go mod download
|
|
|
|
# Copy sources to build container
|
|
|
|
ADD ./src /build/
|
|
|
|
# Build the application
|
|
|
|
WORKDIR /build
|
|
|
|
RUN ls -al
|
|
|
|
RUN go build -a -tags musl -o /build/app
|
|
|
|
######################################
|
2023-01-12 15:09:39 +00:00
|
|
|
FROM golang:alpine
|
2023-01-12 15:14:29 +00:00
|
|
|
LABEL AUTHOR="Linuxcode"
|
2023-01-12 13:49:16 +00:00
|
|
|
#RUN apk --no-cache add curl
|
2023-01-12 15:14:29 +00:00
|
|
|
COPY --from=builder /build/app /custom/app
|
2023-01-12 15:09:39 +00:00
|
|
|
RUN go install golang.org/x/tools/cmd/goimports@latest
|
2023-01-12 13:49:16 +00:00
|
|
|
ENTRYPOINT [ "/custom/app" ]
|