Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ docker network create mono-network
# run postgres
docker run --rm -it -d --name mono-pg --network mono-network -v /tmp/data/mono/pg-data:/var/lib/postgresql/data -p 5432:5432 mono-pg:0.1-pre-release
docker run --rm -it -d --name mono-engine --network mono-network -v /tmp/data/mono/mono-data:/opt/mega -p 8000:8000 mono-engine:0.1-pre-release
docker run --rm -it -d --name mono-ui --network mono-network -e MEGA_INTERNAL_HOST=http://mono-engine:8000 -e MEGA_HOST=http://localhost:8000 -e MOON_HOST=http://localhost:3000 -p 3000:3000 mono-ui:0.1-pre-release
docker run --rm -it -d --name mono-ui --network mono-network -e MEGA_INTERNAL_HOST=http://mono-engine:8000 -e MEGA_HOST=http://localhost:8000 -p 3000:3000 mono-ui:0.1-pre-release
```

## Quick Review of Architecture
Expand Down
4 changes: 2 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ docker network create mono-network
# run postgres
docker run --rm -it -d --name mono-pg --network mono-network -v /tmp/data/mono/pg-data:/var/lib/postgresql/data -p 5432:5432 mono-pg:0.1-pre-release
docker run --rm -it -d --name mono-engine --network mono-network -v /tmp/data/mono/mono-data:/opt/mega -p 8000:8000 mono-engine:0.1-pre-release
docker run --rm -it -d --name mono-ui --network mono-network -e MEGA_INTERNAL_HOST=http://mono-engine:8000 -e MEGA_HOST=http://localhost:8000 -e MOON_HOST=http://localhost:3000 -p 3000:3000 mono-ui:0.1-pre-release
docker run --rm -it -d --name mono-ui --network mono-network -e MEGA_INTERNAL_HOST=http://mono-engine:8000 -e MEGA_HOST=http://localhost:8000 -p 3000:3000 mono-ui:0.1-pre-release
```

[3] Start whole mono engine stack on server with domain
Expand All @@ -55,7 +55,7 @@ docker network create mono-network
# run postgres
docker run --rm -it -d --name mono-pg --network mono-network -v /mnt/data/mono/pg-data:/var/lib/postgresql/data -p 5432:5432 mono-pg:0.1-pre-release
docker run --rm -it -d --name mono-engine --network mono-network -v /mnt/data/mono/mono-data:/opt/mega -p 8000:8000 -p 22:9000 mono-engine:0.1-pre-release
docker run --rm -it -d --name mono-ui --network mono-network -e MEGA_INTERNAL_HOST=http://mono-engine:8000 -e MEGA_HOST=https://git.gitmono.com -e MOON_HOST=https://console.gitmono.com -p 3000:3000 mono-ui:0.1-pre-release
docker run --rm -it -d --name mono-ui --network mono-network -e MEGA_INTERNAL_HOST=http://mono-engine:8000 -e MEGA_HOST=https://git.gitmono.com -p 3000:3000 mono-ui:0.1-pre-release
```

## Test aries engine
Expand Down
7 changes: 1 addition & 6 deletions docker/start-moon.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# user must set the MEGA_HOST,MEGA_INTERNAL_HOST and MOON_HOST
# user must set the MEGA_HOST,MEGA_INTERNAL_HOST
if [ -z "$MEGA_HOST" ]; then
echo "MEGA_HOST is not set"
exit 1
Expand All @@ -11,9 +11,4 @@ if [ -z "$MEGA_INTERNAL_HOST" ]; then
exit 1
fi

if [ -z "$MOON_HOST" ]; then
echo "MOON_HOST is not set"
exit 1
fi

exec node server.js
5 changes: 2 additions & 3 deletions moon/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
# Variables not prefixed with NEXT_PUBLIC_ are only available on the server side.


# add MEGA_HOST, MEGA_INTERNAL_HOST and MOON_HOST to your enviroment for development
# MEGA_HOST and MEGA_INTERNAL_HOST default to http://localhost:8000, MOON_HOST default to http://localhost:3000
# add MEGA_HOST, MEGA_INTERNAL_HOST to your enviroment for development
# MEGA_HOST and MEGA_INTERNAL_HOST default to http://localhost:8000
MEGA_HOST=$MEGA_HOST
MEGA_INTERNAL_HOST=$MEGA_INTERNAL_HOST
CALLBACK_URL=$MOON_HOST/auth/github/callback

SECRET_KEY=$YOUR_SECRET_KEY #(not prefixed with NEXT_PUBLIC_ )
1 change: 0 additions & 1 deletion moon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
In the root directory of your project, three environment variables are required in the `.env` file:

- **MEGA_HOST**: Used for redirecting to public backend routes during the OAuth process.
- **MOON_HOST**: Provides the callback URL to the authentication provider.
- **MEGA_INTERNAL_HOST**: Utilized for internal API requests. Given that the application uses SSR and Next.js Route Handlers, this variable allows you to specify a domain name within the container network.

### Environment Handling
Expand Down
19 changes: 0 additions & 19 deletions moon/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ const nextConfig = {
},
],
},
async redirects() {
return [
{
source: '/auth/github',
destination: process.env.MEGA_HOST + '/auth/github',
permanent: false,
},
{
source: '/auth/authorized',
destination: process.env.MEGA_HOST + '/auth/authorized',
permanent: false,
},
{
source: '/auth/logout',
destination: process.env.MEGA_HOST + '/auth/logout',
permanent: false,
}
]
},
reactStrictMode: true,
transpilePackages: [
// antd & deps
Expand Down
18 changes: 18 additions & 0 deletions moon/src/app/auth/authorized/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const revalidate = 0
export const dynamic = 'force-dynamic' // defaults to auto

import { NextRequest, NextResponse } from 'next/server';

export async function GET(request: NextRequest) {
const endpoint = process.env.MEGA_HOST;

const currentUrl = new URL(request.url);

const redirectUrl = new URL(`${endpoint}/auth/authorized`, request.url);

currentUrl.searchParams.forEach((value, key) => {
redirectUrl.searchParams.set(key, value);
});

return NextResponse.redirect(redirectUrl.toString());
}
9 changes: 9 additions & 0 deletions moon/src/app/auth/github/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { redirect } from 'next/navigation'

export const revalidate = 0
export const dynamic = 'force-dynamic' // defaults to auto

export async function GET() {
const endpoint = process.env.MEGA_HOST;
redirect(`${endpoint}/auth/github`)
}
8 changes: 8 additions & 0 deletions moon/src/app/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { redirect } from 'next/navigation'
export const revalidate = 0
export const dynamic = 'force-dynamic' // defaults to auto

export async function GET() {
const endpoint = process.env.MEGA_HOST;
redirect(`${endpoint}/auth/logout`)
}