feat: docker 部署

test
bigfengyu 5 years ago
parent 17eb191d31
commit 7d99597109

@ -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

@ -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

@ -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

@ -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

@ -1,9 +0,0 @@
const config: IConfig = {
serve: 'http://localhost:38080',
keys: ['some secret hurr'],
session: {
key: 'koa:sess',
},
}
export default config

@ -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/;
}
}

@ -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;
}
}

@ -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",

@ -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'],

@ -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'],

@ -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'],

Loading…
Cancel
Save