Build go without a container to avoid vendor

master
bel 2019-06-22 16:27:34 -06:00
parent 429bc20133
commit c8f015930e
1 changed files with 21 additions and 16 deletions

37
do.sh
View File

@ -141,36 +141,41 @@ function py2_dockerfiles() {
} }
function go_dockerfiles() { function go_dockerfiles() {
GOOS=linux CGO_ENABLED=0 go build -o ./exec-$thisexec -a -installsuffix cgo
from="golang:1.10-alpine" from="golang:1.10-alpine"
if [ "$(uname -s)" == "Darwin" ]; then if [ "$(uname -s)" == "Darwin" ]; then
from="registry-app.eng.qops.net:5001/imported/alpine/golang:1.10-alpine" from="registry-app.eng.qops.net:5001/imported/alpine/golang:1.10-alpine"
fi fi
DOCKERFILE=' #FROM '"$from"' as builder
FROM '"$from"' as builder #MAINTAINER breel@qualtrics.com
MAINTAINER breel@qualtrics.com #
#RUN apk add --no-cache git
RUN apk add --no-cache git #
#WORKDIR /go/'"$thispkg"'
WORKDIR /go/'"$thispkg"' #COPY . .
COPY . . #RUN /bin/sh -c "CGO_ENABLED=0 go build -o /go/bin/'"$thisexec"' -a -installsuffix cgo"
RUN /bin/sh -c "CGO_ENABLED=0 go build -o /go/bin/'"$thisexec"' -a -installsuffix cgo" #
#FROM busybox:glibc
FROM alpine as certs #COPY --from=builder /go/'"$thispkg"' /main
RUN apk update && apk add --no-cache ca-certificates #COPY --from=builder /go/bin /main
#======================== #========================
DOCKERFILE='
FROM alpine as certs
RUN apk update && apk add --no-cache ca-certificates
FROM busybox:glibc FROM busybox:glibc
COPY --from=builder /go/'"$thispkg"' /main COPY . .
COPY --from=builder /go/bin /main
RUN mkdir -p /var/log RUN mkdir -p /var/log
WORKDIR /main WORKDIR /main
ENV GOPATH="" ENV GOPATH=""
ENV MNT="/mnt/" ENV MNT="/mnt/"
#COPY /etc/ssl/certs /etc/ssl
COPY --from=certs /etc/ssl/certs /etc/ssl/certs COPY --from=certs /etc/ssl/certs /etc/ssl/certs
ENTRYPOINT ["/main/'"$thisexec"'"] ENTRYPOINT ["/main/exec-'"$thisexec"'"]
CMD [] CMD []
' '
echo "$DOCKERFILE" > "$dockfile" echo "$DOCKERFILE" > "$dockfile"