镜像
前提
默认认为您对docker已有了解并且已经安装docker,否则请您先看看这个.
如果不想知道创建这些镜像的过程,请直接用我配置好的 PULL完后请直接跳转到PycharmXX配置:
-
https://hub.docker.com/repository/docker/deamonhacker/odoo_db/tags 或直接拉 docker pull deamonhacker/odoo_db:9.5
-
https://hub.docker.com/repository/docker/deamonhacker/odoo_app/tags 或 docker pull deamonhacker/odoo_app:10.0.0
如果你想了解APP和DB镜像创建的过程请继续阅读:
1. 创建APP镜像
这里不用Dockerfile,APP的dockerfile后面我会补上
docker pull debian:stable-slim
docker tag debian odoo_app:10.0
docker run --name=odoo_app -itd -v /var/opt:/Users/XX/opt odoo_app:10.0
docker exec -it --user root 容器ID /bin/bash
2. Debian换源(进入容器后)
mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib"
apt-get update
3. 安装python2.7
apt-get install python2.7
apt-get install gcc
4. 添加环境变量
vim ~/.bashrc
PATH=$PATH:/usr/bin/python2.7
export PATH
source ~/.bashrc
5.PIP换源
cd ~
mkdir .pip
cd .pip
touch pip.conf
vim pip.conf
#内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
6. 安装odoo必须包
apt-get update && apt-get upgrade -y && apt-get install python-pip -y
apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
pip install
cd /etc/opt
pip install --upgrade setuptools
python -m pip install --upgrade pip
touch requirements.txt
vim requirements.txt
requirements.txt内容如下
Babel==2.3.4
decorator==4.0.10
docutils==0.12
ebaysdk==2.1.4
feedparser==5.2.1
gevent==1.1.2
greenlet==0.4.10
jcconv==0.2.3
Jinja2==2.10.1
lxml
Mako==1.0.4
MarkupSafe==0.23
mock==2.0.0
ofxparse==0.16
passlib==1.6.5
Pillow==3.4.1
psutil==4.3.1
psycogreen==1.0
psycopg2==2.7.3.1
pydot==1.2.3
pyparsing==2.1.10
pyPdf==1.13
pyserial==3.1.1
Python-Chart==1.39
python-dateutil==2.5.3
python-ldap
python-openid==2.2.5
pytz==2016.7
pyusb==1.0.0
PyYAML==3.12
qrcode==5.3
reportlab==3.3.0
requests==2.20.0
six==1.10.0
suds-jurko==0.6
vatnumber==1.2
vobject==0.9.3
Werkzeug==0.11.11
wsgiref==0.1.2
XlsxWriter==0.9.3
xlwt==1.1.2
xlrd==1.0.0
7. 将当前容器打包成镜像
docker commit -a 'tc' -m 'Odoo10 Standard Server Env.' a49c332fd192 odoo_app:10.0.0
docker kill 原容器ID
docker rm 原容器ID
docker rmi 原镜像ID
8. 启动容器
docker run --name=odoo_app -itd -v /var/opt:/Users/XX/opt odoo_app:10.0.0
Docker for Postgresql9.5
创建Dockfile
FROM postgres:9.5
MAINTAINER tc
WORKDIR /usr/src/app
#初始化PostgreSQL
ENV POSTGRES_USER root
ENV POSTGRES_PASSWORD root
ENV POSTGRES_DB odoo
#容器运行时监听的端口
EXPOSE 5432
创建DB镜像
docker build -t odoo_db:9.5 .
启动DB
docker run -itd -p 5432:5432 -v /User/XX/codes/db_data:/var/lib/postgres/data --env POSTGRES_USER=odoo --env POSTGRES_PASSWORD=odoo --name odoo_db 5f643dd6895d
连接检测DB容器
Pycharm DB配置
Pycharm App配置
添加interpreter:
配置 APP 信息
最后一步-启动环境
1. 启动db
2. 启动app
打开网页
http://localhost:8069/web
稍等片刻
登录
admin/admin
针对Mac OS有几个代码要注意
sudo mount -uw /
xcrun --show-sdk-path
sudo ln -s <the_path_from_above_command>/usr/include /usr/include
# 防止reportlab报错
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
# conda 安装requirement.txt
while read requirement;do conda install --yes $requirement || pip install $requirement; done < /Users/XXX/Works/codes/odoo_project/odoo_community/odoo/requirements.txt
# pip 安装requirement.txt
pip install -r /Users/XXX/Works/codes/odoo_project/odoo_community/odoo/requirements.txt --ignore-installed
# 注释reportlab pillow python-ldap并采用如下方式安装
pip install python-ldap==2.4.27 --global-option=build_ext --global-option="-I$(xcrun --show-sdk-path)/usr/include/sasl"
conda install -c conda-forge reportla
pip install pillow