You can find more information about this project/repository and how to use it in following blog posts:
- Ultimate Setup for Your Next Golang Project
- Setting up GitHub Package Registry with Docker and Golang
- Building RESTful APIs in Golang
- Setting Up Swagger Docs for Golang API
- Replace All Occurrences of
trung85-go/go-project-blueprint
with your username repository name - Replace All Occurrences of
blueprint
with your desired image name
go mod vendor
Create and Push:
docker login docker.pkg.github.com -u <USERNAME> -p <GITHUB_TOKEN>
docker build -t docker.pkg.github.com/trung85-go/go-project-blueprint/blueprint:latest .
# make container
docker push docker.pkg.github.com/trung85-go/go-project-blueprint/blueprint:latest
# make push
List all docker packages on github: https://github.com/trung85-go/go-project-blueprint/packages
Pull and Run:
docker pull docker.pkg.github.com/trung85-go/go-project-blueprint/blueprint:latest
docker run -p 1234:1234 \
-e BLUEPRINT_DSN="postgres://<USER>:<PASSWORD>@<DOCKER_SERVICE/URL>:<PORT>/<DB>?sslmode=disable" \
-e BLUEPRINT_API_KEY="api_key" \
docker.pkg.github.com/trung85-go/go-project-blueprint/blueprint:latest
- https://docs.travis-ci.com/user/sonarcloud/
- On SonarCloud:
- Click Plus Sign in Upper Right Corner
- Analyze New Project
- Click GitHub app configuration link
- Configure SonarCloud
- Select Repository and Save
- Go Back to Analyze Project
- Tick Newly Added Repository
- Click Set Up
- Click Configure with Travis
- Copy the Command to Encrypt the Travis Token
- Run
travis encrypt --com <TOKEN_YOU_COPPIED>
(generate token in SonarCloud) - Populate the
secure
Field in.travis.yml
with outputted string - Follow steps to populate your
sonar-project.properties
- Push
- On Travis CI:
- Set
DOCKER_USERNAME
. (organization github trung85-go) - Set
DOCKER_PASSWORD
to Your GitHub Registry Token (develop github token)
- Set
- Go to https://codeclimate.com/github/repos/new
- Add Repository
- Go to Test Coverage Tab
- Copy Test Reporter ID
- Go to Travis and Open Settings for Your Repository
- Add Environment Variable: name:
CC_TEST_REPORTER_ID
, value: Copied from CodeClimate (https://codeclimate.com/repos/5f114fcb20e8de018b00b776/settings/test_reporter)
- Application uses gin-swagger.
- To generate/update docs use
swag init
(from/go-project-blueprint/cmd/blueprint
) - You can find generated docs in
docs
package
To view docs, navigate to http://localhost:1234/swagger/index.html or to http://localhost:1234/swagger/doc.json for raw JSON