forked from crawlab-team/crawlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marvin Zhang
committed
Jul 28, 2019
1 parent
80449a8
commit f3e7842
Showing
15 changed files
with
608 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea | ||
logs | ||
*.log | ||
node_modules/ | ||
dist/ | ||
**/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,59 @@ | ||
FROM golang:1.12 AS backend-build | ||
|
||
WORKDIR /go/src/app | ||
COPY ./backend . | ||
|
||
ENV GO111MODULE on | ||
ENV GOPROXY https://mirrors.aliyun.com/goproxy/ | ||
|
||
RUN go install -v ./... | ||
|
||
FROM node:8.16.0-alpine AS frontend-build | ||
|
||
ADD ./frontend /app | ||
WORKDIR /app | ||
|
||
# install frontend | ||
RUN npm install -g yarn && yarn install --registry=https://registry.npm.taobao.org | ||
|
||
RUN npm run build:prod | ||
|
||
# images | ||
FROM ubuntu:latest | ||
|
||
# source files | ||
ADD . /opt/crawlab | ||
ADD . /app | ||
|
||
# set as non-interactive | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# environment variables | ||
ENV NVM_DIR /usr/local/nvm | ||
ENV NODE_VERSION 8.12.0 | ||
ENV WORK_DIR /opt/crawlab | ||
|
||
# install pkg | ||
# install packages | ||
RUN apt-get update \ | ||
&& apt-get install -y curl git net-tools iputils-ping ntp nginx python3 python3-pip \ | ||
&& apt-get clean \ | ||
&& cp $WORK_DIR/crawlab.conf /etc/nginx/conf.d \ | ||
&& apt-get install -y curl git net-tools iputils-ping ntp ntpdate python3 python3-pip \ | ||
&& ln -s /usr/bin/pip3 /usr/local/bin/pip \ | ||
&& ln -s /usr/bin/python3 /usr/local/bin/python | ||
|
||
# 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 backend | ||
RUN pip install scrapy pymongo bs4 requests -i https://pypi.tuna.tsinghua.edu.cn/simple | ||
|
||
# install frontend | ||
RUN npm install -g yarn \ | ||
&& cd /opt/crawlab/frontend \ | ||
&& yarn install | ||
# copy backend files | ||
COPY --from=backend-build /go/src/app . | ||
COPY --from=backend-build /go/bin/crawlab /usr/local/bin | ||
|
||
# install backend | ||
RUN pip install -U setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple \ | ||
&& pip install -r /opt/crawlab/crawlab/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple | ||
# install nginx | ||
RUN apt-get -y install nginx | ||
|
||
# start backend | ||
# copy frontend files | ||
COPY --from=frontend-build /app/dist /app/dist | ||
COPY --from=frontend-build /app/conf/crawlab.conf /etc/nginx/conf.d | ||
|
||
# working directory | ||
WORKDIR /app/backend | ||
|
||
# frontend port | ||
EXPOSE 8080 | ||
|
||
# backend port | ||
EXPOSE 8000 | ||
WORKDIR /opt/crawlab | ||
ENTRYPOINT ["/bin/sh", "/opt/crawlab/docker_init.sh"] | ||
|
||
# start backend | ||
CMD ["/bin/sh", "/app/docker_init.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
#!/bin/sh | ||
case $1 in | ||
master) | ||
cd $WORK_DIR/frontend \ | ||
&& npm run build:prod \ | ||
&& service nginx start | ||
python $WORK_DIR/crawlab/flower.py >> /opt/crawlab/flower.log 2>&1 & | ||
python $WORK_DIR/crawlab/worker.py >> /opt/crawlab/worker.log 2>&1 & | ||
cd $WORK_DIR/crawlab \ | ||
&& gunicorn --log-level=DEBUG -b 0.0.0.0 -w 8 app:app | ||
;; | ||
worker) | ||
python $WORK_DIR/crawlab/app.py >> /opt/crawlab/app.log 2>&1 & | ||
python $WORK_DIR/crawlab/worker.py | ||
;; | ||
esac | ||
|
||
# replace default api path to new one | ||
jspath=`ls /app/dist/js/app.*.js` | ||
cat ${jspath} | sed "s/localhost:8000/${CRAWLAB_API_ADDRESS}/g" > ${jspath} | ||
|
||
# start nginx | ||
service nginx start | ||
|
||
crawlab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<template> | ||
<el-scrollbar wrap-class="scrollbar-wrapper"> | ||
<div class="sidebar-logo" :class="isCollapse ? 'collapsed' : ''"> | ||
<span>C</span><span v-show="!isCollapse">rawlab</span> | ||
</div> | ||
<el-menu | ||
:show-timeout="200" | ||
:default-active="routeLevel1" | ||
:collapse="isCollapse" | ||
:background-color="variables.menuBg" | ||
:text-color="variables.menuText" | ||
:active-text-color="variables.menuActiveText" | ||
mode="vertical" | ||
> | ||
<sidebar-item v-for="route in routes" :key="route.path" :item="route" :base-path="route.path"/> | ||
</el-menu> | ||
</el-scrollbar> | ||
</template> | ||
|
||
<script> | ||
import { mapState, mapGetters } from 'vuex' | ||
import variables from '@/styles/variables.scss' | ||
import SidebarItem from './SidebarItem' | ||
export default { | ||
components: { SidebarItem }, | ||
computed: { | ||
...mapState('user', [ | ||
'adminPaths' | ||
]), | ||
...mapGetters([ | ||
'sidebar' | ||
]), | ||
routeLevel1 () { | ||
let pathArray = this.$route.path.split('/') | ||
return `/${pathArray[1]}` | ||
}, | ||
routes () { | ||
return this.$router.options.routes.filter(d => { | ||
const role = this.$store.getters['user/userInfo'].role | ||
if (role === 'admin') return true | ||
return !this.adminPaths.includes(d.path) | ||
}) | ||
}, | ||
variables () { | ||
return variables | ||
}, | ||
isCollapse () { | ||
return !this.sidebar.opened | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
#app .sidebar-container .el-menu { | ||
height: calc(100% - 50px); | ||
} | ||
.sidebar-container .sidebar-logo { | ||
height: 50px; | ||
display: flex; | ||
align-items: center; | ||
padding-left: 20px; | ||
color: #fff; | ||
background: rgb(48, 65, 86); | ||
font-size: 28px; | ||
font-weight: 600; | ||
font-family: "Verdana", serif; | ||
} | ||
.sidebar-container .sidebar-logo.collapsed { | ||
padding-left: 7px; | ||
} | ||
</style> |
Oops, something went wrong.