Skip to content

Commit b76d277

Browse files
get ready for render
1 parent b5be379 commit b76d277

File tree

9 files changed

+36
-16
lines changed

9 files changed

+36
-16
lines changed

.env.docker

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PORT=8080
22
HOST=0.0.0.0
3-
DATABASE_URL=postgres://forgotten_user:123456@postgres:5432/forgotten_db?sslmode=disable
3+
DB_URL=postgres://forgotten_user:123456@postgres:5432/forgotten_db?sslmode=disable
44
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
5-
ENVIRONMENT=development
5+
SERVER_ENVIRONMENT=development
66
DB_AUTO_MIGRATE=true
77
DB_RUN_MIGRATIONS=false
88
MIGRATIONS_PATH=internal/database/migrations

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PORT=8080
22
HOST=localhost
3-
DATABASE_URL=postgres://user:password@localhost:5432/myapp_db?sslmode=disable
3+
DB_URL=postgres://user:password@localhost:5432/myapp_db?sslmode=disable
44
JWT_SECRET=your-super-secret-jwt-key
5-
ENVIRONMENT=development
5+
SERVER_ENVIRONMENT=development
66
DB_AUTO_MIGRATE=true
77
DB_RUN_MIGRATIONS=false
88
MIGRATIONS_PATH=path/to/migrations

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Run tests
4747
run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
4848
env:
49-
DATABASE_URL: postgres://postgres:password@localhost:5432/testdb?sslmode=disable
49+
DB_URL: postgres://postgres:password@localhost:5432/testdb?sslmode=disable
5050

5151
- name: Upload coverage to Codacy
5252
uses: codacy/codacy-coverage-reporter-action@v1

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ tools:
5555

5656
# Database migrations
5757
migrate-up:
58-
migrate -path internal/database/migrations -database "$(DATABASE_URL)" up
58+
migrate -path internal/database/migrations -database "$(DB_URL)" up
5959

6060
migrate-down:
61-
migrate -path internal/database/migrations -database "$(DATABASE_URL)" down 1
61+
migrate -path internal/database/migrations -database "$(DB_URL)" down 1
6262

6363
migrate-force:
64-
migrate -path internal/database/migrations -database "$(DATABASE_URL)" force $(VERSION)
64+
migrate -path internal/database/migrations -database "$(DB_URL)" force $(VERSION)
6565

6666
migrate-create:
6767
migrate create -ext sql -dir internal/database/migrations -seq $(NAME)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cd forgotten
3838

3939
3) Configure environment
4040
- Copy `.env.example` to `.env` and adjust as needed:
41-
- `DATABASE_URL` (e.g., postgres://user:password@localhost:5432/forgotten_db?sslmode=disable)
41+
- `DB_URL` (e.g., postgres://user:password@localhost:5432/forgotten_db?sslmode=disable)
4242
- Seed data lives at `data/seed_users.json`.
4343

4444
### Run locally (without Docker)

docs/DOCKER_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker login ghcr.io
2020
# 2. Download and run the application
2121
docker pull ghcr.io/nevzattalhaozcan/forgotten-app:latest
2222
docker run -d --name forgotten-postgres -e POSTGRES_DB=forgotten_db -e POSTGRES_USER=forgotten_user -e POSTGRES_PASSWORD=123456 -p 5432:5432 postgres:15-alpine
23-
docker run -d --name forgotten-app -p 8080:8080 --link forgotten-postgres -e DATABASE_URL=postgres://forgotten_user:123456@forgotten-postgres:5432/forgotten_db ghcr.io/nevzattalhaozcan/forgotten-app:latest
23+
docker run -d --name forgotten-app -p 8080:8080 --link forgotten-postgres -e DB_URL=postgres://forgotten_user:123456@forgotten-postgres:5432/forgotten_db ghcr.io/nevzattalhaozcan/forgotten-app:latest
2424
```
2525

2626
### Option B: Using Repository

internal/config/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ func Load() *Config {
5555
log.Printf("no .env file found or error loading it: %v", err)
5656
}
5757

58-
env := getEnv("ENVIRONMENT", "development")
58+
env := getEnv("SERVER_ENVIRONMENT", "development")
5959
defaultAutoMigrate := env != "production"
6060

6161
return &Config{
6262
Server: ServerConfig{
63-
Port: getEnv("PORT", "8080"),
64-
Host: getEnv("HOST", "localhost"),
65-
Environment: getEnv("ENVIRONMENT", env),
63+
Host: getEnv("SERVER_HOST", "localhost"),
64+
Port: getEnv("SERVER_PORT", "8080"),
65+
Environment: getEnv("SERVER_ENVIRONMENT", env),
6666
},
6767
Database: DatabaseConfig{
68-
URL: getEnv("DATABASE_URL", "postgres://user:password@localhost:5432/dbname?sslmode=disable"),
68+
URL: getEnv("DB_URL", "postgres://user:password@localhost:5432/dbname?sslmode=disable"),
6969
MaxOpenConns: getEnvAsInt("DB_MAX_OPEN_CONNS", 25),
7070
MaxIdleConns: getEnvAsInt("DB_MAX_IDLE_CONNS", 5),
7171
AutoMigrate: getEnvAsBool("DB_AUTO_MIGRATE", defaultAutoMigrate),

internal/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
func TestMain(m *testing.M) {
9-
os.Setenv("ENVIRONMENT", "development")
9+
os.Setenv("SERVER_ENVIRONMENT", "development")
1010
code := m.Run()
1111
os.Exit(code)
1212
}

render.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
- type: web
3+
name: forgotten-api
4+
runtime: docker
5+
plan: free
6+
rootDir: .
7+
dockerfilePath: ./docker/Dockerfile
8+
autoDeploy: true
9+
healthCheckPath: /health
10+
envVars:
11+
- key: SERVER_HOST
12+
value: 0.0.0.0
13+
- key: SERVER_PORT
14+
value: ${PORT}
15+
- key: SERVER_ENVIRONMENT
16+
value: production
17+
- key: DB_URL
18+
sync: false
19+
- key: REDIS_URL
20+
sync: false

0 commit comments

Comments
 (0)