Fiber, Postgres, JWT and Swagger docs in isolated Docker containers.
These instructions will get you a copy of the project up and running on docker container and on your local machine.
Prequisites package:
- Docker
- Go Go Programming Language
- Swag. converts Go annotations to Swagger Documentation 2.0
- migrate tool for applying migrations.
- Make Automated Execution using Makefile
- Email for SMTP. If you use gmail, make sure Less Secure App Setting is enabled.
Optional package:
- gosec Golang Security Checker
- Rename
Makefile.example
toMakefile
and fill it with your make setting. - Run project by this command:
$ make run
# Process:
# - Generate API docs by Swagger
# - Create a new Docker network for containers
# - Build and run Docker containers (Fiber, PostgreSQL)
# - Apply database migrations (using github.com/golang-migrate/migrate)
Stop application by this command:
$ make stop
# Process:
# - Stop and remove postgres container
# - Stop and remove Fiber container
- Create local database by running command
createdb some_database_name
- Rename
run.sh.example
torun.sh
and fill it with your environment values. - Set
run.sh
file permission
$ chmod +x ./run.sh
- Run application from terminal by execute this command:
$ ./run.sh
- Go to your API Docs page: 127.0.0.1:3000/swagger/index.html
To reset database, run following command.
$ migrate -path ./platform/migrations -database "postgres://username:password@localhost:5432/db_name?sslmode=disable" down
Go to your API Docs page: 127.0.0.1:3000/swagger/index.html
API Docs page will be look like:
- Inspects source code for security problems using gosec. You need to install it first.
- Execute unit test
$ make test
- Inspects source code for security problems using gosec. You need to install it first.
- Execute unit test by using following command:
$ make test
- Go - Go Programming Languange
- Go Modules - Go Dependency Management System
- Make - GNU Make Automated Execution
- Docker - Application Containerization
- Fajar Rizky - Initial Work - cooljar