From 835713b73390c45e29b642b62a1c23d64f50a6f2 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Thu, 6 Jun 2019 07:11:49 +0800 Subject: [PATCH] updated Dockerfile --- Dockerfile | 39 +++++++++++++++++++ crawlab.conf | 5 +++ crawlab/Dockerfile | 26 ------------- .../docker-compose.yml => docker-compose.yml | 0 4 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 Dockerfile create mode 100644 crawlab.conf delete mode 100644 crawlab/Dockerfile rename crawlab/docker-compose.yml => docker-compose.yml (100%) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d1a71f77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# images +FROM ubuntu:latest + +# source files +ADD . /opt/crawlab + +# install python +RUN apt-get update +RUN apt-get install -y python3 python3-pip net-tools iputils-ping vim ntp git nginx + +# soft link +RUN ln -s /usr/bin/pip3 /usr/local/bin/pip +RUN ln -s /usr/bin/python3 /usr/local/bin/python + +# install backend +RUN pip install -U setuptools +RUN pip install -r /opt/crawlab/crawlab/requirements.txt + +# install nvm +RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash +RUN export NVM_DIR="$HOME/.nvm" +RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +RUN nvm install 8.12 +RUN nvm use 8.12 + +# install frontend +WORKDIR /opt/crawlab/frontend +RUN npm install -g yarn pm2 +RUN yarn install + +# nginx config & start frontend +RUN cp /opt/crawlab/crawlab.conf /etc/nginx/conf.d +RUN service nginx reload + +# start backend +WORKDIR /opt/crawlab/crawlab +CMD pm2 start app.py +CMD pm2 start flower.py +CMD pm2 start worker.py diff --git a/crawlab.conf b/crawlab.conf new file mode 100644 index 00000000..f0b7cef2 --- /dev/null +++ b/crawlab.conf @@ -0,0 +1,5 @@ +server { + listen 8080; + root /opt/crawlab/frontend/dist; + index index.html; +} \ No newline at end of file diff --git a/crawlab/Dockerfile b/crawlab/Dockerfile deleted file mode 100644 index b286d956..00000000 --- a/crawlab/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# images -#FROM python:latest -FROM ubuntu:latest - -# source files -ADD . /opt/crawlab - -# add dns -RUN cat /etc/resolv.conf - -# install python -RUN apt-get update -RUN apt-get install -y python3 python3-pip net-tools iputils-ping vim ntp - -# soft link -RUN ln -s /usr/bin/pip3 /usr/local/bin/pip -RUN ln -s /usr/bin/python3 /usr/local/bin/python - -# install required libraries -RUN pip install -U setuptools -RUN pip install -r /opt/crawlab/requirements.txt - -# execute apps -WORKDIR /opt/crawlab -CMD python ./bin/run_worker.py -CMD python app.py diff --git a/crawlab/docker-compose.yml b/docker-compose.yml similarity index 100% rename from crawlab/docker-compose.yml rename to docker-compose.yml