This is simple ping-pong demo server that listens to /
on port 8080
written in golang.
It accepts POST requests with json with following syntax:
{"name":"YOUR_NAME"}
If request is correct the response will be in following format:
{"greeting":"Hello, YOUR_NAME"}
In case of error following json will be returned:
{"error":"ERROR_DESCRIPTION"}
This repo contains travis CI integration and in case there is tag and all tests passed it will upload docker image as GitHub package, where image tag is the tag of git.
# curl -X POST -d '{"name":"world"}' localhost:8080
{"greeting":"Hello, world"}
In order to utilize travis CI on your fork, connect TravisCI to your repository. Set following env variables for that repo:
DOCKER_USER
- your user name on github
DOCKER_PASSWORD
- API token for github
DOCKER_REGISTRY
- registry to push to, e.g. for Packages
on github mine is set to docker.pkg.github.com
DO NOT forget to update badge in the head of this README to link to your build status
Each commit will trigger build tests
Each tag will result in new image pushed as
$DOCKER_REGISTRY/$GITHUB_USERNAME/$GITHUB_REPO/helloworld:$GIT_TAG
Following will generate helloworld
binary in root directory
git https://github.com/funkycode/helloworld.git
cd helloworld
# optionally run tests
go test ./...
go build
git https://github.com/funkycode/helloworld.git
cd helloworld
docker build . -t helloworld
docker run --name helloworld -d -p8080:8080 helloworld # docker port 8080 is binded to host port 8080
# pull latest changes
git pull
sh scripts/redeploy.sh
Script above will do following:
- It will rebuild image as
helloworld:latest
from latest code - Try to stop previous instance (in case you have one running already)
- Start docker with name
helloworld
while binding8080
port of docker to8080
on host.