How to deploy a written golang project under docker?

ask for advice:
I have a local project in go language. Now I want to push the image to the online warehouse, and then pull from the online server to the production environment and run it.

my local directory is go- > src

        ->github/
        ->myapp/
        
        myapp github 
        myapp Dockerfile 
        
        
        ~~
Mar.13,2021

Thank you for the invitation

you can refer to the following steps

1. Solve the project dependency problem:

use tools such as govendor and dep to put project dependencies under the vendor package under the myapp project

2, Golang App package docker Image:

reference article Gin practice Serial 9 deploy Golang applications to Docker

3. Push image to online deployment

then you need to upload your packaged image to the image library before you can reach pull to the production environment
(package the local image-"upload remote image library -" pull the required image from the remote image library)

.
  • use Docker Hub
  • use other domestic providers
  • the company sets up a private one, and it's not difficult (the internal ones basically adopt this)
< hr >

the general idea is as above, follow the check and do, you can solve your problem

Menu