Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: opt schema and port config #267

Merged
merged 1 commit into from
Aug 14, 2022
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: 2 additions & 0 deletions deploy/docker-compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ SYS_SERVER_SECRET_SALT=system-server-abcdefg1234567

# exposed port of laf services
PUBLISH_PORT=8000
PUBLISH_HTTPS_PORT=9443

APP_SERVICE_DEPLOY_URL_SCHEMA=http

# `*.127-0-0-1.nip.io` always resolved to 127.0.0.1, just for local development
Expand Down
15 changes: 10 additions & 5 deletions deploy/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '3.8'
services:
mongo:
# image: bitnami/mongodb:5.0.8
image: bitnami/mongodb:4.4.13 # Use this version for Apple M1 Chip
image: bitnami/mongodb:5.0.8
# image: bitnami/mongodb:4.4.13 # Use this version for Apple M1 Chip
environment:
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_ADVERTISED_HOSTNAME=mongo
Expand Down Expand Up @@ -65,12 +65,14 @@ services:
APP_SERVICE_IMAGE: ${APP_SERVICE_IMAGE:-lafyun/app-service:latest}
ACCOUNT_DEFAULT_APP_QUOTA: ${ACCOUNT_DEFAULT_APP_QUOTA:-2}
ACCOUNT_SIGNUP_MODE: ${ACCOUNT_SIGNUP_MODE:-0}
APP_SERVICE_DEPLOY_HOST: ${DEPLOY_DOMAIN:?err}:${PUBLISH_PORT:-8080}
APP_SERVICE_DEPLOY_HOST: ${DEPLOY_DOMAIN:?err}
APP_SERVICE_DEPLOY_URL_SCHEMA: ${APP_SERVICE_DEPLOY_URL_SCHEMA}
MINIO_ACCESS_KEY: ${MINIO_ROOT_USER}
MINIO_ACCESS_SECRET: ${MINIO_ROOT_PASSWORD}
MINIO_INTERNAL_ENDPOINT: http://oss:9000
MINIO_EXTERNAL_ENDPOINT: http://${OSS_DOMAIN}:${PUBLISH_PORT:-8080}
MINIO_EXTERNAL_ENDPOINT: ${OSS_DOMAIN}
PUBLISH_PORT: ${PUBLISH_PORT:-8080}
PUBLISH_HTTPS_PORT: ${PUBLISH_HTTPS_PORT:-9443}
MINIO_REGION_NAME: cn-default
INIT_ROOT_ACCOUNT: ${INIT_ROOT_ACCOUNT}
INIT_ROOT_ACCOUNT_PASSWORD: ${INIT_ROOT_ACCOUNT_PASSWORD:?err}
Expand Down Expand Up @@ -102,6 +104,7 @@ services:
- ./gateway_conf.yaml:/usr/local/apisix/conf/config.yaml:ro
ports:
- ${PUBLISH_PORT:-8080}:9080
- ${PUBLISH_HTTPS_PORT:-9443}:9443
networks:
- laf_shared_network

