添加docker打包脚本

This commit is contained in:
chenzhipei 2021-07-08 16:44:10 +08:00
parent 488f57d5f6
commit fbd3cee50a
7 changed files with 127 additions and 1 deletions

2
.gitignore vendored
View File

@ -62,3 +62,5 @@ services/service-metadata-layouts/.env.local
steedos-packages/**/node_modules/**
steedos-projects/**/node_modules/**
packages/cli/dist/**
docker-volumes

22
DOCKER_BUILD.md Normal file
View File

@ -0,0 +1,22 @@
## Docker Build
### 更新项目
```bash
git checkout 2.0-meteor1.9
git pull
```
### 登录docker
```bash
docker login
# 输入用户名和密码
```
### 执行打包
```bash
yarn build_image
# 等待打包打包后会自动推送到hub
```

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM node:12.16.3
ENV community_dir=./steedos-projects/project-community
WORKDIR /app
ADD ${community_dir}/ ./
RUN npm config set registry http://registry.npm.taobao.org/
RUN yarn config set registry http://registry.npm.taobao.org/
RUN yarn install --production
ENV NODE_ENV=production
CMD ["yarn", "start"]

19
build_image.js Normal file
View File

@ -0,0 +1,19 @@
// build 镜像并上传至docker hub
console.log("IMAGE*******************************************************************");
const { execSync } = require("child_process");
const VERSION = require("./steedos-projects/project-community/package.json").version;
const IMAGE_VERSION = `steedos/steedos-project-community:${VERSION}`;
let cwd = process.cwd();
console.log("* VERSION: ", VERSION);
console.log("* cwd: ", cwd);
console.log(`* image: build start!`);
execSync(`docker rmi ${IMAGE_VERSION} --force`);
execSync(`docker build --no-cache=true -t ${IMAGE_VERSION} .`);
console.log(`* image: build done!`);
console.log(`pushing image to hub...`);
execSync(`docker push ${IMAGE_VERSION}`);
console.log(`* image: push done!`);
console.log("*******************************************************************IMAGE");

59
docker-compose.yml Normal file
View File

@ -0,0 +1,59 @@
version: "3"
services:
steedos:
image: steedos/steedos-project-community:2.0.34
restart: always
ports:
- "3000:3000"
volumes:
- "./docker-volumes/steedos/storage:/app/storage"
environment:
- PORT=3000
- ROOT_URL=http://localhost:3000
- MONGO_URL=mongodb://mongo:27017/steedos
- MONGO_OPLOG_URL=mongodb://mongo:27017/local
- STEEDOS_CFS_STORE=local
- STEEDOS_STORAGE_DIR=/app/storage
- TRANSPORTER=redis://redis:6379
- CACHER=redis://redis/1
depends_on:
- mongo
- redis
redis:
image: redis:6.2.4
restart: always
volumes:
- "./docker-volumes/redis/data:/data"
command: redis-server
ports:
- "6389:6379"
mongo:
image: mongo:4.2
restart: always
volumes:
- "./docker-volumes/mongo/data/db:/data/db"
command: mongod --oplogSize 128 --profile=1 --slowms=500 --replSet rs0 --bind_ip_all
ports:
- "27018:27017"
# this container's job is just run the command to initialize the replica set.
# it will run the command and remove himself (it will not stay running)
mongo-init-replica:
image: mongo:4.2
command: >
bash -c
"for i in `seq 1 30`; do
mongo mongo/steedos --eval \"
rs.initiate({
_id: 'rs0',
version: 1,
members: [ { _id: 0, host: 'mongo:27017' } ]})\" &&
s=$$? && break || s=$$?;
echo \"Tried $$i times. Waiting 5 secs...\";
sleep 5;
done; (exit $$s)"
depends_on:
- mongo

View File

@ -25,7 +25,8 @@
"git": "git config core.autocrlf true && git config core.filemode false",
"update-yarn": "curl --compressed -o- -L https://yarnpkg.com/install.sh | bash",
"syncToTaoBaoWin": "start https://npm.taobao.org/sync/@steedos/webapp && start https://npm.taobao.org/sync/@steedos/app-admin && start https://npm.taobao.org/sync/@steedos/app-crm && start https://npm.taobao.org/sync/@steedos/app-contracts && start https://npm.taobao.org/sync/@steedos/auth && start https://npm.taobao.org/sync/steedos-cli && start https://npm.taobao.org/sync/@steedos/core && start https://npm.taobao.org/sync/@steedos/filters && start https://npm.taobao.org/sync/@steedos/i18n && start https://npm.taobao.org/sync/@steedos/meteor-bundle-dependencies && start https://npm.taobao.org/sync/@steedos/meteor-bundle-runner && start https://npm.taobao.org/sync/@steedos/migrate && start https://npm.taobao.org/sync/@steedos/objectql && start https://npm.taobao.org/sync/@steedos/project-template-empty && start https://npm.taobao.org/sync/@steedos/schemas && start https://npm.taobao.org/sync/@steedos/standard-objects && start https://npm.taobao.org/sync/steedos-server && start https://npm.taobao.org/sync/create-steedos-app && start https://npm.taobao.org/sync/@steedos/plugin-enterprise && start https://npm.taobao.org/sync/@steedos/accounts",
"syncToTaoBaoMac": "./.scripts/syncToTaoBaoMac.sh"
"syncToTaoBaoMac": "./.scripts/syncToTaoBaoMac.sh",
"build_image": "node build_image.js"
},
"resolutions": {
"**/lodash": "^4.17.15",

View File

@ -27,6 +27,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"@steedos/app-admin": "2.0.34",
"@steedos/app-contracts": "2.0.34",
"@steedos/app-crm": "2.0.34",
"@steedos/app-oa": "2.0.34",
"@steedos/app-okr-management": "2.0.34",
"@steedos/app-project-management": "2.0.34",
"@steedos/service-charts": "^2.0.34",
"@steedos/service-metadata-server": "^2.0.34",
"@steedos/service-mongodb-server": "^2.0.34",