Skip to content

Commit

Permalink
Merge pull request #22 from dharamveergit/main
Browse files Browse the repository at this point in the history
fix: memo in envvarupdater
  • Loading branch information
dharamveergit authored Oct 10, 2024
2 parents 79991c5 + 2e9f0f2 commit cdf71a4
Show file tree
Hide file tree
Showing 59 changed files with 719 additions and 618 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"deployment",
"certificate",
"dx",
"config",
"stats"
]
]
Expand Down
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ apps/indexer/.env*
apps/landing/.env*
apps/provider-console/.env*
apps/provider-proxy/.env*
apps/stats-web/.env*

**/.next
*.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-stats-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.stats-web == 'true'
run: npm run dc:build -- stats-web
run: npm run dc:build -- --build-arg DEPLOYMENT_ENV=production stats-web
13 changes: 1 addition & 12 deletions apps/api/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ services:
image: <IMAGE_NAME>:<IMAGE_TAG>
depends-on: cloud-sql-proxy
env:
- GITHUB_PAT=
- AKASH_SANDBOX_DATABASE_CS=
- USER_DATABASE_CS=
- SECRET_TOKEN=
- NETWORK=<sandbox|mainnet>
- MASTER_WALLET_MNEMONIC=
- POSTGRES_DB_URI=
- ANONYMOUS_USER_TOKEN_SECRET=
- SENTRY_DSN=
- DOPPLER_TOKEN=
- SENTRY_SERVER_NAME=
- DEPLOYMENT_ENV=<staging|production>
- STRIPE_SECRET_KEY=
- STRIPE_WEBHOOK_SECRET=
expose:
- port: 3080
as: 80
Expand Down
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"lint": "eslint .",
"migrate": "node-pg-migrate",
"migration:gen": "drizzle-kit generate",
"prod": "doppler run -- node dist/server.js",
"start": "webpack --config webpack.dev.js --watch",
"test": "jest --selectProjects unit functional",
"test:cov": "jest --selectProjects unit functional --coverage",
Expand Down
1 change: 1 addition & 0 deletions apps/deploy-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@cosmjs/encoding": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@cosmos-kit/cosmos-extension-metamask": "0.10.0",
"@cosmos-kit/cosmostation-extension": "^2.12.2",
"@cosmos-kit/keplr": "^2.12.2",
"@cosmos-kit/leap": "^2.12.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,7 @@ export const DeploymentLeaseShell: React.FunctionComponent<Props> = ({ leases })
<ViewPanel stickToBottom className="overflow-hidden">
{isConnectionClosed && (
<Alert variant="warning" className="rounded-none">
The connection to your Akash Console Shell was lost. (
<Link href={UrlService.faq("shell-lost")} target="_blank" className="inline-flex items-center space-x-2">
<span>More Info</span>
<OpenNewWindow className="text-xs" alignmentBaseline="middle" />
</Link>
)
The connection to your Akash Console Shell was not established or lost.
</Alert>
)}
<XTerm ref={terminalRef} onKey={onTerminalKey} onTerminalPaste={onTerminalPaste} />
Expand Down
10 changes: 8 additions & 2 deletions apps/deploy-web/src/components/layout/WalletStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { browserEnvConfig } from "@src/config/browser-env.config";
import { useWallet } from "@src/context/WalletProvider";
import { useLoginRequiredEventHandler } from "@src/hooks/useLoginRequiredEventHandler";
import { useManagedEscrowFaqModal } from "@src/hooks/useManagedEscrowFaqModal";
import { getSplitText } from "@src/hooks/useShortText";
import { useWalletBalance } from "@src/hooks/useWalletBalance";
import { udenomToDenom } from "@src/utils/mathHelpers";
import { uaktToAKT } from "@src/utils/priceUtils";
Expand Down Expand Up @@ -104,10 +105,15 @@ export function WalletStatus() {
<Link className="ml-2 cursor-pointer leading-4" href={`https://stats.akash.network/addresses/${address}`} target="_blank">
<Tooltip>
<TooltipTrigger asChild>
<span>{walletName}</span>
{walletName?.length > 20 ? (
<span className="text-xs">{getSplitText(walletName, 4, 4)}</span>
) : (
<span className="text-xs">{walletName}</span>
)}
</TooltipTrigger>
<TooltipContent>
<Address address={address} isCopyable disableTooltip />
<div className="text-xs">{walletName}</div>
<Address address={address} isCopyable disableTooltip disableTruncate />
</TooltipContent>
</Tooltip>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, useEffect, useState } from "react";
import { Dispatch, useEffect, useMemo, useState } from "react";
import { Control, UseFormSetValue } from "react-hook-form";
import { Button, Spinner, Tabs, TabsContent, TabsList, TabsTrigger } from "@akashnetwork/ui/components";
import { Bitbucket, Github as GitIcon, GitlabFull } from "iconoir-react";
Expand Down Expand Up @@ -53,7 +53,7 @@ const RemoteRepositoryDeployManager = ({

const shouldResetValue = isRepoUrlDefault(services?.[0]?.env || []);

const envVarUpdater = new EnvVarUpdater(services);
const envVarUpdater = useMemo(() => new EnvVarUpdater(services), [services]);

const { reLoginWithGithub, loginWithGithub } = new GitHubService();

Expand Down
8 changes: 2 additions & 6 deletions apps/deploy-web/src/components/remote-deploy/Repos.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, useEffect, useState } from "react";
import { Dispatch, useEffect, useMemo, useState } from "react";
import { UseFormSetValue } from "react-hook-form";
import {
Button,
Expand Down Expand Up @@ -64,31 +64,27 @@ const Repos = ({
const [directory, setDirectory] = useState<IGithubDirectoryItem[] | null>(null);
const [open, setOpen] = useState(false);
const [accounts, setAccounts] = useState<string[]>([]);
const envVarUpdater = new EnvVarUpdater(services);
const repo = repos?.find(r => r.html_url === currentRepoUrl);
const currentFolder = currentServiceEnv?.find(e => e.key === protectedEnvironmentVariables.FRONTEND_FOLDER);

const { currentFramework, isLoading: frameworkLoading } = useRemoteDeployFramework({
currentRepoUrl,
currentBranchName,
currentGitlabProjectId: currentServiceEnv?.find(e => e.key === protectedEnvironmentVariables.GITLAB_PROJECT_ID)?.value,
subFolder: currentFolder?.value,
setCpus: (cpus: number) => setValue("services.0.profile.cpu", +cpus > 2 ? +cpus : 2)
});

const { isLoading: isGettingDirectory, isFetching: isGithubLoading } = useSrcFolders(setFolders, formatUrlWithoutInitialPath(currentRepoUrl));
const { isLoading: isGettingDirectoryBit, isFetching: isBitLoading } = useBitSrcFolders(
setFolders,
formatUrlWithoutInitialPath(currentRepoUrl),
currentBranchName
);

const { isLoading: isGettingDirectoryGitlab, isFetching: isGitlabLoading } = useGitlabSrcFolders(
setFolders,
currentServiceEnv?.find(e => e.key === protectedEnvironmentVariables.GITLAB_PROJECT_ID)?.value
);

const isLoadingDirectories = isGithubLoading || isGitlabLoading || isBitLoading || isGettingDirectory || isGettingDirectoryBit || isGettingDirectoryGitlab;
const envVarUpdater = useMemo(() => new EnvVarUpdater(services), [services]);

useEffect(() => {
if (type === "github") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useMemo, useState } from "react";
import { UseFormSetValue } from "react-hook-form";
import { Card, CardContent, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Label, Separator } from "@akashnetwork/ui/components";
import { cn } from "@akashnetwork/ui/utils";
Expand All @@ -12,7 +12,7 @@ import BoxTextInput from "../BoxTextInput";
const RemoteBuildInstallConfig = ({ services, setValue }: { services: ServiceType[]; setValue: UseFormSetValue<SdlBuilderFormValuesType> }) => {
const [expanded, setExpanded] = useState(false);
const currentService = services[0];
const envVarUpdater = new EnvVarUpdater(services);
const envVarUpdater = useMemo(() => new EnvVarUpdater(services), [services]);
return (
<Collapsible
open={expanded}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useMemo, useState } from "react";
import { useFieldArray, useForm } from "react-hook-form";
import { Checkbox, Label, Snackbar } from "@akashnetwork/ui/components";
import { useAtom } from "jotai";
Expand Down Expand Up @@ -26,9 +26,9 @@ const RemoteDeployUpdate = ({ sdlString, onManifestChange }: { sdlString: string
const [isEditingEnv, setIsEditingEnv] = useState<number | boolean | null>(false);
const { control, watch, setValue } = useForm<SdlBuilderFormValuesType>({ defaultValues: { services: [defaultService] } });
const { fields: services } = useFieldArray({ control, name: "services", keyName: "id" });
const envVarUpdater = new EnvVarUpdater(services);
const { getTemplateById } = useTemplates();
const remoteDeployTemplate = getTemplateById(CI_CD_TEMPLATE_ID);
const envVarUpdater = useMemo(() => new EnvVarUpdater(services), [services]);

useEffect(() => {
const { unsubscribe }: any = watch(data => {
Expand Down
4 changes: 2 additions & 2 deletions apps/deploy-web/src/components/settings/CertificateList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { useState, useEffect } from "react";
import { useEffect,useState } from "react";
import { FormattedDate } from "react-intl";
import { Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, CustomPagination } from "@akashnetwork/ui/components";
import { Button, CustomPagination,Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@akashnetwork/ui/components";
import { Check } from "iconoir-react";

import { ConnectWallet } from "@src/components/shared/ConnectWallet";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { useSnackbar } from "notistack";

import { RestApiCertificate } from "@src/types/certificate";
import { AnalyticsEvents } from "@src/utils/analytics";
import { ApiUrlService, loadWithPagination } from "@src/utils/apiUtils";
import { TransactionMessageData } from "@src/utils/TransactionMessageData";
import { getStorageWallets, updateWallet } from "@src/utils/walletUtils";
import { useSettings } from "../SettingsProvider";
import { useWallet } from "../WalletProvider";
import { ApiUrlService, loadWithPagination } from "@src/utils/apiUtils";

export type LocalCert = {
certPem: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "@interchain-ui/react/styles";
import "@interchain-ui/react/globalStyles";

import { GasPrice } from "@cosmjs/stargate";
import { wallets as metamask } from "@cosmos-kit/cosmos-extension-metamask";
import { wallets as cosmostation } from "@cosmos-kit/cosmostation-extension";
import { wallets as keplr } from "@cosmos-kit/keplr";
import { wallets as leap } from "@cosmos-kit/leap";
Expand All @@ -22,7 +23,7 @@ export function CustomChainProvider({ children }: Props) {
<ChainProvider
chains={[akash, akashSandbox, akashTestnet]}
assetLists={assetLists}
wallets={[...keplr, ...leap, ...cosmostation]}
wallets={[...keplr, ...leap, ...cosmostation, ...metamask]}
sessionOptions={{
duration: 31_556_926_000, // 1 year
callback: () => {
Expand Down
92 changes: 46 additions & 46 deletions apps/deploy-web/src/pages/faq/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@ import Layout from "@src/components/layout/Layout";
import { Title } from "@src/components/shared/Title";

const FaqEntries = [
{
anchor: "cpu-support",
title: "Which CPUs are officially supported?",
content: (
<>
<p>
<Link href="https://akash.network/docs/deployments/akash-cli/installation/#cpu-support" target="_blank">
Only x86_64 processors
</Link>{" "}
are officially supported for Akash deployments. This may change in the future and when ARM processors are supported it will be announced and
documented.
</p>
<p>
If you're on MacOS or linux, you can specify the{" "}
<Link
href="https://stackoverflow.com/questions/69054921/docker-on-mac-m1-gives-the-requested-images-platform-linux-amd64-does-not-m/69119815#69119815"
target="_blank"
>
target platform
</Link>{" "}
when building your docker image. For example, if you're using a Dockerfile you can use the following command:
</p>
<p>
<code>docker build -t my-image --platform linux/amd64 .</code>
</p>
</>
)
},
{
anchor: "lease-closed",
title: "My lease is closed, but the deployment isn't.",
Expand Down Expand Up @@ -34,36 +62,6 @@ const FaqEntries = [
</>
)
},
{
anchor: "shell-lost",
title: "Can't access shell: 'The connection to your Akash Console Shell was lost.'",
content: (
<>
<p>
There is a{" "}
<a href="https://github.com/akash-network/support/issues/87" target="_blank">
known issue
</a>{" "}
where the shell access will stop working if the provider pod gets restarted. Here's two workarounds you can try:
</p>
<ul className="list-disc py-4 pl-8">
<li>
You can try the "UPDATE DEPLOYMENT" button in the "UPDATE" tab of your deployment. Even without changing your SDL, this should temporarily restore
the shell access.
<br />
<Image src="/images/faq/update-deployment-btn.png" alt="Update Deployment" width={500} height={116} />
</li>
<li>
A permanent solution would be to add your own ssh access to your deployment, here is an{" "}
<Link href="https://gist.github.com/arno01/f33b7c618ecf090108a33deea38c3c10" target="_blank">
example SDL
</Link>{" "}
with ssh.
</li>
</ul>
</>
)
},
{
anchor: "shell-arrows-and-completion",
title: "Shell: UP arrow and TAB autocompletion does not work",
Expand Down Expand Up @@ -130,23 +128,25 @@ export default function FaqPage() {
<NextSeo title={`Frequently Asked Questions`} />
<Title>Frequently Asked Questions</Title>

<ul className="list-disc py-4 pl-8">
{FaqEntries.map(entry => (
<li key={entry.anchor}>
<Link href={"#" + entry.anchor}>{entry.title}</Link>
</li>
))}
</ul>
<div className="prose dark:prose-invert prose-code:before:hidden prose-code:after:hidden">
<ul className="list-disc py-4 pl-8">
{FaqEntries.map(entry => (
<li key={entry.anchor}>
<Link href={"#" + entry.anchor}>{entry.title}</Link>
</li>
))}
</ul>

<div className="pb-8">
{FaqEntries.map(entry => (
<div key={entry.anchor}>
<Title subTitle id={entry.anchor} className="my-4">
{entry.title}
</Title>
{entry.content}
</div>
))}
<div className="pb-8">
{FaqEntries.map(entry => (
<div key={entry.anchor}>
<Title subTitle id={entry.anchor} className="my-4">
{entry.title}
</Title>
{entry.content}
</div>
))}
</div>
</div>
</Layout>
);
Expand Down
1 change: 1 addition & 0 deletions apps/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dev": "npm run start",
"format": "prettier --write ./*.{js,json} **/*.{ts,js,json}",
"lint": "eslint .",
"prod": "node dist/server.js",
"start": "webpack --mode development --config webpack.dev.js --watch",
"test": "jest"
},
Expand Down
1 change: 1 addition & 0 deletions apps/stats-web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

# production
/build
env-config.schema.js

# misc
.DS_Store
Expand Down
9 changes: 9 additions & 0 deletions apps/stats-web/env/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NEXT_PUBLIC_NODE_ENV=$NODE_ENV
NEXT_PUBLIC_BASE_API_MAINNET_URL=https://console-api.akash.network
NEXT_PUBLIC_BASE_API_SANDBOX_URL=https://console-api-sandbox.akash.network
NEXT_PUBLIC_BASE_API_TESTNET_URL=https://console-api-testnet.akash.network
NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL

BASE_API_MAINNET_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL
BASE_API_TESTNET_URL=$NEXT_PUBLIC_BASE_API_TESTNET_URL
BASE_API_SANDBOX_URL=$NEXT_PUBLIC_BASE_API_SANDBOX_URL
1 change: 1 addition & 0 deletions apps/stats-web/env/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_BASE_URL=
9 changes: 9 additions & 0 deletions apps/stats-web/env/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NEXT_PUBLIC_NODE_ENV=$NODE_ENV
NEXT_PUBLIC_BASE_API_MAINNET_URL=https://console-api-mainnet-staging.akash.network
NEXT_PUBLIC_BASE_API_SANDBOX_URL=https://console-api-sandbox-staging.akash.network
NEXT_PUBLIC_BASE_API_TESTNET_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL
NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL

BASE_API_MAINNET_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL
BASE_API_TESTNET_URL=$NEXT_PUBLIC_BASE_API_TESTNET_URL
BASE_API_SANDBOX_URL=$NEXT_PUBLIC_BASE_API_SANDBOX_URL
11 changes: 11 additions & 0 deletions apps/stats-web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
require("@akashnetwork/env-loader");
const { version } = require("./package.json");

try {
const { browserEnvSchema } = require("./env-config.schema");

browserEnvSchema.parse(process.env);
} catch (error) {
if (error.message.includes("Cannot find module")) {
console.warn("No env-config.schema.js found, skipping env validation");
}
}

/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
Expand Down
Loading

0 comments on commit cdf71a4

Please sign in to comment.