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

文章标题:go mod使用私有库

本文作者:kaisawind

发布时间:2020-06-04, 06:11:12

最后更新:2020-07-21, 14:35:46

原始链接:https://kaisawind.gitee.io/2020/06/03/2020-06-06-go-private-mod/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