- Docker and Go
- golang-migrate/migrate
Clone the repository with:
git clone github.com/rizperdana/prototype-golang-rest
Copy the env.example
file to a .env
file.
$ cp .env.example .env
Update the postgres variables declared in the new .env
to match your preference.
There's a handy guide on the Postgres' DockerHub.
Build and start the services with:
$ docker-compose up --build
The database migration files are in db/migrations
so feel free to simply source them directly. Alternatively, you can apply them using migrate
by running:
$ export POSTGRESQL_URL="postgres://$PG_USER:$PG_PASS@localhost:5432/$PG_DB?sslmode=disable"
$ migrate -database ${POSTGRESQL_URL} -path db/migrations up
NOTE: Remember to replace the $PG*
variables with their actual values
After making your changes, you can rebuild the server
service by running the commands below
$ docker-compose stop server
$ docker-compose build server
$ docker-compose up --no-start server
$ docker-compose start server