go mod使用私有库

go mod使用私有库

Dockerfile

FROM golang:alpine AS builder
ARG username
ARG password
ENV GO111MODULE=on
WORKDIR /go/src/dev.yunxing.tech/edgex/app-service-pdiot

RUN sed -e 's/dl-cdn[.]alpinelinux.org/mirrors.aliyun.com/g' -i~ /etc/apk/repositories

# add git for go modules
RUN apk update && apk add make git upx
RUN echo "https://$username:$password@dev.yunxing.tech" > ~/.git-credentials
RUN git config --global credential.helper store
RUN go env -w GOPROXY=https://goproxy.io
RUN go env -w GOPRIVATE=dev.yunxing.tech

COPY . .

RUN make

congfig.mk

username := xxxx
password := xxxx

Makefile

## include config file ##
file := .config.mk
ifeq ($(file), $(wildcard $(file)))
include $(file)
endif

docker:
    docker buildx build \
        --platform=linux/arm64,linux/amd64 \
        --push \
        --build-arg username=$(username) \
        --build-arg password=$(password) \
        -f scripts/Dockerfile \
        -t csedge/docker-app-service-pdiot:$(DOCKER_TAG) .

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 wind.kaisa@gmail.com

💰

×

Help us with donation