chore: env
This commit is contained in:
parent
c410c188a3
commit
5164f85484
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM node:12.20.0-stretch
|
||||
|
||||
WORKDIR /app
|
||||
# COPY . /app
|
||||
RUN ls -a
|
||||
|
||||
RUN npm config set registry https://registry.npm.taobao.org
|
||||
RUN yarn config set registry https://registry.npm.taobao.org
|
||||
|
||||
# RUN npm install
|
||||
# RUN npm run bootstrap
|
||||
# RUN npm run build
|
||||
|
||||
# # Install app dependencies
|
||||
# ENV NPM_CONFIG_LOGLEVEL warn
|
||||
# RUN yarn install
|
||||
|
||||
# # Show current folder structure in logs
|
||||
RUN ls -a
|
||||
|
||||
# CMD [ "npm", "run", "serve" ]
|
39
docker-compose.yml
Normal file
39
docker-compose.yml
Normal file
@ -0,0 +1,39 @@
|
||||
version: "3"
|
||||
networks:
|
||||
nocobase:
|
||||
driver: bridge
|
||||
services:
|
||||
adminer:
|
||||
image: adminer
|
||||
restart: always
|
||||
networks:
|
||||
- nocobase
|
||||
ports:
|
||||
- ${ADMINER_PORT}:8080
|
||||
postgres:
|
||||
image: postgres:10
|
||||
restart: always
|
||||
ports:
|
||||
- "${DB_POSTGRES_PORT}:5432"
|
||||
networks:
|
||||
- nocobase
|
||||
command: postgres -c wal_level=logical
|
||||
environment:
|
||||
POSTGRES_USER: ${DB_USER}
|
||||
POSTGRES_DB: ${DB_DATABASE}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
nocobase:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
networks:
|
||||
- nocobase
|
||||
command: [ "yarn", "start" ]
|
||||
working_dir: /app
|
||||
env_file: ./.env
|
||||
volumes:
|
||||
- ./:/app
|
||||
expose:
|
||||
- 8000
|
||||
ports:
|
||||
- "${APP_PORT}:8000"
|
@ -65,8 +65,6 @@ if (process.argv.length < 3) {
|
||||
process.argv.push('start', '--port', process.env.API_PORT || 12302);
|
||||
}
|
||||
|
||||
console.log(process.argv);
|
||||
|
||||
api.parse(process.argv).then(() => {
|
||||
console.log(`${new Date().toLocaleTimeString()} Start-up time: ${(Date.now() - start) / 1000}s`);
|
||||
});
|
||||
|
@ -1,9 +1,25 @@
|
||||
import dotenv from 'dotenv';
|
||||
import { resolve } from 'path';
|
||||
import { defineConfig } from 'umi';
|
||||
import { getUmiConfig } from '../utils/src/umiConfig';
|
||||
|
||||
dotenv.config({
|
||||
path: resolve(__dirname, '../../.env'),
|
||||
});
|
||||
|
||||
process.env.MFSU_AD = 'none';
|
||||
|
||||
const umiConfig = getUmiConfig();
|
||||
|
||||
export default defineConfig({
|
||||
define: {
|
||||
...umiConfig.define,
|
||||
},
|
||||
// only proxy when using `umi dev`
|
||||
// if the assets are built, will not proxy
|
||||
proxy: {
|
||||
...umiConfig.proxy,
|
||||
},
|
||||
nodeModulesTransform: {
|
||||
type: 'none',
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { APIClient } from '@nocobase/client';
|
||||
|
||||
const apiClient = new APIClient({
|
||||
baseURL: `http://localhost:3000/api/`,
|
||||
baseURL: process.env.API_BASE_URL,
|
||||
});
|
||||
|
||||
export default apiClient;
|
||||
|
@ -1,5 +1,7 @@
|
||||
export * from './merge';
|
||||
export * from './mixin';
|
||||
export * from './mixin/AsyncEmitter';
|
||||
export * from './uid';
|
||||
export * from './registry';
|
||||
export * from './uid';
|
||||
export * from './umiConfig';
|
||||
|
||||
|
36
packages/utils/src/umiConfig.ts
Normal file
36
packages/utils/src/umiConfig.ts
Normal file
@ -0,0 +1,36 @@
|
||||
export function getUmiConfig() {
|
||||
const { API_PORT, API_BASE_URL } = process.env;
|
||||
const API_BASE_PATH = process.env.API_BASE_PATH || '/api/';
|
||||
const PROXY_TARGET_URL = process.env.PROXY_TARGET_URL || `http://127.0.0.1:${API_PORT}`;
|
||||
const LOCAL_STORAGE_BASE_URL = process.env.LOCAL_STORAGE_BASE_URL || '/uploads';
|
||||
|
||||
function getLocalStorageProxy() {
|
||||
if (LOCAL_STORAGE_BASE_URL.startsWith('http')) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
[LOCAL_STORAGE_BASE_URL]: {
|
||||
target: PROXY_TARGET_URL,
|
||||
changeOrigin: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
define: {
|
||||
'process.env.API_BASE_URL': API_BASE_URL || API_BASE_PATH,
|
||||
},
|
||||
// only proxy when using `umi dev`
|
||||
// if the assets are built, will not proxy
|
||||
proxy: {
|
||||
[API_BASE_PATH]: {
|
||||
target: PROXY_TARGET_URL,
|
||||
changeOrigin: true,
|
||||
pathRewrite: { [`^${API_BASE_PATH}`]: API_BASE_PATH },
|
||||
},
|
||||
// for local storage
|
||||
...getLocalStorageProxy(),
|
||||
},
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user