golang private module
1.0.0
비공개 GIT 저장소를 사용하는 Go 모듈
go env -w GOPRIVATE=github.com/appleboy
git config --global url. " https:// $USERNAME : $ACCESS_TOKEN @github.com " .insteadOf " https://github.com "
개인 저장소를 사용해보십시오.
go get github.com/appleboy/golang-private
steps :
- name : build
image : golang:1.13
environment :
USERNAME :
from_secret : username
ACCESS_TOKEN :
from_secret : access_token
commands :
- go env -w GOPRIVATE=github.com/$USERNAME
- git config --global url."https://$USERNAME:[email protected]".insteadOf "https://github.com"
- go mod tidy
- go build -o main .
다음을 참조하세요.
# Start from the latest golang base image
FROM golang:1.14 as Builder
RUN GOCACHE=OFF
RUN go env -w GOPRIVATE=github.com/appleboy
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy everything from the current directory to the Working Directory inside the container
COPY . .
ARG ACCESS_TOKEN
ENV ACCESS_TOKEN=$ACCESS_TOKEN
RUN git config --global url. "https://appleboy:${ACCESS_TOKEN}@github.com" .insteadOf "https://github.com"
# Build the Go app
RUN go build -o main .
FROM scratch
COPY --from=Builder /app/main /
CMD [ "/main" ]
Drone을 사용하여 이미지를 빌드하고 설정의 보안 섹션에서 Docker 액세스 토큰을 가져옵니다.
- name : build-image
image : plugins/docker
environment :
ACCESS_TOKEN :
from_secret : access_token
settings :
username :
from_secret : username
password :
from_secret : password
repo : appleboy/golang-module-private
build_args_from_env :
- ACCESS_TOKEN