Skip to content

Commit

Permalink
add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo authored and lihuanhuan committed Apr 12, 2018
1 parent 0b8192e commit 9c1bfb0
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM docker.io/centos

#archer
RUN yum -y install unzip git gcc gcc-c++ make cmake bison openssl-devel mysql-devel openldap-devel \
&& yum -y install epel-release \
&& yum -y install python34 python34-pip python34-devel.x86_64 \
&& cd /opt \
&& pip3 install virtualenv -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& virtualenv venv4archer --python=python3.4 \
&& source venv4archer/bin/activate \
&& git clone https://github.com/hhyo/archer.git \
&& pip3 install -r /opt/archer/requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& cp /opt/archer/src/docker/pymysql/connections.py /opt/venv4archer/lib/python3.4/site-packages/pymysql/ \
&& cp /opt/archer/src/docker/pymysql/cursors.py /opt/venv4archer/lib/python3.4/site-packages/pymysql/ \
&& yum -y install nginx \
&& cp /opt/archer/src/docker/nginx.conf /etc/nginx/ \
&& nginx \
#sqladvisor
&& yum -y install libaio-devel libffi-devel glib2 glib2-devel \
&& yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm \
&& yum -y install Percona-Server-devel-56.x86_64 Percona-Server-shared-56.x86_64 Percona-Server-client-56.x86_64 \
&& git clone https://github.com/Meituan-Dianping/SQLAdvisor.git \
&& cd /opt \
&& mv /opt/src/SQLAdvisor-master.zip /opt \
&& unzip SQLAdvisor-master.zip \
&& rm -rf SQLAdvisor-master.zip \
&& mv SQLAdvisor-master SQLAdvisor \
&& cd /opt/SQLAdvisor/ \
&& yum -y install make \
&& cmake -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr/local/sqlparser ./ \
&& make && make install \
&& cd sqladvisor/ \
&& cmake -DCMAKE_BUILD_TYPE=debug ./ \
&& make \
#修改中文支持
&& rm -rf /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& yum -y install kde-l10n-Chinese && yum -y reinstall glibc-common \
&& localedef -c -f UTF-8 -i zh_CN zh_CN.utf8

ENV LANG en_US.UTF-8
ENV LC_ALL zh_CN.utf8

#port
EXPOSE 9123

#start service
ENTRYPOINT bash /opt/archer/startup.sh && bash
115 changes: 115 additions & 0 deletions src/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

access_log on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

server{
listen 9123; #监听的端口
server_name archer;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /static {
alias /opt/archer/static;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }

}

0 comments on commit 9c1bfb0

Please sign in to comment.