Expand Down Expand Up @@ -147,7 +150,9 @@ services:
SERVICE_DRIVER: docker
APP_SERVICE_ENV_NPM_INSTALL_FLAGS: ' --no-audit --no-fund'
MINIO_INTERNAL_ENDPOINT: http://oss:9000
MINIO_EXTERNAL_ENDPOINT: http://${OSS_DOMAIN}:${PUBLISH_PORT:-8080}
MINIO_EXTERNAL_ENDPOINT: ${OSS_DOMAIN}
PUBLISH_PORT: ${PUBLISH_PORT:-8080}
PUBLISH_HTTPS_PORT: ${PUBLISH_HTTPS_PORT:-9443}
MINIO_REGION_NAME: cn-default
SYSTEM_EXTENSION_APPID: ${SYSTEM_EXTENSION_APPID}
command: node ./dist/index.js
Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
version: '3.8'
services:
mongo:
# image: bitnami/mongodb:5.0.8
image: bitnami/mongodb:4.4.13 # Use this version for Apple M1 Chip
image: bitnami/mongodb:5.0.8
# image: bitnami/mongodb:4.4.13 # Use this version for Apple M1 Chip
environment:
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_ADVERTISED_HOSTNAME=mongo
Expand Down Expand Up @@ -69,7 +69,9 @@ services:
MINIO_ACCESS_KEY: minio-root-user
MINIO_ACCESS_SECRET: minio-root-password
MINIO_INTERNAL_ENDPOINT: http://oss:9000
MINIO_EXTERNAL_ENDPOINT: http://oss.127-0-0-1.nip.io:8080
MINIO_EXTERNAL_ENDPOINT: oss.127-0-0-1.nip.io
PUBLISH_PORT: ${PUBLISH_PORT:-8080}
PUBLISH_HTTPS_PORT: ${PUBLISH_HTTPS_PORT:-9443}
MINIO_REGION_NAME: cn-default
INIT_ROOT_ACCOUNT_PASSWORD: abc123
INIT_ROOT_ACCOUNT: root
Expand Down Expand Up @@ -102,7 +104,9 @@ services:
SERVICE_DRIVER: docker
APP_SERVICE_ENV_NPM_INSTALL_FLAGS: ' --no-audit --no-fund'
MINIO_INTERNAL_ENDPOINT: http://oss:9000
MINIO_EXTERNAL_ENDPOINT: http://oss.127-0-0-1.nip.io:8080
MINIO_EXTERNAL_ENDPOINT: oss.laf.windup.top
PUBLISH_PORT: ${PUBLISH_PORT:-8080}
PUBLISH_HTTPS_PORT: ${PUBLISH_HTTPS_PORT:-9443}
MINIO_REGION_NAME: cn-default
DEBUG_BIND_HOST_APP_PATH: '${PWD}/packages/app-service'
SYSTEM_EXTENSION_APPID: '000000'
Expand Down
2 changes: 1 addition & 1 deletion gateway_dashboard_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ plugins: # plugin list (sorted in alphabetical order)
- wolf-rbac
- zipkin
- server-info
- traffic-split
- traffic-split
6 changes: 4 additions & 2 deletions packages/instance-controller/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Config {

/**
* DEBUG: the app-service path that bind to app-service container
* This env var should only be set while debugging app service,
* This env var should only be set while debugging app service,
* otherwise always keep this env var value be empty
*/
static get DEBUG_BIND_HOST_APP_PATH(): string | undefined {
Expand Down Expand Up @@ -100,7 +100,9 @@ export default class Config {
// use URL().origin to get the pure hostname, because the hostname may contain port number
// this is to resolve bug of https://github.com/labring/laf/issues/96
const internal_endpoint: string = new URL(process.env.MINIO_INTERNAL_ENDPOINT).origin
const external_endpoint: string = new URL(process.env.MINIO_EXTERNAL_ENDPOINT).origin

const external_port = process.env.APP_SERVICE_DEPLOY_URL_SCHEMA === 'http' ? process.env.PUBLISH_PORT : process.env.PUBLISH_HTTPS_PORT
const external_endpoint: string = new URL(process.env.APP_SERVICE_DEPLOY_URL_SCHEMA + '://' + process.env.MINIO_EXTERNAL_ENDPOINT + ':' + external_port).origin
const region: string = process.env.MINIO_REGION_NAME

return {
Expand Down
20 changes: 16 additions & 4 deletions packages/system-server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,28 @@ export default class Config {

/**
* The host to access the app service
* For example, if set this to `lafyun.com`, then you can access app service by format `[appid].lafyun.com`:
* For example, if set this to `lafyun.com`, then you can access app service by format `[appid].lafyun.com`:
* - 7b0b318c-b96c-4cc5-b521-33d11bd16cde.lafyun.com
* - http://7b0b318c-b96c-4cc5-b521-33d11bd16cde.lafyun.com/file/public/33d11bd16cde.png
* - http://7b0b318c-b96c-4cc5-b521-33d11bd16cde.lafyun.com/FUNC_NAME
*
*
* You should resolve `*.lafyun.com` to your laf server ip, to support `[appid].lafyun.com` url.
* You can also provide the PORT, like `lafyun.com:8080`.
* You can also provide the PORT, like `lafyun.com:8080`.
*/
static get APP_SERVICE_DEPLOY_HOST(): string {
return process.env.APP_SERVICE_DEPLOY_HOST ?? ''
}



static get PUBLISH_PORT(): string {
return process.env.PUBLISH_PORT ?? ''
}

static get PUBLISH_HTTPS_PORT(): string {
return process.env.PUBLISH_HTTPS_PORT ?? ''
}

/**
* The schema of app deployed url: `http` | `https`.
* Default value is `http`.
Expand All @@ -131,7 +141,9 @@ export default class Config {
// use URL().origin to get the pure hostname, because the hostname may contain port number
// this is to resolve bug of https://github.com/labring/laf/issues/96
const internal_endpoint: string = new URL(process.env.MINIO_INTERNAL_ENDPOINT).origin
const external_endpoint: string = new URL(process.env.MINIO_EXTERNAL_ENDPOINT).origin

const external_port = process.env.APP_SERVICE_DEPLOY_URL_SCHEMA === 'http' ? process.env.PUBLISH_PORT : process.env.PUBLISH_HTTPS_PORT
const external_endpoint: string = new URL(process.env.APP_SERVICE_DEPLOY_URL_SCHEMA + '://' + process.env.MINIO_EXTERNAL_ENDPOINT + ':' + external_port).origin
const region: string = process.env.MINIO_REGION_NAME

return {
Expand Down
4 changes: 3 additions & 1 deletion packages/system-server/src/handler/application/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export async function handleGetApplicationByAppid(req: Request, res: Response) {
debug_token = getToken({ appid, type: 'debug', exp }, app.config.server_secret_salt)
}

const app_deploy_host = Config.APP_SERVICE_DEPLOY_HOST
let export_port = Config.APP_SERVICE_DEPLOY_URL_SCHEMA === 'http' ? Config.PUBLISH_PORT : Config.PUBLISH_HTTPS_PORT

const app_deploy_host = Config.APP_SERVICE_DEPLOY_HOST + ':' + export_port
const app_deploy_url_schema = Config.APP_SERVICE_DEPLOY_URL_SCHEMA
const oss_external_endpoint = Config.MINIO_CONFIG.endpoint.external
const oss_internal_endpoint = Config.MINIO_CONFIG.endpoint.internal
Expand Down