Fix the god damn cgo nightmare
This commit is contained in:
@@ -18,14 +18,26 @@ COPY . .
|
|||||||
# RUN go mod download
|
# RUN go mod download
|
||||||
# RUN go mod verify
|
# RUN go mod verify
|
||||||
|
|
||||||
RUN GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main .
|
RUN apt-get update && apt-get install -y \
|
||||||
|
gcc \
|
||||||
|
libc6-dev
|
||||||
|
|
||||||
|
RUN GOFLAGS=-mod=vendor \
|
||||||
|
CGO_ENABLED=1 \
|
||||||
|
GOOS=linux \
|
||||||
|
GOARCH=amd64 \
|
||||||
|
CGO_LDFLAGS="-static -w -s" \
|
||||||
|
go build \
|
||||||
|
-ldflags '-extldflags "-static"' \
|
||||||
|
-o main .
|
||||||
|
|
||||||
# Final stage
|
# Final stage
|
||||||
# Pick your poison
|
# Pick your poison
|
||||||
# Ordered by size desc
|
# Ordered by size desc
|
||||||
# FROM ubuntu:latest
|
# FROM ubuntu:latest
|
||||||
# FROM alpine:latest
|
FROM alpine:latest
|
||||||
FROM scratch
|
# FROM scratch
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
|
||||||
# Run this for ubuntu
|
# Run this for ubuntu
|
||||||
# RUN apt-get update && apt-get install -y curl vim git && apt-get clean
|
# RUN apt-get update && apt-get install -y curl vim git && apt-get clean
|
||||||
@@ -40,6 +52,5 @@ COPY --from=base /etc/group /etc/group
|
|||||||
|
|
||||||
# Use the non-root user
|
# Use the non-root user
|
||||||
# USER small-user
|
# USER small-user
|
||||||
EXPOSE 8090
|
|
||||||
|
|
||||||
CMD ["/main"]
|
CMD ["/main"]
|
Reference in New Issue
Block a user