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 56672d9
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 105 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
91 changes: 65 additions & 26 deletions ee/apps/platform/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,76 @@
import { withSentryConfig } from "@sentry/nextjs";
import path from "path";
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/** @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, { isServer }) => {
config.resolve.fallback = { fs: false, net: false, tls: false };
config.externals.push("pino-pretty", "encoding");

// Add module resolution aliases
// config.resolve.alias = {
// ...config.resolve.alias,
// "@karrio/console": path.resolve(__dirname, "../../platform/packages/console/src")
// };

// // Add module directories
// config.resolve.modules = [
// path.resolve(__dirname, "../../platform/packages"),
// "node_modules",
// ...config.resolve.modules || []
// ];

return config;
},
experimental: {
swcMinify: false,
esmExternals: true
},
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

silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
// 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.
};

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": "*"
}
}
}
40 changes: 40 additions & 0 deletions ee/apps/platform/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

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

# Configure git to use HTTPS instead of SSH
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/"

# Configure npm for GitHub packages
echo "//npm.pkg.github.com/:_authToken=${GIT_CREDENTIALS}" >~/.npmrc
echo "@karrio:registry=https://npm.pkg.github.com/" >>~/.npmrc
echo "always-auth=true" >>~/.npmrc
echo "legacy-peer-deps=true" >>~/.npmrc

# Navigate to root and clean submodules
cd ../../../
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

# Debug: Print directory structure
echo "Current directory structure:"
ls -la
ls -la ee/platform/packages/console/src/modules/Organizations

# Install dependencies using workspace resolution
npm install -w @karrio/platform

# Generate Prisma client
cd ee/platform/packages/console
npx prisma generate

# Build the platform app using Turbo
cd ../../../apps/platform
export NEXT_TELEMETRY_DISABLED=1
npm run build --no-cache
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"
]
}
2 changes: 1 addition & 1 deletion ee/platform
Loading

0 comments on commit 56672d9

Please sign in to comment.