From 3b78792e0bda75908d9fab48d0a5ee333660fd49 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Mon, 10 Jun 2019 21:36:26 +0800 Subject: [PATCH] added frontend dockerfile --- frontend/Dockerfile | 29 +++++++++++++++++++++++++++++ frontend/conf/crawlab.conf | 5 +++++ frontend/conf/nginx.conf | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 frontend/Dockerfile create mode 100644 frontend/conf/crawlab.conf diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 00000000..554a3b8a --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,29 @@ +# images +FROM nginx:latest + +# source files +ADD . /opt/crawlab/frontend + +# environment variables +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 8.12.0 +ENV WORK_DIR /opt/crawlab/frontend + +# install nvm +RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash \ + && . $NVM_DIR/nvm.sh \ + && nvm install v$NODE_VERSION \ + && nvm use v$NODE_VERSION \ + && nvm alias default v$NODE_VERSION +ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +# install frontend +RUN npm install -g yarn pm2 --registry=https://registry.npm.taobao.org +RUN cd /opt/crawlab/frontend && yarn install --registry=https://registry.npm.taobao.org + +# nginx config & start frontend +RUN cp $WORK_DIR/conf/crawlab.conf /etc/nginx/conf.d +RUN service nginx reload + +CMD ["npm", "run", "build:prod"] diff --git a/frontend/conf/crawlab.conf b/frontend/conf/crawlab.conf new file mode 100644 index 00000000..da8513f3 --- /dev/null +++ b/frontend/conf/crawlab.conf @@ -0,0 +1,5 @@ +server { + listen 8080; + root /opt/crawlab/frontend/dist; + index index.html; +} diff --git a/frontend/conf/nginx.conf b/frontend/conf/nginx.conf index 72c248d2..56e4cd80 100644 --- a/frontend/conf/nginx.conf +++ b/frontend/conf/nginx.conf @@ -8,8 +8,8 @@ http { default_type application/octet-stream; server { - listen 8888; - root /Users/yeqing/projects/crawlab-frontend/dist; + listen 8080; + root /opt/dist; index index.html; location ~ .*\.(js|css)?$ {