Original text transferred from:Upload docker image to GitHub docker registry automatically with drone』
I’m glad to receive itGitHubGet started with your beta invitationGitHub Package RegistryRelated functions. You can know from the description file that registry currently supports several packages, such asnpm, gem, docker, mvnandnuget, this article mainly introduces how to use drone to quickly connect the “automatically upload docker image to GitHub Registry” of CI / CD process. At the end, let’s see how to use the docker registry provided by GitHub.
For more practical videos, please refer to my udemy teaching series
- Go language practical course:http://bit.ly/golang-2019
- Drone CI / CD automation course:http://bit.ly/drone-2019
$ docker login docker.pkg.github.com \ -u USERNAME \ -p PASSWORD/TOKEN
The quickest way to log in to GitHub’s docker registry is to log in directly with your personal account and password, and the registry setting is
docker.pkg.github.comHere, please note that although the official has written that you can log in with your personal password, if you log in with OTP, this method is not applicable and safe. Personally, I strongly recommend that you establish an exclusive token in the background.
write:packagesPlease check the two scopes. If it is a private repo, then
repoCheck the option, so you can get a token as a password. You can
docker loginLet’s log in and try
Tandem drone CI / CD
From commit to automatic uploading of docker image can be quickly completed through drone. Let’s create it first
FROM plugins/base:multiarch LABEL maintainer="Bo-Yi Wu <[email protected]>" \ org.label-schema.name="Drone Workshop" \ org.label-schema.vendor="Bo-Yi Wu" \ org.label-schema.schema-version="1.0" ADD release/linux/amd64/helloworld /bin/ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/bin/helloworld", "-ping" ] ENTRYPOINT ["/bin/helloworld"]
Then through the official dronedockerSuite to complete automated upload
kind: pipeline name: default steps: - name: build image: golang:1.13 commands: - make build_linux_amd64 - name: docker image: plugins/docker settings: registry: docker.pkg.github.com repo: docker.pkg.github.com/appleboy/test/demo auto_tag: true auto_tag_suffix: linux-amd64 username: appleboy password: from_secret: docker_password
The difference between GitHub and dockerhub is that the format of GitHub is
OWNER/REPOSITORY/IMAGE_NAME, notice there’s one more in the middle
OWNER/IMAGE_NAME。 Then go backstage and
docker_passwordAfter setting, you can deploy correctly.
This work adoptsCC agreement, reprint must indicate the author and the link to this article