8000 Merge pull request #66 from dongweiming/master · lcppcl/code@7ea082f · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ea082f

Browse files
committed
Merge pull request douban#66 from dongweiming/master
Add Dockerfile
2 parents 59a56bc + ce11077 commit 7ea082f

File tree

6 files changed

+55
-13
lines changed

6 files changed

+55
-13
lines changed

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM ubuntu:14.04
2+
MAINTAINER Dongweiming "ciici123@gmail.com"
3+
4+
ENV DEBIAN_FRONTEND noninteractive
5+
ENV CODE_ENV "unset"
6+
7+
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" > /etc/apt/sources.list
8+
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
9+
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
10+
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> /etc/apt/sources.list
11+
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
12+
RUN echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" >> /etc/apt/sources.list
13+
RUN echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
14+
RUN echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
15+
RUN echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> /etc/apt/sources.list
16+
RUN echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
17+
RUN apt-get update
18+
19+
RUN apt-get install curl python -yq
20+
RUN curl -O https://raw.githubusercontent.com/dongweiming/code/master/scripts/install_code.sh
21+
RUN /bin/bash install_code.sh
22+
RUN rm -rf install_code.sh

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ Dependency
1212
- Python 2.7+
1313
- pip >= 1.4.1
1414

15+
Docker Installation
16+
-------------------
17+
18+
You can use [code](https://registry.hub.docker.com/u/dongweiming/code/)
19+
20+
```
21+
docker pull dongweiming/code
22+
```
23+
24+
or just build locally(recommended):
25+
26+
```
27+
cd code
28+
docker build -t code .
29+
```
30+
31+
And launch a bash shell inside the container:
32+
33+
```
34+
docker run -t -i code /bin/bash
35+
```
36+
1537
Quick Installation
1638
------------------
1739
Currently supports the following systems:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MySQL-python==1.2.4
1+
-e git+https://github.com/qingfeng/MySQLdb1@MySQL-python-1.2.4#egg=MySQL-python
22
Mako==0.9.0
33
docutils==0.9.1
44
gunicorn==18.0

scripts/common.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@ install_libmemcached() {
1919
check_virtualenv() {
2020
which virtualenv > /dev/null 2>&1
2121
if [ $? != 0 ];then
22-
echo "Install virtualenv..."
23-
sudo pip install virtualenv
22+
echo "Install virtualenv..."
23+
sudo pip install virtualenv
2424
fi
25+
virtualenv venv
26+
. venv/bin/activate
2527
}
2628

2729
setup_database() {
2830
read -p "Please input Mysql User(default is root):" user
2931
if [ "${user}" = "" ];then
30-
user="root"
32+
user="root"
3133
fi
3234
read -p "Please input Mysql ${user}'s password(default is ''):" passwd
3335
echo "drop database if exists valentine" | mysql --user=${user} --password=${passwd}
3436
echo "create database valentine" | mysql --user=${user} --password=${passwd}
35-
if [ $? -ne 0 ]; then
36-
exit 1
37+
if [b $? -ne 0 ]; then
38+
exit 1
3739
fi
3840
(echo "use valentine"; cat vilya/databases/schema.sql) | mysql --user=${user} --password=${passwd}
3941
}
@@ -43,14 +45,9 @@ install_code() {
4345
cd code
4446
echo "Setup database..."
4547
setup_database
46-
check_virtualenv
47-
virtualenv venv
48-
. venv/bin/activate
48+
test "$CODE_ENV" != "unset" && check_virtualenv
4949
pip install cython # should install first
5050
pip install -U setuptools # python-libmemcached require updated setuptools
51-
if [ -f /etc/arch-release ] ; then
52-
pip install "distribute==0.6.29" # Fixed install MySQL-python on archlinux for #14
53-
fi
5451
pip install -r requirements.txt
5552
}
5653

scripts/install_code.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Check Python version > 2.7
44
test `python -c 'import sys; print sys.version_info < (2, 7)'` = "True" && echo 'CODE requires Python 2.7.' && exit 1
55

6-
url='https://raw.github.com/douban/code/master/scripts'
6+
url='https://raw.githubusercontent.com/douban/code/master/scripts'
77

88
if [ -f /etc/fedora-release ] ; then
99
file="$url/fedora.sh"

scripts/ubuntu.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sudo apt-get install build-essential g++ git python-pip python-virtualenv python
88

99
echo "Install mysql..."
1010
sudo apt-get install mysql-client mysql-server libmysqlclient-dev -yq
11+
/etc/init.d/mysql restart
1112

1213
echo "Setup memcached port to 11311..."
1314
sudo sed -i "s/11211/11311/g" /etc/memcached.conf

0 commit comments

Comments
 (0)
0