Skip to content

Commit

Permalink
rename step and include two custom domains
Browse files Browse the repository at this point in the history
  • Loading branch information
dreth committed Jul 25, 2024
1 parent 7833e68 commit b077b06
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: |
docker compose --version
- name: Navigate to the hbd dir and build + bring up the container
- name: build + bring up the container
run: |
docker compose -f docker-compose-prod.yml build &&
docker stop hbd || true &&
Expand Down
17 changes: 14 additions & 3 deletions backend/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
// Set the MASTER_KEY and DATABASE_URL environment variables
var DB *sql.DB = db()
var MK string = mk()
var CD string = customDomain()
var CDFE string = customDomainFrontend()
var CDBE string = customDomainBackend()

func DBType() string {
loadDotenv()
Expand Down Expand Up @@ -71,11 +72,21 @@ func db() *sql.DB {
}

// Custom domain for CORS
func customDomain() string {
func customDomainFrontend() string {
loadDotenv()
customDomain := os.Getenv("CUSTOM_DOMAIN")
customDomain := os.Getenv("CUSTOM_DOMAIN_FRONTEND")
if customDomain == "" {
customDomain = "http://hbd.lotiguere.com"
}
return customDomain
}

// Custom domain for CORS
func customDomainBackend() string {
loadDotenv()
customDomain := os.Getenv("CUSTOM_DOMAIN_BACKEND")
if customDomain == "" {
customDomain = "http://hbd-api.lotiguere.com"
}
return customDomain
}
2 changes: 1 addition & 1 deletion backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {

// Configure CORS
router.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:8417", "http://localhost:8418", "http://localhost:3000", "http://0.0.0.0:8418", env.CD},
AllowOrigins: []string{"http://localhost:8417", "http://localhost:8418", "http://localhost:3000", "http://0.0.0.0:8418", env.CDFE, env.CDBE},
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowHeaders: []string{"Origin", "Content-Length", "Content-Type", "Authorization"},
ExposeHeaders: []string{"Content-Length"},
Expand Down
5 changes: 3 additions & 2 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ services:
- MASTER_KEY=35e150e7ca83247f18cb1a37d61d8e161dddec06027f5db009b34da48c25f1b5
- PORT=8418
- ENVIRONMENT=production
- CUSTOM_DOMAIN=https://hbd.lotiguere.com
- CUSTOM_DOMAIN_FRONTEND=https://hbd.lotiguere.com
- CUSTOM_DOMAIN_BACKEND=https://hbd-api.lotiguere.com
labels:
# Frontend
- "traefik.enable=true"
Expand All @@ -23,7 +24,7 @@ services:
- "traefik.http.services.hbd-service.loadbalancer.server.port=8418"

# Backend
- "traefik.http.routers.hbd-api.rule=Host(`hbd.lotiguere.com`) && PathPrefix(`/api`)"
- "traefik.http.routers.hbd-api.rule=Host(`hbd-api.lotiguere.com`)"
- "traefik.http.routers.hbd-api.entrypoints=websecure"
- "traefik.http.routers.hbd-api.tls.certresolver=myresolver"
- "traefik.http.routers.hbd-api.service=hbd-api-service"
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ services:
- MASTER_KEY=35e150e7ca83247f18cb1a37d61d8e161dddec06027f5db009b34da48c25f1b5
- PORT=8418
- ENVIRONMENT=development
- CUSTOM_DOMAIN=https://hbd.lotiguere.com
- CUSTOM_DOMAIN_FRONTEND=https://hbd.lotiguere.com
- CUSTOM_DOMAIN_BACKEND=https://hbd-api.lotiguere.com

networks:
default:
Expand Down

0 comments on commit b077b06

Please sign in to comment.