Skip to content

Commit 02e42d9

Browse files
committed
fix: CI and various fixes
1 parent 1da7ee9 commit 02e42d9

File tree

14 files changed

+121
-79
lines changed

14 files changed

+121
-79
lines changed

Dockerfile_devnet

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
# ---- Build stage ---------
2-
FROM node:18-slim AS builder
3-
ARG VERSION
1+
FROM node:20-slim AS base
42
WORKDIR /app
53

6-
# Build arguments for configuration
7-
ARG API_URL=https://devnet-deeploy-api.ratio1.ai
8-
ARG ENVIRONMENT=devnet
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends python3 make g++ \
6+
&& rm -rf /var/lib/apt/lists/*
7+
ENV PYTHON=python3
8+
9+
ARG NEXT_PUBLIC_API_URL=https://devnet-deeploy-api.ratio1.ai
10+
ARG NEXT_PUBLIC_ENVIRONMENT=devnet
11+
ARG VERSION
912

10-
# Set environment variables for the build process
11-
ENV VITE_API_URL=${API_URL}
12-
ENV VITE_ENVIRONMENT=${ENVIRONMENT}
13+
ENV NEXT_TELEMETRY_DISABLED=1
14+
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
15+
ENV NEXT_PUBLIC_ENVIRONMENT=${NEXT_PUBLIC_ENVIRONMENT}
16+
ENV NEXT_PUBLIC_APP_VERSION=${VERSION}
1317

18+
FROM base AS deps
1419
COPY package*.json ./
1520
RUN npm ci
1621

22+
FROM base AS builder
23+
COPY package*.json ./
24+
COPY --from=deps /app/node_modules ./node_modules
1725
COPY . .
18-
ENV VITE_APP_VERSION=${VERSION}
19-
RUN npm run build # produces static files in /app/dist
20-
21-
# ---- Runtime stage ---------
22-
FROM nginx:alpine
26+
RUN npm run build
27+
RUN npm prune --omit=dev
2328

24-
COPY --from=builder /app/dist /usr/share/nginx/html
29+
FROM base AS runner
30+
ENV NODE_ENV=production
31+
ENV PORT=80
32+
ENV HOST=0.0.0.0
2533

26-
RUN sed -i '/index index\.html index\.htm;/a\ try_files \$uri \$uri/ /index.html;' \
27-
/etc/nginx/conf.d/default.conf
34+
COPY --from=builder /app/public ./public
35+
COPY --from=builder /app/.next ./.next
36+
COPY --from=builder /app/node_modules ./node_modules
37+
COPY package.json ./
2838

2939
EXPOSE 80
30-
CMD ["nginx", "-g", "daemon off;"]
40+
CMD ["npm", "run", "start"]

Dockerfile_mainnet

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
# ---- Build stage ---------
2-
FROM node:18-slim AS builder
3-
ARG VERSION
1+
FROM node:20-slim AS base
42
WORKDIR /app
53

6-
# Build arguments for configuration
7-
ARG API_URL=https://deeploy-api.ratio1.ai
8-
ARG ENVIRONMENT=mainnet
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends python3 make g++ \
6+
&& rm -rf /var/lib/apt/lists/*
7+
ENV PYTHON=python3
8+
9+
ARG NEXT_PUBLIC_API_URL=https://deeploy-api.ratio1.ai
10+
ARG NEXT_PUBLIC_ENVIRONMENT=mainnet
11+
ARG VERSION
912

10-
# Set environment variables for the build process
11-
ENV VITE_API_URL=${API_URL}
12-
ENV VITE_ENVIRONMENT=${ENVIRONMENT}
13+
ENV NEXT_TELEMETRY_DISABLED=1
14+
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
15+
ENV NEXT_PUBLIC_ENVIRONMENT=${NEXT_PUBLIC_ENVIRONMENT}
16+
ENV NEXT_PUBLIC_APP_VERSION=${VERSION}
1317

18+
FROM base AS deps
1419
COPY package*.json ./
1520
RUN npm ci
1621

22+
FROM base AS builder
23+
COPY package*.json ./
24+
COPY --from=deps /app/node_modules ./node_modules
1725
COPY . .
18-
ENV VITE_APP_VERSION=${VERSION}
19-
RUN npm run build # produces static files in /app/dist
20-
21-
# ---- Runtime stage ---------
22-
FROM nginx:alpine
26+
RUN npm run build
27+
RUN npm prune --omit=dev
2328

24-
COPY --from=builder /app/dist /usr/share/nginx/html
29+
FROM base AS runner
30+
ENV NODE_ENV=production
31+
ENV PORT=80
32+
ENV HOST=0.0.0.0
2533

26-
RUN sed -i '/index index\.html index\.htm;/a\ try_files \$uri \$uri/ /index.html;' \
27-
/etc/nginx/conf.d/default.conf
34+
COPY --from=builder /app/public ./public
35+
COPY --from=builder /app/.next ./.next
36+
COPY --from=builder /app/node_modules ./node_modules
37+
COPY package.json ./
2838

2939
EXPOSE 80
30-
CMD ["nginx", "-g", "daemon off;"]
40+
CMD ["npm", "run", "start"]

Dockerfile_testnet

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
# ---- Build stage ---------
2-
FROM node:18-slim AS builder
3-
ARG VERSION
1+
FROM node:20-slim AS base
42
WORKDIR /app
53

6-
# Build arguments for configuration
7-
ARG API_URL=https://testnet-deeploy-api.ratio1.ai
8-
ARG ENVIRONMENT=testnet
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends python3 make g++ \
6+
&& rm -rf /var/lib/apt/lists/*
7+
ENV PYTHON=python3
8+
9+
ARG NEXT_PUBLIC_API_URL=https://testnet-deeploy-api.ratio1.ai
10+
ARG NEXT_PUBLIC_ENVIRONMENT=testnet
11+
ARG VERSION
912

10-
# Set environment variables for the build process
11-
ENV VITE_API_URL=${API_URL}
12-
ENV VITE_ENVIRONMENT=${ENVIRONMENT}
13+
ENV NEXT_TELEMETRY_DISABLED=1
14+
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
15+
ENV NEXT_PUBLIC_ENVIRONMENT=${NEXT_PUBLIC_ENVIRONMENT}
16+
ENV NEXT_PUBLIC_APP_VERSION=${VERSION}
1317

18+
FROM base AS deps
1419
COPY package*.json ./
1520
RUN npm ci
1621

22+
FROM base AS builder
23+
COPY package*.json ./
24+
COPY --from=deps /app/node_modules ./node_modules
1725
COPY . .
18-
ENV VITE_APP_VERSION=${VERSION}
19-
RUN npm run build # produces static files in /app/dist
20-
21-
# ---- Runtime stage ---------
22-
FROM nginx:alpine
26+
RUN npm run build
27+
RUN npm prune --omit=dev
2328

24-
COPY --from=builder /app/dist /usr/share/nginx/html
29+
FROM base AS runner
30+
ENV NODE_ENV=production
31+
ENV PORT=80
32+
ENV HOST=0.0.0.0
2533

26-
RUN sed -i '/index index\.html index\.htm;/a\ try_files \$uri \$uri/ /index.html;' \
27-
/etc/nginx/conf.d/default.conf
34+
COPY --from=builder /app/public ./public
35+
COPY --from=builder /app/.next ./.next
36+
COPY --from=builder /app/node_modules ./node_modules
37+
COPY package.json ./
2838

2939
EXPOSE 80
30-
CMD ["nginx", "-g", "daemon off;"]
40+
CMD ["npm", "run", "start"]

app/(protected)/account/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function Account() {
1818
useEffect(() => {
1919
const tab = searchParams.get('tab');
2020
if (tab && (tab === 'invoicing' || tab === 'profile' || tab === 'burn-report')) {
21-
setSelectedTab(tab as 'invoicing' | 'profile' | 'burn-report');
21+
setSelectedTab(tab);
2222
}
2323
}, [searchParams]);
2424

app/(protected)/deeploys/dashboard/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function Dashboard() {
4242
useEffect(() => {
4343
const tab = searchParams.get('tab');
4444
if (tab && (tab === 'running' || tab === 'drafts')) {
45-
setSelectedTab(tab as 'running' | 'drafts');
45+
setSelectedTab(tab);
4646
}
4747
}, [searchParams]);
4848

app/(protected)/protected-layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export function ProtectedLayout({ children }: { children: ReactNode }) {
1515
const account = useAccount();
1616
const { address } = isUsingDevAddress ? getDevAddress() : account;
1717

18+
const isAuthenticated = isSignedIn && address !== undefined && isFetchAppsRequired !== undefined;
19+
1820
useEffect(() => {
1921
if (account.status === 'disconnected') {
2022
setFetchAppsRequired(undefined);
2123
setApps({});
2224
}
2325
}, [account.status, setApps, setFetchAppsRequired]);
2426

25-
const isAuthenticated = isSignedIn && address !== undefined && isFetchAppsRequired !== undefined;
26-
2727
useEffect(() => {
2828
if (!isAuthenticated) {
2929
router.replace('/login');

app/(public)/login/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import RestrictedAccess from '@components/auth/RestrictedAccess';
88
import { Spinner } from '@heroui/spinner';
99
import { config, environment, getDevAddress, isUsingDevAddress } from '@lib/config';
1010
import { AuthenticationContextType, useAuthenticationContext } from '@lib/contexts/authentication';
11-
import { BlockchainContextType, useBlockchainContext } from '@lib/contexts/blockchain';
1211
import { DeploymentContextType, useDeploymentContext } from '@lib/contexts/deployment';
1312
import { getAssetUrl } from '@lib/assets/getAssetUrl';
1413
import { EthAddress } from '@typedefs/blockchain';
@@ -20,7 +19,6 @@ import { useRouter } from 'next/navigation';
2019

2120
export default function Login() {
2221
const { isSignedIn } = useAuthenticationContext() as AuthenticationContextType;
23-
const { fetchLicenses } = useBlockchainContext() as BlockchainContextType;
2422
const { isFetchAppsRequired, setEscrowContractAddress } = useDeploymentContext() as DeploymentContextType;
2523

2624
const { address } = isUsingDevAddress ? getDevAddress() : useAccount();

eslint.config.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,26 @@ export default tseslint.config(
1919
},
2020
rules: {
2121
...reactHooks.configs.recommended.rules,
22-
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
22+
'react-refresh/only-export-components': [
23+
'warn',
24+
{
25+
allowConstantExport: true,
26+
allowExportNames: [
27+
'metadata',
28+
'generateMetadata',
29+
'viewport',
30+
'generateViewport',
31+
'revalidate',
32+
'fetchCache',
33+
'dynamic',
34+
'dynamicParams',
35+
'runtime',
36+
'preferredRegion',
37+
'maxDuration',
38+
'generateStaticParams',
39+
],
40+
},
41+
],
2342
'react-hooks/rules-of-hooks': 'off',
2443
'react-hooks/exhaustive-deps': 'off',
2544
'no-unused-vars': 'off',

next.config.mjs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
33
reactStrictMode: true,
4-
env: {
5-
VITE_API_URL: process.env.VITE_API_URL,
6-
VITE_ENVIRONMENT: process.env.VITE_ENVIRONMENT,
7-
VITE_DEV_ADDRESS: process.env.VITE_DEV_ADDRESS,
8-
VITE_APP_VERSION: process.env.VITE_APP_VERSION,
9-
},
104
serverExternalPackages: ['pino', 'pino-pretty', 'thread-stream'],
115
};
126

src/lib/api/backend.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { config } from '@lib/config';
22
import { InvoiceDraft, PublicProfileInfo } from '@typedefs/general';
33
import axios from 'axios';
4-
import * as types from 'typedefs/blockchain';
4+
import * as types from '@typedefs/blockchain';
55

66
// Ratio1 dApp API
77
const backendUrl = config.backendUrl;
@@ -88,10 +88,7 @@ export const downloadBurnReportCSV = async (start: string, end: string) => {
8888
};
8989

9090
export const downloadBurnReportJSON = async (start: string, end: string) =>
91-
downloadJsonFile(
92-
`/burn-report/download-burn-report-json?startTime=${start}&endTime=${end}`,
93-
'burn_report.json',
94-
);
91+
downloadJsonFile(`/burn-report/download-burn-report-json?startTime=${start}&endTime=${end}`, 'burn_report.json');
9592

9693
export const getBrandingPlatforms = async () => _doGet<string[]>('/branding/get-platforms');
9794

0 commit comments

Comments
 (0)