Unverified Commit 072b9c2d authored by 陈帅's avatar 陈帅 Committed by GitHub

add docker support (#2459)

* add docker support

* remove test:all to package.json

* add gzip config
parent 88be0d2b
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
**/node_modules
# roadhog-api-doc ignore
/src/utils/request-temp.js
_roadhog-api-doc
# production
/dist
/.vscode
# misc
.DS_Store
npm-debug.log*
yarn-error.log
/coverage
.idea
yarn.lock
package-lock.json
*bak
.vscode
# visual studio code
.history
*.log
functions/mock
.temp/**
# umi
.umi
.umi-production
# screenshot
screenshot
.firebase
\ No newline at end of file
FROM node:latest
WORKDIR /usr/src/app/
COPY package.json ./
RUN npm install --silent --no-cache
COPY ./ ./
RUN apt-get update
RUN apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
CMD ["npm", "run", "build"]
...@@ -7,4 +7,5 @@ RUN npm install --silent --no-cache ...@@ -7,4 +7,5 @@ RUN npm install --silent --no-cache
COPY ./ ./ COPY ./ ./
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]
...@@ -79,6 +79,8 @@ We need your help: https://github.com/ant-design/ant-design-pro/issues/120 ...@@ -79,6 +79,8 @@ We need your help: https://github.com/ant-design/ant-design-pro/issues/120
## Usage ## Usage
### Use bash
```bash ```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 $ git clone https://github.com/ant-design/ant-design-pro.git --depth=1
$ cd ant-design-pro $ cd ant-design-pro
...@@ -86,6 +88,23 @@ $ npm install ...@@ -86,6 +88,23 @@ $ npm install
$ npm start # visit http://localhost:8000 $ npm start # visit http://localhost:8000
``` ```
### Use by docker
```bash
// dev
$ npm run docker:dev
// build
$ npm run docker:build
// production dev
$ npm run docker-prod:dev
// production build
$ npm run docker-prod:build
```
More instructions at [documentation](http://pro.ant.design/docs/getting-started). More instructions at [documentation](http://pro.ant.design/docs/getting-started).
## Browsers support ## Browsers support
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
## 使用 ## 使用
### 使用命令行
```bash ```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 $ git clone https://github.com/ant-design/ant-design-pro.git --depth=1
$ cd ant-design-pro $ cd ant-design-pro
...@@ -79,6 +80,23 @@ $ npm install ...@@ -79,6 +80,23 @@ $ npm install
$ npm start # 访问 http://localhost:8000 $ npm start # 访问 http://localhost:8000
``` ```
### 使用 docker
```bash
// dev
$ npm run docker:dev
// build
$ npm run docker:build
// production dev
$ npm run docker-prod:dev
// production build
$ npm run docker-prod:build
```
更多信息请参考 [使用文档](http://pro.ant.design/docs/getting-started) 更多信息请参考 [使用文档](http://pro.ant.design/docs/getting-started)
## 支持环境 ## 支持环境
......
FROM node:latest
WORKDIR /usr/src/app/
COPY package.json ./
RUN npm install --silent --no-cache
COPY ./ ./
RUN sh ./tests/fix_puppeteer.sh
RUN npm run test:all
CMD ["npm", "run", "build"]
...@@ -2,11 +2,13 @@ version: "3.5" ...@@ -2,11 +2,13 @@ version: "3.5"
services: services:
ant-design-pro_dev: ant-design-pro_dev:
ports:
- 8000:8000
build: build:
context: ./ context: ../
dockerfile: Dockerfile.dev dockerfile: Dockerfile.dev
container_name: "ant-design-pro_dev" container_name: "ant-design-pro_dev"
volumes: volumes:
- ./src:/usr/src/app/src - ../src:/usr/src/app/src
- ./config:/usr/src/app/config - ../config:/usr/src/app/config
- ./mock:/usr/src/app/mock - ../mock:/usr/src/app/mock
...@@ -2,13 +2,15 @@ version: "3.5" ...@@ -2,13 +2,15 @@ version: "3.5"
services: services:
ant-design-pro_build: ant-design-pro_build:
build: ./ build: ../
container_name: "ant-design-pro_build" container_name: "ant-design-pro_build"
volumes: volumes:
- dist:/usr/src/app/dist - dist:/usr/src/app/dist
ant-design-pro_web: ant-design-pro_web:
image: nginx image: nginx
ports:
- 80:80
container_name: "ant-design-pro_web" container_name: "ant-design-pro_web"
restart: unless-stopped restart: unless-stopped
volumes: volumes:
......
server { server {
listen 80; listen 80;
# gzip config
gzip on;
gzip_min_length 1k;
gzip_comp_level 9
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
root /usr/share/nginx/html; root /usr/share/nginx/html;
location / { location / {
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
} }
location /api {
proxy_pass https://preview.pro.ant.design;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"precommit": "npm run lint-staged", "precommit": "npm run lint-staged",
"presite": "npm run generate-mock && cd functions && npm install", "presite": "node ./scripts/generateMock.js && cd functions && npm install",
"start": "cross-env APP_TYPE=site umi dev", "start": "cross-env APP_TYPE=site umi dev",
"start:no-mock": "cross-env MOCK=none umi dev", "start:no-mock": "cross-env MOCK=none umi dev",
"build": "umi build", "build": "umi build",
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js", "lint-staged:js": "eslint --ext .js",
"test": "umi test", "test": "umi test",
"generate-mock": "node ./scripts/generateMock.js",
"test:component": "umi test ./src/components", "test:component": "umi test ./src/components",
"test:all": "node ./tests/run-tests.js", "test:all": "node ./tests/run-tests.js",
"prettier": "prettier --write ./src/**/**/**/*" "prettier": "prettier --write ./src/**/**/**/*",
"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"
}, },
"dependencies": { "dependencies": {
"@antv/data-set": "^0.9.6", "@antv/data-set": "^0.9.6",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment