diff --git a/Dockerfile b/Dockerfile index 390ece66..ddb4d47e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,4 +56,4 @@ EXPOSE 8080 EXPOSE 8000 # start backend -CMD ["/bin/sh", "./wait-for-it.sh", "mongo:27017", "--", "/bin/sh", "/app/docker_init.sh"] +CMD ["/bin/sh", "/app/docker_init.sh"] diff --git a/Dockerfile.local b/Dockerfile.local index f500369c..ddb4d47e 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -4,16 +4,17 @@ WORKDIR /go/src/app COPY ./backend . ENV GO111MODULE on -ENV GOPROXY https://mirrors.aliyun.com/goproxy/ +ENV GOPROXY https://goproxy.io RUN go install -v ./... -FROM node:8.16.0 AS frontend-build +FROM node:8.16.0-alpine AS frontend-build ADD ./frontend /app WORKDIR /app # install frontend +RUN npm config set unsafe-perm true RUN npm install -g yarn && yarn install --registry=https://registry.npm.taobao.org RUN npm run build:prod @@ -26,9 +27,6 @@ ADD . /app # set as non-interactive ENV DEBIAN_FRONTEND noninteractive -# set tmp folder privillege -RUN chmod -R 777 /tmp - # install packages RUN apt-get update \ && apt-get install -y curl git net-tools iputils-ping ntp ntpdate python3 python3-pip \ @@ -58,4 +56,4 @@ EXPOSE 8080 EXPOSE 8000 # start backend -CMD ["/bin/sh", "/app/docker_init.sh"] \ No newline at end of file +CMD ["/bin/sh", "/app/docker_init.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 3ed6c76a..bea50fb1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,25 +6,25 @@ services: environment: CRAWLAB_API_ADDRESS: "http://localhost:8000" # backend API address 后端 API 地址,设置为 http://<宿主机IP>:<端口>,端口为映射出来的端口 CRAWLAB_SERVER_MASTER: "Y" # whether to be master node 是否为主节点,主节点为 Y,工作节点为 N - CRAWLAB_MONGO_HOST: "mongo" # MongoDB host address MongoDB 的地址,在 docker compose 网络中,直接引用服务名称 + CRAWLAB_MONGO_HOST: "mongo1" # MongoDB host address MongoDB 的地址,在 docker compose 网络中,直接引用服务名称 CRAWLAB_REDIS_ADDRESS: "redis" # Redis host address Redis 的地址,在 docker compose 网络中,直接引用服务名称 ports: - "8080:8080" # frontend port mapping 前端端口映射 - "8000:8000" # backend port mapping 后端端口映射 depends_on: - - mongo + - mongo1 - redis worker: image: tikazyq/crawlab:latest container_name: worker environment: CRAWLAB_SERVER_MASTER: "N" - CRAWLAB_MONGO_HOST: "mongo" + CRAWLAB_MONGO_HOST: "mongo1" CRAWLAB_REDIS_ADDRESS: "redis" depends_on: - - mongo + - mongo1 - redis - mongo: + mongo1: image: mongo:latest restart: always # volumes: @@ -37,4 +37,4 @@ services: # volumes: # - "/opt/crawlab/redis/data:/data" # make data persistent 持久化 # ports: - # - "6379:6379" # expose port to host machine 暴露接口到宿主机 \ No newline at end of file + # - "6379:6379" # expose port to host machine 暴露接口到宿主机 diff --git a/docker_init.sh b/docker_init.sh index 09f63e9b..8c256839 100755 --- a/docker_init.sh +++ b/docker_init.sh @@ -22,4 +22,10 @@ fi # start nginx service nginx start +# wait for mongo service to be ready +#/app/wait-for-it.sh $CRAWLAB_MONGO_HOST:$CRAWLAB_MONGO_PORT + +# wait for redis service to be ready +#/app/wait-for-it.sh $CRAWLAB_REDIS_ADDRESS:$CRAWLAB_REDIS_PORT + crawlab \ No newline at end of file