From 8d57acc886eec16657c219493d7486b8407db6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sat, 17 Nov 2018 10:14:31 +0800 Subject: [PATCH] add preview use docker (#2890) --- .dockerignore | 1 - Dockerfile.hub | 11 +++++++++++ README.md | 13 +++++++++---- README.zh-CN.md | 11 ++++++++--- package.json | 7 +++++-- 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 Dockerfile.hub diff --git a/.dockerignore b/.dockerignore index 12022d6e..8e90ca6d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,7 +5,6 @@ /src/utils/request-temp.js # production -/dist /.vscode # misc diff --git a/Dockerfile.hub b/Dockerfile.hub new file mode 100644 index 00000000..2e9c1ec9 --- /dev/null +++ b/Dockerfile.hub @@ -0,0 +1,11 @@ +FROM nginx + +WORKDIR /usr/src/app/ + +COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf + +COPY ./dist /usr/share/nginx/html/ + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/README.md b/README.md index 4f068a24..6952f109 100644 --- a/README.md +++ b/README.md @@ -93,17 +93,22 @@ $ npm start # visit http://localhost:8000 ### Use by docker ```bash -// dev +# preview +$ docker pull chenshuai2144/ant-design-pro +$ docker run -p 80:80 chenshuai2144/ant-design-pro +# open http://localhost + +# dev $ npm run docker:dev -// build +# build $ npm run docker:build -// production dev +# production dev $ npm run docker-prod:dev -// production build +# production build $ npm run docker-prod:build ``` diff --git a/README.zh-CN.md b/README.zh-CN.md index d4aae9f3..e1682437 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -83,14 +83,19 @@ $ npm start # 访问 http://localhost:8000 ### 使用 docker ```bash -// dev +# preview +$ docker pull chenshuai2144/ant-design-pro +$ docker run -p 80:80 chenshuai2144/ant-design-pro +# open http://localhost + +# dev $ npm run docker:dev -// build +# build $ npm run docker:build -// production dev +# production dev $ npm run docker-prod:dev // production build diff --git a/package.json b/package.json index 28b06c80..8e0adabc 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "start": "cross-env APP_TYPE=site umi dev", "start:no-mock": "cross-env MOCK=none umi dev", "build": "umi build", - "site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy", + "site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push", "analyze": "cross-env ANALYZE=1 umi build", "lint:style": "stylelint \"src/**/*.less\" --syntax less", "lint": "eslint --ext .js src mock tests && npm run lint:style", @@ -24,7 +24,10 @@ "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up", "docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build", "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up", - "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build" + "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build", + "docker-hub:build":"docker build -f Dockerfile.hub -t ant-design-pro ./", + "docker:tag":"docker tag ant-design-pro chenshuai2144/ant-design-pro", + "docker:push":"npm run docker-hub:build && npm run docker:tag && docker push chenshuai2144/ant-design-pro" }, "dependencies": { "@babel/runtime": "^7.1.5", -- GitLab