PhysarumSM / service-registry

Apache License 2.0
0 stars 0 forks source link

Automatically package users' microservices into docker images #12

Closed hivanco closed 4 years ago

hivanco commented 4 years ago

Current flow for creating new docker images contains many repetitive steps. Only thing that changes are specific to a microservice (name, files). Also, someone deploying their microservice shouldn't need to be concerned with how to package our proxy+related files, setup environment variables, things internal to our system. Simply provide users' files, configuration info, microservice name, and our system can take care of the rest.

hivanco commented 4 years ago

Work being done on image-auto-packaging branch

hivanco commented 4 years ago

Commit b153d890c966d97794a441379a37bf105926c947 allows user to provide their microservice's files to build image packaged with our proxy, push to dockerhub, and register with hash lookup in one command. Next, need to migrate functions and tests. Image build, save, and push to docker_driver. Getting username/password, tar balling files, and hashing can all go to common. May introduce some new flags (select specific proxy version to build).

hivanco commented 4 years ago

Brief comment on new hl-cli usage: ./hl-cli --bootstrap <addr> add <config> <dir> <image-name> <service-name>

<config> is a json file of this format:

{
    "PerfConf": {
        "Perf": {
            "SoftReq": {
                "RTT": 100
            },
            "HardReq": {
                "RTT": 1000
            }
        },
        "Bootstraps": [
            "/ip4/10.11.17.32/tcp/4001/ipfs/12D3KooWGegi4bWDPw9f6x2mZ6zxtsjR8w4ax1tEMDKCNqdYBt7X"
        ]
    },
    "DockerConf": {
        "Copy": [
            ["server", "."],
            ["certificate.crt", "/usr/local/share/ca-certificates/certificate.crt"]
        ],
        "Run": [
            "apt-get update && apt-get install -y ca-certificates",
            "update-ca-certificates"
        ],
        "Cmd": "./server $PROXY_IP $SERVICE_PORT",
        "ProxyClientMode": false
    }
}

PerfConf is the json you would want to pass to proxy (see service-manager). DockerConf is stuff about the image: which files to copy, commands to run, the actual command to run your service, and whether to run proxy in client mode (most likely false).

<dir> is the directory to find the files needed to build this image, ie. the files listed under DockerConf.Copy.

<image-name> is what you want to name the image. This should be the full name used to push to dockerhub, ie. <username>/<repo>:<tag>.

<service-name> is the name used to register this service with hash-lookup.

hl-cli will take this and build an image, push to dockerhub, and add to hash-lookup.

t-lin commented 4 years ago

@hivanco Is there a way to specify a temp proxy binary be used instead of cloning the latest service-manager repo?? This is useful in cases where we're testing the ongoing development of the proxy.

hivanco commented 4 years ago

Yup, see the --proxy-version flag under the add command: https://github.com/Multi-Tier-Cloud/hash-lookup/blob/dcab30c7056ff683ef03252e02fc0ce9b7387752/hl-cli/add.go#L53

You can do something like hl-cli add --proxy-version <commit hash> Where <commit hash> gets passed to git checkout. So you could pass a branch or tags/<tag> or whatever argument git checkout accepts.

hivanco commented 4 years ago

Oh wait nevermind, I see what you mean. Like your own locally built proxy. Not currently, I should add a flag for that.

hivanco commented 4 years ago

See #19