-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added air support for hot reloading
Updated docker configs and added an air config for faster development. Air is a watches all the go files and rebuilds whenever there is any change in the code to reflect in the API immediately
- Loading branch information
1 parent
4f40f8e
commit c0fbd97
Showing
5 changed files
with
80 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format | ||
|
||
# Working directory | ||
# . or absolute path, please note that the directories following must be under root | ||
root = "." | ||
tmp_dir = "/tmp" | ||
|
||
[build] | ||
# Just plain old shell command. You could use `make` as well. | ||
cmd = "go build -o ./tmp/app/permify ./cmd/permify" | ||
# Binary file yields from `cmd`. | ||
bin = "/tmp/app" | ||
|
||
# Customize binary. | ||
# This is how you start to run your application. Since my application will works like CLI, so to run it, like to make a CLI call. | ||
full_bin = "./tmp/app/permify serve --database-engine postgres --database-uri postgres://postgres:secret@database:5432/permify --database-max-open-connections 20" | ||
# This log file places in your tmp_dir. | ||
log = "air_errors.log" | ||
# Watch these filename extensions. | ||
include_ext = ["go", "yaml",".env"] | ||
# Ignore these filename extensions or directories. | ||
exclude_dir = ["tmp", "docs"] | ||
# It's not necessary to trigger build each time file changes if it's too frequent. | ||
delay = 500 # ms | ||
|
||
[log] | ||
# Show log time | ||
time = true | ||
[color] | ||
|
||
[misc] | ||
# Delete tmp directory on exit | ||
clean_on_exit = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,5 @@ | |
# Dependency directories (remove the comment below to include it) | ||
vendor/dist/ | ||
/dist | ||
/config | ||
/config | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM golang:1.21-alpine | ||
|
||
RUN apk --no-cache add curl | ||
# Install the air binary so we get live code-reloading when we save files | ||
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin | ||
|
||
# Run the air command in the directory where our code will live | ||
WORKDIR /app | ||
|
||
ENTRYPOINT [ "air" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
version: "3.9" | ||
services: | ||
permify: | ||
image: "ghcr.io/permify/permify:latest" | ||
command: "serve --database-engine postgres --database-uri postgres://postgres:secret@database:5432/permify --database-max-open-connections 20" | ||
restart: "always" | ||
ports: | ||
- "3476:3476" | ||
- "3478:3478" | ||
depends_on: | ||
- "database" | ||
permify: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.local | ||
restart: "always" | ||
ports: | ||
- "3476:3476" | ||
- "3478:3478" | ||
volumes: | ||
- .:/app | ||
depends_on: | ||
- "database" | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:3476/healthz"] | ||
interval: 10s | ||
retries: 10 | ||
start_period: 60s | ||
|
||
database: | ||
image: "postgres" | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- "POSTGRES_PASSWORD=secret" | ||
- "POSTGRES_DB=permify" | ||
database: | ||
image: "postgres" | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- "POSTGRES_PASSWORD=secret" | ||
- "POSTGRES_DB=permify" | ||
|
||
integration: | ||
build: | ||
context: . | ||
dockerfile: integration-test/Dockerfile | ||
container_name: integration | ||
image: integration | ||
depends_on: | ||
- permify | ||
integration: | ||
build: | ||
context: . | ||
dockerfile: integration-test/Dockerfile | ||
container_name: integration | ||
image: integration | ||
depends_on: | ||
permify: | ||
condition: service_healthy | ||
|
||
volumes: | ||
pg-data: | ||
pg-data: |