This project provides an API with access to a PostgreSQL. It has JWT integration in one of the endpoints.
method | endpoint | description | headers |
---|---|---|---|
GET | /health | checks healthiness and readiness | |
POST | /auth | returns jwt token |
|_ cmd
|_ pkg
|_ application
|_ containers
|_ controllers
|_ dtos
|_ domain
|_ interfaces
|_ schemas
|_ services
|_ infrastructure
|_ adapters
|_ config
|_ http
|_ repositories
|_ services
|_ presentation
|_ routers
- You need to have go, Docker, docker-compose, minikube, helm, helm secrets and skaffold installed
- Clone the repository by running
git clone https://github.com/brianfiszman/GoHexagonalBoilerplate
into your terminal - Create a .env file with the following content:
Name | Description | Example |
---|---|---|
HTTP_PORT | HTTP Port allocated for service | 3000 |
JWT_SECRET | Secret Key injected inside the JWT Token | foobar |
DATABASE_HOST | PostgreSQL database host location | localhost |
DATABASE_PORT | PostgreSQL database port number | 5432 |
DATABASE_USER | PostgreSQL database username | foo |
DATABASE_PASS | PostgreSQL database password | bar |
DATABASE_NAME | PostgreSQL database name | anycoloryoulike |
- Run
docker-compose up
in your terminal
-
First we need to worry about creating the secrets, which will be used as environment variables encrypted. To achieve this we need to have a GPG key created in our system. Once its created obtain it with the following command
gpg --list-secret-keys --keyid-format LONG
-
Replace the current GPG key in k8s/.sops.yaml file with the one in your clipboard
-
Modify the k8s/secrets.yaml file with the following environment variables:
secrets:
HTTP_PORT: "8080"
DATABASE_HOST: app-postgresql
DATABASE_PORT: "5432"
DATABASE_USER: postgres
DATABASE_PASS: "123123"
DATABASE_NAME: testdb
postgresql-password: "123123"
-
Run the following command:
make encrypt-secrets
-
Run
minikube start
to start the Kubernetes service on Docker -
Run
make skaffold-debug
in your terminal. -
Enjoy!
I want to thank for the support in this project to my GlobalLogic Team, @barbaraimperatori and @MaxiSanchez600 You are really awesome! :-D