Skip to content

Commit

Permalink
chore: setup platform deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 committed Jan 26, 2025
1 parent 3a162a6 commit 6215f71
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 34 deletions.
4 changes: 4 additions & 0 deletions ee/apps/platform/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//npm.pkg.github.com/:_authToken=${GIT_CREDENTIALS}
@karrio:registry=https://npm.pkg.github.com/
always-auth=true
legacy-peer-deps=true
71 changes: 46 additions & 25 deletions ee/apps/platform/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,56 @@ import path from "path";

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: [
"@karrio/core",
"@karrio/hooks",
"@karrio/ui",
"@karrio/lib",
"@karrio/types",
"@karrio/insiders",
"@karrio/console",
],
sentry: {
disableServerWebpackPlugin: true,
disableClientWebpackPlugin: true,
},
sassOptions: {
includePaths: [path.join("src", "app", "styles")],
},
reactStrictMode: true,
transpilePackages: [
"@karrio/core",
"@karrio/hooks",
"@karrio/ui",
"@karrio/lib",
"@karrio/types",
"@karrio/insiders",
"@karrio/console"
],
sentry: {
disableServerWebpackPlugin: true,
disableClientWebpackPlugin: true,
},
sassOptions: {
includePaths: [path.join("src", "app", "styles")],
},
webpack: (config) => {
config.resolve.fallback = { fs: false, net: false, tls: false };
config.externals.push("pino-pretty", "encoding");
config.resolve.alias = {
...config.resolve.alias,
"@karrio/console": path.resolve(__dirname, "../../platform/packages/console")
};
return config;
},
images: {
unoptimized: true
},
pageExtensions: ['js', 'jsx', 'ts', 'tsx'],
typescript: {
ignoreBuildErrors: true
},
eslint: {
ignoreDuringBuilds: true
},
distDir: '.next',
cleanDistDir: true
};

const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore

silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};

export default withSentryConfig(nextConfig, sentryWebpackPluginOptions);
2 changes: 1 addition & 1 deletion ee/apps/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"eslint-config-next": "14.2.8",
"tsconfig": "*"
}
}
}
45 changes: 45 additions & 0 deletions ee/apps/platform/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -e # Exit on error
set -x # Print commands for debugging

# Configure git to use HTTPS instead of SSH
git config --global credential.helper store
echo "https://${GIT_CREDENTIALS}:[email protected]" >~/.git-credentials
git config --global url."https://${GIT_CREDENTIALS}@github.com/".insteadOf "[email protected]:"
git config --global url."https://${GIT_CREDENTIALS}@github.com/karrioapi/".insteadOf "[email protected]:karrioapi/"

# Clean and reinitialize submodules
cd /vercel/path0

# Update submodule URLs to use HTTPS with token
git config --file=.gitmodules submodule.ee/insiders.url "https://${GIT_CREDENTIALS}@github.com/karrioapi/karrio-insiders.git"
git config --file=.gitmodules submodule.ee/platform.url "https://${GIT_CREDENTIALS}@github.com/karrioapi/karrio-platform.git"

rm -rf ee/insiders ee/platform
git clean -ffdx
git reset --hard HEAD
git submodule deinit -f .
git submodule sync --recursive
git submodule update --init --recursive --force

# Install root dependencies
npm install --no-workspaces

# Install and generate Prisma client
cd ee/platform/packages/console
npm install --no-workspaces
npx prisma generate

# Back to platform app and install its dependencies
cd ../../../apps/platform
npm install --no-workspaces --legacy-peer-deps

# Disable telemetry
export NEXT_TELEMETRY_DISABLED=1

# Install SWC dependencies
npm install --no-save @next/swc-linux-x64-gnu @next/swc-linux-x64-musl

# Build the application
npm run build
1 change: 0 additions & 1 deletion ee/apps/platform/src/app/(error)/404/page.tsx

This file was deleted.

1 change: 0 additions & 1 deletion ee/apps/platform/src/app/(error)/500/page.tsx

This file was deleted.

17 changes: 17 additions & 0 deletions ee/apps/platform/src/app/(landing)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client';

import dynamic from 'next/dynamic';
import { Suspense } from 'react';

const LandingLayout = dynamic(() => import("@karrio/console/layouts/root-layout"), {
ssr: false,
loading: () => <div>Loading...</div>
});

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<Suspense fallback={<div>Loading...</div>}>
<LandingLayout>{children}</LandingLayout>
</Suspense>
);
}
18 changes: 17 additions & 1 deletion ee/apps/platform/src/app/(landing)/page.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
export { default } from "@karrio/console/modules/Landing";
'use client';

import dynamic from 'next/dynamic';
import { Suspense } from 'react';

const LandingPage = dynamic(() => import("@karrio/console/modules/Landing"), {
ssr: false,
loading: () => <div>Loading...</div>
});

export default function Page() {
return (
<Suspense fallback={<div>Loading...</div>}>
<LandingPage />
</Suspense>
);
}
19 changes: 17 additions & 2 deletions ee/apps/platform/src/app/error.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
"use client";
export { default } from "@karrio/core/components/error";
"use client";

import dynamic from 'next/dynamic';
import { Suspense } from 'react';

const ErrorPage = dynamic(() => import("@karrio/console/modules/Error/500"), {
ssr: false,
loading: () => <div>Loading...</div>
});

export default function Error() {
return (
<Suspense fallback={<div>Loading...</div>}>
<ErrorPage />
</Suspense>
);
}
17 changes: 16 additions & 1 deletion ee/apps/platform/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
import "../styles/globals.css";
export { default } from "@karrio/console/layouts/root-layout";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "Karrio Platform",
description: "Karrio Platform",
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
}
18 changes: 17 additions & 1 deletion ee/apps/platform/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
export { default } from "@karrio/console/modules/Maintainance";
'use client';

import dynamic from 'next/dynamic';
import { Suspense } from 'react';

const NotFound = dynamic(() => import("@karrio/console/modules/Error/404"), {
ssr: false,
loading: () => <div>Loading...</div>
});

export default function Page() {
return (
<Suspense fallback={<div>Loading...</div>}>
<NotFound />
</Suspense>
);
}
15 changes: 14 additions & 1 deletion ee/apps/platform/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
export { default } from "@karrio/console/modules/Landing";
import { lazy } from 'react';

const LandingPage = lazy(() => import("@karrio/console/modules/Landing"));

export const dynamic = 'force-dynamic';
export const revalidate = 0;

export default function Page() {
return (
<div>
<LandingPage />
</div>
);
}
15 changes: 15 additions & 0 deletions ee/apps/platform/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"buildCommand": "chmod +x scripts/build.sh && ./scripts/build.sh",
"outputDirectory": ".next",
"framework": "nextjs",
"git": {
"submodules": true,
"deploymentEnabled": {
"paas-foundation": true
}
},
"installCommand": "npm install",
"regions": [
"iad1"
]
}

0 comments on commit 6215f71

Please sign in to comment.