Skip to content

Commit

Permalink
Merge pull request #10 from prefeitura-rio/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
lucastavarex authored Dec 12, 2024
2 parents e50902c + 222df8a commit 95a9d19
Show file tree
Hide file tree
Showing 35 changed files with 1,263 additions and 247 deletions.
7 changes: 5 additions & 2 deletions cloudbuild-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ steps:
# Create the .env file
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
args:
- "-c"
- |
echo "APP_URL=https://plataforma-clima.dados.rio" > .env.production && echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w" >> .env.production
echo "NEXT_PUBLIC_ENV=production" > .env.production
echo "NEXT_PUBLIC_ROOT_URL_PROD=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_ROOT_URL_DEV=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w" >> .env.production
# Build the container image
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA", "."]
Expand Down
17 changes: 13 additions & 4 deletions cloudbuild-staging.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
steps:
# Create the .env file
# Create the .env.staging file with environment variables
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
- "-c"
- |
echo "APP_URL=https://staging.plataforma-clima.dados.rio" > .env.production && echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w" >> .env.production
echo "NEXT_PUBLIC_ENV=staging" > .env.production
echo "NEXT_PUBLIC_ROOT_URL_PROD=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_ROOT_URL_DEV=https://gw.dados.rio/plataforma-clima-staging/" >> .env.production
echo "NEXT_PUBLIC_MAPBOX_API_KEY=pk.eyJ1IjoiZXNjcml0b3Jpb2RlZGFkb3MiLCJhIjoiY2t3bWdmcHpjMmJ2cTJucWJ4MGQ1Mm1kbiJ9.4hHJX-1pSevYoBbja7Pq4w" >> .env.production
# Build the container image
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA", "."]
args:
["build", "-t", "gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA", "."]

# Push the container image to Container Registry
- name: "gcr.io/cloud-builders/docker"
args: ["push", "gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA"]

# Kustomize: set the image in the kustomization.yaml file
- name: "gcr.io/cloud-builders/gke-deploy"
dir: "k8s/staging"
Expand All @@ -21,11 +28,13 @@ steps:
- "set"
- "image"
- "gcr.io/project-id/plataforma-clima=gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA"

# Kustomize: apply the kustomization.yaml file
- name: "gcr.io/cloud-builders/gke-deploy"
dir: "k8s/staging"
entrypoint: "kustomize"
args: ["build", ".", "-o", "staging.yaml"]

# Deploy the application to the GKE cluster
- name: "gcr.io/cloud-builders/gke-deploy"
dir: "k8s/staging"
Expand All @@ -37,4 +46,4 @@ steps:
- "--project=datario"

images:
- "gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA"
- "gcr.io/$PROJECT_ID/plataforma-clima:$COMMIT_SHA"
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const nextConfig = {
return [
{
source: '/',
destination: '/satelite/CP/mapa',
destination: '/previsao-de-chuva/v1/mapa',
permanent: true,
},
];
Expand Down
43 changes: 42 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
"geist": "^1.3.0",
"lucide-react": "^0.377.0",
"mapbox-gl": "^3.6.0",
"next": "14.2.3",
"next": "^14.2.3",
"next-themes": "^0.3.0",
"react": "^18",
"react-dom": "^18",
"react-draggable": "^4.4.6",
"react-map-gl": "^7.1.7",
"react-resizable": "^3.0.5",
"react-responsive": "^10.0.0",
"react-rnd": "^10.4.12",
"recharts": "^2.12.7",
"shadcn-ui": "^0.9.0",
Expand Down
6 changes: 0 additions & 6 deletions src/app/(demo)/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ export default function AccountPage() {
<ContentLayout title="Account">
<Breadcrumb>
<BreadcrumbList>
{/* <BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="/">Home</Link>
</BreadcrumbLink>
</BreadcrumbItem> */}
{/* <BreadcrumbSeparator /> */}
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="/dashboard">Dashboard</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ import {
BreadcrumbSeparator
} from "@/components/ui/breadcrumb";

export default function RadarPage() {
interface PluviometroProps {
params: {
pluviometroView: string[];
};
}

export default function RadarPage({ params }: PluviometroProps) {

return (
<ContentLayout title="Pluviômetros">
<PlaceholderContent />
Expand Down
20 changes: 0 additions & 20 deletions src/app/(demo)/previsao-de-chuva/1h2h3h/[1h2h3hTipo]/page.tsx

This file was deleted.

71 changes: 71 additions & 0 deletions src/app/(demo)/previsao-de-chuva/v1/[...modelView]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"use client";

import React, { useEffect, useState } from "react";
import { ModelLayout } from "@/components/admin-panel/model-layout";
import { TabsDemo } from "@/components/tabs-demo";
import { InfoButton } from "@/components/info-button";
import ModelLayer from "@/components/rionowcast-v1-map";
import ColorLabel from "@/components/color-label";
import { LineChartComponent } from "@/components/ui/line-chart";

interface ModelViewProps {
params: {
modelView: string[];
};
}

const ModelView = ({ params }: ModelViewProps) => {
const [view] = params.modelView;
const [data, setData] = useState<any>(null);
const [error, setError] = useState<string | null>(null);
const time_horizon_ = "1h";

useEffect(() => {
const fetchData = async () => {
try {
const rootUrl = process.env.NEXT_PUBLIC_ENV === 'production'
? process.env.NEXT_PUBLIC_ROOT_URL_PROD
: process.env.NEXT_PUBLIC_ROOT_URL_DEV;
const apiUrl = `${rootUrl}nowcasting_models/info/v1`;
const response = await fetch(apiUrl);
const result = await response.json();
setData(result);
} catch (error) {
console.error('Error fetching data:', error);
}
};

fetchData();
}, [view]);

if (error) {
return <div>{error}</div>;
}

const product = data?.product || {};
const values_range = data?.values_range || {};
const legend = data?.legend || { colors: [] };

if (!product || !values_range || !legend) {
return <div>Invalid data</div>;
}

const { name, unit } = product;
const valueRange = [values_range.min, values_range.max];
const stepRange = legend.colors.map((colorStop: any) => colorStop?.value);
const productLabel = legend.colors.map((colorStop: any) => ({
color: colorStop.color,
value: colorStop.value,
}));

return (
<ModelLayout title="Modelo">
<>
<ModelLayer name={name} modelView={view} time_horizon={time_horizon_} />
<ColorLabel colorStops={productLabel} unit={unit} />
</>
</ModelLayout>
);
};

export default ModelView;
20 changes: 0 additions & 20 deletions src/app/(demo)/previsao-de-chuva/xyyhzh/[xyyhzhTipo]/page.tsx

This file was deleted.

Loading

0 comments on commit 95a9d19

Please sign in to comment.