diff --git a/deploy/docker-compose/.env b/deploy/docker-compose/.env index 79ba4d9d83..5adc762244 100644 --- a/deploy/docker-compose/.env +++ b/deploy/docker-compose/.env @@ -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 diff --git a/deploy/docker-compose/docker-compose.yml b/deploy/docker-compose/docker-compose.yml index d73f3b110f..11f9cf83f9 100644 --- a/deploy/docker-compose/docker-compose.yml +++ b/deploy/docker-compose/docker-compose.yml @@ -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 @@ -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} @@ -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 @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 1950495632..a0b3691eee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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 @@ -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' diff --git a/gateway_dashboard_conf.yaml b/gateway_dashboard_conf.yaml index efabc89db3..f07888e46e 100644 --- a/gateway_dashboard_conf.yaml +++ b/gateway_dashboard_conf.yaml @@ -101,4 +101,4 @@ plugins: # plugin list (sorted in alphabetical order) - wolf-rbac - zipkin - server-info - - traffic-split \ No newline at end of file + - traffic-split diff --git a/packages/instance-controller/src/config.ts b/packages/instance-controller/src/config.ts index 449957dd20..2b154bb3e4 100644 --- a/packages/instance-controller/src/config.ts +++ b/packages/instance-controller/src/config.ts @@ -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 { @@ -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 { diff --git a/packages/system-server/src/config.ts b/packages/system-server/src/config.ts index c325dd97f1..ff61be2b21 100644 --- a/packages/system-server/src/config.ts +++ b/packages/system-server/src/config.ts @@ -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`. @@ -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 { diff --git a/packages/system-server/src/handler/application/get.ts b/packages/system-server/src/handler/application/get.ts index d3f59c8c05..2940279a4e 100644 --- a/packages/system-server/src/handler/application/get.ts +++ b/packages/system-server/src/handler/application/get.ts @@ -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