diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..95adf9c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# misc +.DS_Store +.env +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# css +src/**/*.css +build +build.zip diff --git a/Dockerfile b/Dockerfile index 33c4f5a..e81267d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ # BUILDING FROM node:lts-alpine AS builder -LABEL maintainer="llitfkitfk@gmail.com" +# base on work of llitfkitfk@gmail.com +LABEL maintainer="chibing.fy@alibaba-inc.com" RUN yarn global add typescript WORKDIR /app # cache dependencies COPY package.json ./ -RUN yarn install +RUN yarn config set registry https://registry.npm.taobao.org/ && yarn install # build COPY . ./ @@ -17,7 +18,15 @@ RUN yarn run build # RUNNING FROM node:lts-alpine -LABEL maintainer="llitfkitfk@gmail.com" +# base on work of llitfkitfk@gmail.com +LABEL maintainer="chibing.fy@alibaba-inc.com" +# use China mirror of: https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-linux.tar.gz +RUN wget http://q08gwzg9o.bkt.clouddn.com/pandoc-2.7.3-linux.tar.gz && \ + tar -xf pandoc-2.7.3-linux.tar.gz && \ + cp pandoc-2.7.3/bin/* /usr/bin/ && \ + pandoc -v && \ + rm -rf pandoc-2.7.3-linux.tar.gz pandoc-2.7.3 + WORKDIR /app COPY --from=builder /app/dist . COPY --from=builder /app/node_modules ./node_modules \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b9ac341..d8a60f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,29 +1,26 @@ # mail@dongguochao.com # llitfkitfk@gmail.com +# chibing.fy@alibaba-inc.com version: "3" services: # frontend - nginx: + dolores: # image: nginx:stable-alpine - build: - # will use image from the frontend repo in the future - context: docker/frontend - volumes: - - ./docker/nginx/conf.d:/etc/nginx/conf.d + image: rapcore/rap2-dolores:latest ports: - - 38080:38080 - 38081:38081 # backend delos: # build from ./Dockerfile - build: . + image: rapcore/rap2-delos:latest + ports: + - 38080:38080 # build from images - # you can find last tag from https://hub.docker.com/r/blackdog1987/rap2-delos - # image: blackdog1987/rap2-delos:2.6.aa3be03 environment: + - SERVE_PORT=38080 # if you have your own mysql, config it here, and disable the 'mysql' config blow - MYSQL_URL=mysql # links will maintain /etc/hosts, just use 'container_name' - MYSQL_PORT=3306 diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile deleted file mode 100644 index 9d8d937..0000000 --- a/docker/frontend/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -# BUILDING -FROM node:lts-alpine AS builder - -LABEL maintainer="llitfkitfk@gmail.com" -WORKDIR /app - -RUN apk add --no-cache git -RUN git clone --depth 1 https://github.com/thx/rap2-dolores.git ./ -RUN yarn install -COPY config/config.prod.ts ./src/config/config.prod.ts -RUN yarn run lint -RUN yarn run build - -# nginx -FROM nginx:stable-alpine - -COPY --from=builder /app/build /app \ No newline at end of file diff --git a/docker/frontend/config/config.prod.ts b/docker/frontend/config/config.prod.ts deleted file mode 100644 index 1894d51..0000000 --- a/docker/frontend/config/config.prod.ts +++ /dev/null @@ -1,9 +0,0 @@ -const config: IConfig = { - serve: 'http://localhost:38080', - keys: ['some secret hurr'], - session: { - key: 'koa:sess', - }, -} - -export default config diff --git a/docker/nginx/conf.d/delos.conf b/docker/nginx/conf.d/delos.conf deleted file mode 100644 index a767a76..0000000 --- a/docker/nginx/conf.d/delos.conf +++ /dev/null @@ -1,17 +0,0 @@ -server { - listen 38080; - server_name localhost; - - #charset koi8-r; - #access_log /var/log/nginx/host.access.log main; - - location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_set_header X-Nginx-Proxy true; - proxy_set_header Connection ""; - proxy_pass http://delos:8080/; - } -} - diff --git a/docker/nginx/conf.d/dolores.conf b/docker/nginx/conf.d/dolores.conf deleted file mode 100644 index 738a581..0000000 --- a/docker/nginx/conf.d/dolores.conf +++ /dev/null @@ -1,12 +0,0 @@ -server { - listen 38081; - server_name localhost; - - root /app; - #charset koi8-r; - #access_log /var/log/nginx/host.access.log main; - - location / { - try_files $uri /index.html; - } -} diff --git a/package.json b/package.json index e52a152..e60c1b4 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "start": "cross-env NODE_ENV=production pm2 start dist/dispatch.js --name=rap-server-delos", "lint": "echo \"TSLint checking...\" && tslint -c tslint.json 'src/**/*.ts' 'src/**/*.tsx'", "start:redis": "pm2 start redis-server --name redis-server", - "clean": "pm2 delete all" + "clean": "pm2 delete all", + "build:docker": "docker build --rm -f \"Dockerfile\" -t rapteam/rap2-delos:latest ." }, "author": "bosn, nuysoft", "license": "ISC", diff --git a/src/config/config.dev.ts b/src/config/config.dev.ts index facf669..8519047 100644 --- a/src/config/config.dev.ts +++ b/src/config/config.dev.ts @@ -3,7 +3,7 @@ import { IConfigOptions } from "../types" let config: IConfigOptions = { version: 'v2.7.0', serve: { - port: 8080, + port: (process.env.SERVE_PORT && parseInt(process.env.SERVE_PORT)) || 8080, path: '', }, keys: ['some secret hurr'], diff --git a/src/config/config.local.ts b/src/config/config.local.ts index 7af4172..00d5516 100644 --- a/src/config/config.local.ts +++ b/src/config/config.local.ts @@ -3,7 +3,7 @@ import { IConfigOptions } from "../types" let config: IConfigOptions = { version: '2.7.0', serve: { - port: 8080, + port: (process.env.SERVE_PORT && parseInt(process.env.SERVE_PORT)) || 8080, path: '', }, keys: ['some secret hurr'], diff --git a/src/config/config.prod.ts b/src/config/config.prod.ts index 36252a7..2459717 100644 --- a/src/config/config.prod.ts +++ b/src/config/config.prod.ts @@ -4,7 +4,7 @@ import { IConfigOptions } from "../types" let config: IConfigOptions = { version: '2.7.0', serve: { - port: (process.env.EXPOSE_PORT && parseInt(process.env.EXPOSE_PORT)) || 8080, + port: (process.env.SERVE_PORT && parseInt(process.env.SERVE_PORT)) || 8080, path: '', }, keys: ['some secret hurr'],