Skip to content

Commit

Permalink
chore: replace backend subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-milan committed May 3, 2024
1 parent eabbd56 commit bf22f54
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
- name: "BASE_URL_FRONTEND"
value: "https://development.basedosdados.org"
- name: "BASE_URL_API"
value: "https://development.api.basedosdados.org"
value: "https://development.backend.basedosdados.org"
- name: "CSRF_COOKIE_DOMAIN"
value: "${{ secrets.CSRF_COOKIE_DOMAIN }}"
- name: "CSRF_TRUSTED_ORIGIN"
Expand Down Expand Up @@ -145,15 +145,15 @@ jobs:
passwordSecret: "api-development-database-password"
ingress:
enabled: true
host: "development.api.basedosdados.org"
host: "development.backend.basedosdados.org"
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/issuer: "letsencrypt-production"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
tls:
- hosts:
- development.api.basedosdados.org
- development.backend.basedosdados.org
secretName: api-development-basedosdados-org-tls
EOF
- name: Deploy using Helm
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
|| ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: production
url: https://api.basedosdados.org
url: https://backend.basedosdados.org
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: "BASE_URL_FRONTEND"
value: "https://basedosdados.org"
- name: "BASE_URL_API"
value: "https://api.basedosdados.org"
value: "https://backend.basedosdados.org"
- name: "CSRF_COOKIE_DOMAIN"
value: "${{ secrets.CSRF_COOKIE_DOMAIN }}"
- name: "CSRF_TRUSTED_ORIGIN"
Expand Down Expand Up @@ -114,15 +114,15 @@ jobs:
passwordSecret: "api-prod-database-password"
ingress:
enabled: true
host: "api.basedosdados.org"
host: "backend.basedosdados.org"
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/issuer: "letsencrypt-production"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
tls:
- hosts:
- api.basedosdados.org
- backend.basedosdados.org
secretName: api-basedosdados-org-tls
EOF
- name: Deploy using Helm
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
|| ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: staging
url: https://staging.api.basedosdados.org
url: https://staging.backend.basedosdados.org
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: "BASE_URL_FRONTEND"
value: "https://staging.basedosdados.org"
- name: "BASE_URL_API"
value: "https://staging.api.basedosdados.org"
value: "https://staging.backend.basedosdados.org"
- name: "CSRF_COOKIE_DOMAIN"
value: "${{ secrets.CSRF_COOKIE_DOMAIN }}"
- name: "CSRF_TRUSTED_ORIGIN"
Expand Down Expand Up @@ -114,15 +114,15 @@ jobs:
passwordSecret: "api-staging-database-password"
ingress:
enabled: true
host: "staging.api.basedosdados.org"
host: "staging.backend.basedosdados.org"
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/issuer: "letsencrypt-production"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
tls:
- hosts:
- staging.api.basedosdados.org
- staging.backend.basedosdados.org
secretName: staging-api-basedosdados-org-tls
EOF
- name: Deploy using Helm
Expand Down
14 changes: 9 additions & 5 deletions bd_api/apps/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

URL_MAPPING = {
"localhost:8080": "http://localhost:3000",
"api.basedosdados.org": "https://basedosdados.org",
"staging.api.basedosdados.org": "https://staging.basedosdados.org",
"development.api.basedosdados.org": "https://development.basedosdados.org",
"backend.basedosdados.org": "https://basedosdados.org",
"staging.backend.basedosdados.org": "https://staging.basedosdados.org",
"development.backend.basedosdados.org": "https://development.basedosdados.org",
}


Expand All @@ -27,8 +27,12 @@ def get(self, request, *args, **kwargs):
if dataset := request.GET.get("dataset"):
dataset_slug = dataset.replace("-", "_")

if resource := CloudTable.objects.filter(gcp_dataset_id=dataset_slug).first():
return HttpResponseRedirect(f"{domain}/dataset/{resource.table.dataset.id}")
if resource := CloudTable.objects.filter(
gcp_dataset_id=dataset_slug
).first():
return HttpResponseRedirect(
f"{domain}/dataset/{resource.table.dataset.id}"
)

if resource := Dataset.objects.filter(slug__icontains=dataset_slug).first():
return HttpResponseRedirect(f"{domain}/dataset/{resource.id}")
Expand Down
6 changes: 3 additions & 3 deletions bd_api/custom/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def get_backend_url():
"""Get backend url by environment"""

if is_prd():
return "api.basedosdados.org"
return "backend.basedosdados.org"
if is_stg():
return "staging.api.basedosdados.org"
return "staging.backend.basedosdados.org"
if is_dev():
return "development.api.basedosdados.org"
return "development.backend.basedosdados.org"
return "localhost:8080"


Expand Down

0 comments on commit bf22f54

Please sign in to comment.