feat: improve nocobase app template

This commit is contained in:
chenos 2021-10-07 17:24:31 +08:00
parent f825e48d03
commit 23f4ec2681
6 changed files with 120 additions and 17 deletions

View File

@ -0,0 +1,44 @@
########## DOCKER COMPOSE ENV ##########
DB_POSTGRES_PORT=15432
APP_PORT=13000
ADMINER_PORT=18080
########## NOCOBASE ENV ##########
# DATABASE
DB_DIALECT=postgres
DB_DATABASE=nocobase
DB_USER=nocobase
DB_PASSWORD=nocobase
# set to 'on' to enable log
DB_LOG_SQL=
# for localhost
DB_PORT=15432
DB_HOST=localhost
# for docker
# DB_PORT=5432
# DB_HOST=postgres
# API & APP
NOCOBASE_ENV=
API_PORT=13001
API_URL=/api/
# ADMIN USER (Initialization only)
ADMIN_EMAIL=admin@nocobase.com
ADMIN_PASSWORD=admin
# STORAGE (Initialization only)
# local or ali-oss
STORAGE_TYPE=local
# LOCAL STORAGE
LOCAL_STORAGE_USE_STATIC_SERVER=true
LOCAL_STORAGE_BASE_URL=http://localhost:23000

View File

@ -17,4 +17,4 @@
/src/.umi
/src/.umi-production
/src/.umi-test
/.env.local
/.env.local

View File

@ -3,7 +3,7 @@ import dotenv from 'dotenv';
import path from 'path';
dotenv.config({
path: path.resolve(__dirname, '../../.env'),
path: path.resolve(__dirname, './.env'),
});
export default defineConfig({

View 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" ]

View File

@ -0,0 +1,37 @@
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-server", "start", "--port", "8000" ]
working_dir: /app
env_file: ./.env
volumes:
- ./:/app
ports:
- "${APP_PORT}:8000"

View File

@ -1,10 +1,11 @@
{
"name": "root",
"name": "nocobase-app",
"private": true,
"scripts": {
"start": "concurrently \"npm run start-server\" \"umi dev\"",
"start-client": "umi dev",
"start-server": "ts-node-dev -r dotenv/config --project tsconfig.apis.json ./src/apis/index.ts",
"nocobase": "ts-node-dev -r dotenv/config --project tsconfig.apis.json ./src/apis/index.ts",
"build": "npm run build-server && npm run build-client",
"build-client": "umi build",
"build-server": "rimraf -rf lib && tsc --project tsconfig.apis.json",
@ -25,22 +26,22 @@
]
},
"dependencies": {
"@nocobase/plugin-action-logs": "^0.5.0-alpha.5",
"@nocobase/plugin-china-region": "^0.5.0-alpha.5",
"@nocobase/plugin-client": "^0.5.0-alpha.5",
"@nocobase/plugin-collections": "^0.5.0-alpha.5",
"@nocobase/plugin-export": "^0.5.0-alpha.5",
"@nocobase/plugin-file-manager": "^0.5.0-alpha.5",
"@nocobase/plugin-multi-apps": "^0.5.0-alpha.5",
"@nocobase/plugin-permissions": "^0.5.0-alpha.5",
"@nocobase/plugin-system-settings": "^0.5.0-alpha.5",
"@nocobase/plugin-ui-router": "^0.5.0-alpha.5",
"@nocobase/plugin-ui-schema": "^0.5.0-alpha.5",
"@nocobase/plugin-users": "^0.5.0-alpha.5",
"@nocobase/server": "^0.5.0-alpha.5"
"@nocobase/plugin-action-logs": "^{{{ version }}}",
"@nocobase/plugin-china-region": "^{{{ version }}}",
"@nocobase/plugin-client": "^{{{ version }}}",
"@nocobase/plugin-collections": "^{{{ version }}}",
"@nocobase/plugin-export": "^{{{ version }}}",
"@nocobase/plugin-file-manager": "^{{{ version }}}",
"@nocobase/plugin-multi-apps": "^{{{ version }}}",
"@nocobase/plugin-permissions": "^{{{ version }}}",
"@nocobase/plugin-system-settings": "^{{{ version }}}",
"@nocobase/plugin-ui-router": "^{{{ version }}}",
"@nocobase/plugin-ui-schema": "^{{{ version }}}",
"@nocobase/plugin-users": "^{{{ version }}}",
"@nocobase/server": "^{{{ version }}}"
},
"devDependencies": {
"@nocobase/client": "^0.5.0-alpha.5",
"@nocobase/client": "^{{{ version }}}",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@umijs/preset-react": "1.x",