Skip to content

Commit

Permalink
fix(deploy): fix oss external endpoint config format
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Sep 13, 2022
1 parent 989ca02 commit 543fe9a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
10 changes: 5 additions & 5 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 @@ -62,12 +62,12 @@ services:
ACCOUNT_DEFAULT_APP_QUOTA: 5
ACCOUNT_SIGNUP_MODE: 0
APP_SERVICE_IMAGE: lafyun/app-service:latest
APP_SERVICE_DEPLOY_HOST: 127-0-0-1.nip.io:8080 # `*.127-0-0-1.nip.io` always resolved to 127.0.0.1, used to local development
APP_SERVICE_DEPLOY_HOST: 127-0-0-1.nip.io # `*.127-0-0-1.nip.io` always resolved to 127.0.0.1, used to local development
APP_SERVICE_DEPLOY_URL_SCHEMA: 'http'
MINIO_ACCESS_KEY: minio-root-user
MINIO_ACCESS_SECRET: minio-root-password
MINIO_INTERNAL_ENDPOINT: http://oss:9000
MINIO_EXTERNAL_ENDPOINT: oss.127-0-0-1.nip.io
MINIO_EXTERNAL_ENDPOINT: http://oss.127-0-0-1.nip.io:${PUBLISH_PORT:-8080}
PUBLISH_PORT: ${PUBLISH_PORT:-8080}
PUBLISH_HTTPS_PORT: ${PUBLISH_HTTPS_PORT:-9443}
MINIO_REGION_NAME: cn-default
Expand Down Expand Up @@ -102,7 +102,7 @@ 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: http://oss.127-0-0-1.nip.io:${PUBLISH_PORT:-8080}
PUBLISH_PORT: ${PUBLISH_PORT:-8080}
PUBLISH_HTTPS_PORT: ${PUBLISH_HTTPS_PORT:-9443}
MINIO_REGION_NAME: cn-default
Expand Down
17 changes: 12 additions & 5 deletions packages/instance-controller/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,22 @@ 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_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 external_endpoint: string = new URL(process.env.MINIO_EXTERNAL_ENDPOINT).origin

// fixed external_endpoint with extra schema and port config
const external_port = process.env.APP_SERVICE_DEPLOY_URL_SCHEMA === 'http' ? process.env.PUBLISH_PORT : process.env.PUBLISH_HTTPS_PORT
const obj = new URL(external_endpoint)
obj.port = external_port || obj.port
obj.protocol = process.env.APP_SERVICE_DEPLOY_URL_SCHEMA || 'http'
const fixed_external_endpoint = obj.toString()

console.log({fixed_external_endpoint}, obj)
const region: string = process.env.MINIO_REGION_NAME

return {
endpoint: {
internal: internal_endpoint,
external: external_endpoint
internal: internal_endpoint.replace(/\/$/, ''),
external: fixed_external_endpoint.replace(/\/$/, '')
},
user_policy: process.env.MINIO_USER_POLICY || 'owner_by_prefix',
region
Expand Down
14 changes: 10 additions & 4 deletions packages/system-server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,23 @@ 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

// fixed external_endpoint with extra schema and port config
const external_port = process.env.APP_SERVICE_DEPLOY_URL_SCHEMA === 'http' ? process.env.PUBLISH_PORT : process.env.PUBLISH_HTTPS_PORT
const obj = new URL(external_endpoint)
obj.port = external_port || obj.port
obj.protocol = process.env.APP_SERVICE_DEPLOY_URL_SCHEMA
const fixed_external_endpoint = obj.toString()

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 {
access_key,
access_secret,
endpoint: {
internal: internal_endpoint,
external: external_endpoint
internal: internal_endpoint.replace(/\/$/, ''),
external: fixed_external_endpoint.replace(/\/$/, '')
},
user_policy: process.env.MINIO_USER_POLICY || 'owner_by_prefix',
region
Expand Down

0 comments on commit 543fe9a

Please sign in to comment.