yinxin630 / fiora

An interesting open source chat application. Developed with node.js, mongoDB, socket.io and react
https://fiora.suisuijiang.com
MIT License
6.57k stars 1.31k forks source link

Docker automated #47

Closed lemos1235 closed 5 years ago

lemos1235 commented 6 years ago

建议:弄一下 docker 自动构建:-> link 省略掉 build 的时间

Dockerfile

FROM node:alpine

WORKDIR /usr/src/app

Run wget -q -O - https://api.github.com/repos/yinxin630/fiora/tarball/master | tar xz --strip=1 && \
    apk add --no-cache python build-base && \
    yarn install && \
    yarn build && \
    rm -rf public/* && \
    mv dist/fiora/* public

CMD [ "node", "server/main.js" ]

或者

FROM node:alpine

WORKDIR /usr/src/app

Run  apk add --no-cache python build-base

COPY package.json .

RUN yarn install

COPY . .

RUN yarn build && rm -rf public/* && mv dist/fiora/* public

CMD [ "node", "server/main.js" ]
yinxin630 commented 6 years ago

感谢, docker我就简单看过, 玩的不熟, 有空我研究下哈

lemos1235 commented 5 years ago

docker-compose.yaml

version: '3.2'

services:
  fiora:
    build: .
    restart: always
    ports:
      - "9200:9200"
   environment:
      - "DATABASE=mongodb"
  mongodb:
    image: mongo
    restart: always

将 Dockerfile 与 docker-compose.yaml 添加到项目根目录,执行下面的命令用于快速构建并启动项目


docker-compose up -d 
sonofcrocus commented 5 years ago

Hello @yinxin630 @lemos1235 and thank you. So long story short, i have cloned fiora locally and i want to dockerize the application in an image or two ( one for client interface and one for server). Would you please share the Dockerfiles configuration in order to build the image? i tried several times but it doesn't work Thanks alot.

yinxin630 commented 5 years ago

Why my container can't connect mongo database(localhost:27017) ?

docker run --name mongo mongo
docker run --net=host --name fiora suisuijiang/fiora
sonofcrocus commented 5 years ago

@yinxin630 What i want to do is create a custom database image from mongo and node and not using the docker hub image. I've noticed that the client run from /build/dev-server.js and the server run from /server/main.js that's why i want to create two images out of those and then link them with docker-compose but i'm having trouble creating an image FROM two environments.

yinxin630 commented 5 years ago

已支持 docker 自动构建

yinxin630 commented 5 years ago

@sonofcrocus https://github.com/yinxin630/fiora/blob/master/Dockerfile

sonofcrocus commented 5 years ago

@yinxin630 Thanks alot.