diff --git a/Dockerfile b/Dockerfile index bcdd4f4c..b64ceebf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,7 +54,7 @@ RUN pip install crawlab-sdk==0.6.b20211024-1207 # add files COPY ./backend/conf /app/backend/conf COPY ./nginx /app/nginx -COPY ./docker_init.sh /app/docker_init.sh +COPY ./bin /app/bin # copy backend files RUN mkdir -p /opt/bin @@ -84,4 +84,4 @@ EXPOSE 8080 EXPOSE 8000 # start backend -CMD ["/bin/bash", "/app/docker_init.sh"] +CMD ["/bin/bash", "/app/bin/docker-init.sh"] diff --git a/Dockerfile.cn b/Dockerfile.cn index 4503b94d..edf54b70 100644 --- a/Dockerfile.cn +++ b/Dockerfile.cn @@ -54,7 +54,7 @@ RUN pip install crawlab-sdk==0.6.b20211024-1207 # add files COPY ./backend/conf /app/backend/conf COPY ./nginx /app/nginx -COPY ./docker_init.sh /app/docker_init.sh +COPY ./bin /app/bin # copy backend files RUN mkdir -p /opt/bin @@ -84,4 +84,4 @@ EXPOSE 8080 EXPOSE 8000 # start backend -CMD ["/bin/bash", "/app/docker_init.sh"] +CMD ["/bin/bash", "/app/bin/docker-init.sh"] diff --git a/Dockerfile.local b/Dockerfile.local index 8210afd5..d04207fa 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -54,7 +54,7 @@ RUN pip install crawlab-sdk==0.6.b20211024-1207 # add files COPY ./backend/conf /app/backend/conf COPY ./nginx /app/nginx -COPY ./docker_init.sh /app/docker_init.sh +COPY ./bin /app/bin # copy backend files RUN mkdir -p /opt/bin @@ -84,4 +84,4 @@ EXPOSE 8080 EXPOSE 8000 # start backend -CMD ["/bin/bash", "/app/docker_init.sh"] +CMD ["/bin/bash", "/app/bin/docker-init.sh"] diff --git a/backend/.air.master.conf b/backend/.air.master.conf index adf01597..47c2ee4d 100644 --- a/backend/.air.master.conf +++ b/backend/.air.master.conf @@ -7,7 +7,7 @@ tmp_dir = "/tmp" [build] # Just plain old shell command. You could use `make` as well. -cmd = "go build -o ../tmp/main ./ " +cmd = "go build -o ../tmp/main ./ " # Binary file yields from `cmd`. bin = "../tmp/main" # Customize binary. @@ -19,7 +19,7 @@ exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"] # Watch these directories if you specified. include_dir = ["../libs"] # Exclude files. -exclude_file = [ +exclude_file = [] # This log file places in your tmp_dir. log = "air.log" # It's not necessary to trigger build each time file changes if it's too frequent. diff --git a/backend/.air.worker.conf b/backend/.air.worker.conf index 954ad095..6198cadc 100644 --- a/backend/.air.worker.conf +++ b/backend/.air.worker.conf @@ -7,7 +7,7 @@ tmp_dir = "/tmp" [build] # Just plain old shell command. You could use `make` as well. -cmd = "go build -o ../tmp/main ./ " +cmd = "go build -o ../tmp/main ./ " # Binary file yields from `cmd`. bin = "../tmp/main" # Customize binary. diff --git a/bin/docker-init.sh b/bin/docker-init.sh new file mode 100755 index 00000000..f15755db --- /dev/null +++ b/bin/docker-init.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ "${CRAWLAB_NODE_MASTER}" = "Y" ]; then + # start master + /bin/bash /app/bin/docker-start-master.sh + + # start crawlab + crawlab-server master +else + # start crawlab + crawlab-server worker +fi diff --git a/bin/docker-start-master.sh b/bin/docker-start-master.sh new file mode 100755 index 00000000..339640fd --- /dev/null +++ b/bin/docker-start-master.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# start nginx +service nginx start + +# start seaweedfs server +seaweedfsDataPath=/data/seaweedfs +if [ -e ${seaweedfsDataPath} ]; then + : +else + mkdir -p ${seaweedfsDataPath} +fi +weed server \ + -dir /data \ + -master.dir ${seaweedfsDataPath} \ + -volume.dir.idx ${seaweedfsDataPath} \ + -ip localhost \ + -volume.port 9999 \ + -filer \ + >> /var/log/weed.log 2>&1 & diff --git a/docker_init.sh b/docker_init.sh deleted file mode 100755 index ad3d9815..00000000 --- a/docker_init.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash - -# replace absolute api url to relative -jspath=`ls /app/dist/js/index.*.js` -sed -i "s?VUE_APP_API_BASE_URL?\/api?g" ${jspath} - -# replace default api path to new one -# if [ "${CRAWLAB_API_ADDRESS}" = "" ]; -# then -# : -# else -# jspath=`ls /app/dist/js/app.*.js` -# sed -i "s?###CRAWLAB_API_ADDRESS###?${CRAWLAB_API_ADDRESS}?g" ${jspath} -# fi - -# replace base url -# if [ "${CRAWLAB_BASE_URL}" = "" ]; -# then -# : -# else -# indexpath=/app/dist/index.html -# sed -i "s?/js/?${CRAWLAB_BASE_URL}/js/?g" ${indexpath} -# sed -i "s?/css/?${CRAWLAB_BASE_URL}/css/?g" ${indexpath} -# fi - -#grant script -# chmod +x /app/backend/scripts/*.sh - -# install languages -# if [ "${CRAWLAB_SERVER_LANG_NODE}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_JAVA}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_DOTNET}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_PHP}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_GO}" = "Y" ]; -# then -# echo "installing languages" -# echo "you can view log at /var/log/install.sh.log" -# /bin/sh /app/backend/scripts/install.sh >> /var/log/install.sh.log 2>&1 & -# fi - -# generate ssh -ssh-keygen -q -t rsa -N "" -f ${HOME}/.ssh/id_rsa - -# ssh config -touch ${HOME}/.ssh/config && chmod 600 ${HOME}/.ssh/config -cat > ${HOME}/.ssh/config <> /var/log/weed.log 2>&1 & - - # start crawlab - crawlab-server master -else - # start crawlab - crawlab-server worker -fi diff --git a/workspace/docker-compose.yml b/workspace/docker-compose.yml index 131cd2ab..3584407d 100644 --- a/workspace/docker-compose.yml +++ b/workspace/docker-compose.yml @@ -3,17 +3,21 @@ services: master: build: context: ./dockerfiles/golang - command: "air -c .air.master.conf" + command: /bin/bash -c "/app/bin/docker-start-master.sh && air -c .air.master.conf" volumes: - "./.crawlab/master:/root/.crawlab" - ../backend:/backend - ../backend/go.mod.local:/backend/go.mod - ../..:/libs/crawlab-team + - ../bin:/app/bin + - ../nginx:/etc/nginx/conf.d + - ../frontend/dist:/app/dist environment: CRAWLAB_NODE_MASTER: "Y" CRAWLAB_MONGO_HOST: "mongo" ports: - "9080:8080" + - "9000:8000" depends_on: - mongo diff --git a/workspace/dockerfiles/node/Dockerfile b/workspace/dockerfiles/node/Dockerfile index a276ee6c..80eb7a4e 100644 --- a/workspace/dockerfiles/node/Dockerfile +++ b/workspace/dockerfiles/node/Dockerfile @@ -1,5 +1,4 @@ -FROM node:latest +FROM node:12 WORKDIR frontend ENV SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ RUN npm config set registry "http://registry.npm.taobao.org" -