Skip to content

Commit

Permalink
docs: Update README and Makefile (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnantaWeda authored Oct 1, 2024
1 parent fc4e5be commit 72b76f0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ DB_PASSWORD=thisisasamplepassword
DB_NAME=fiberdb
DB_PORT=5432

# migration golang path
MIGRATION_PATH=~/migrate

# JWT
# JWT secret key
JWT_SECRET=thisisasamplesecret
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include .env
export $(shell sed 's/=.*//' .env)

start:
@go run src/main.go
lint:
Expand All @@ -10,6 +13,14 @@ testsum:
@cd test && gotestsum --format testname
swagger:
@cd src && swag init
migrate-up:
@$(MIGRATE_PATH) -database "postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=disable" -path src/database/migrations up
migrate-down:
@$(MIGRATE_PATH) -database "postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=disable" -path src/database/migrations down
migrate-docker-up:
@docker run -v ./src/database/migrations:/migrations --network go-fiber-boilerplate_go-network migrate/migrate -path=/migrations/ -database postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=disable up
migrate-docker-down:
@docker run -v ./src/database/migrations:/migrations --network go-fiber-boilerplate_go-network migrate/migrate -path=/migrations/ -database postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=disable down -all
docker:
@docker-compose up --build
docker-test:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ cp .env.example .env
- **Compression**: gzip compression with [Fiber-Compress](https://docs.gofiber.io/api/middleware/compress)
- **Docker support**
- **Linting**: with [golangci-lint](https://golangci-lint.run)
- **Migrations**: with [golang-migrate](https://github.com/golang-migrate/migrate)

## Commands

Expand Down Expand Up @@ -133,6 +134,22 @@ Swagger:
make swagger
```

Migration:

```bash
# run migration up in local
make migrate-up

# run migration down in local
make migrate-down

# run migration up in docker container
make migrate-docker-up

# run migration down all in docker container
make migrate-docker-down-all
```

## Environment Variables

The environment variables can be found and modified in the `.env` file. They come with these default values:
Expand Down

0 comments on commit 72b76f0

Please sign in to comment.