Arkadaşlar selamlar
YAML dosyasını iletiyorum, Size nginx+mongo destekli hazır çalışır docker contanier sunar. İstediğiniz kadar deploy edebilirsiniz. Dikkat etmeniz gereken tek şey nginx.conf'lardaki portları değiştirmeniz.
(1 sunucu üzerinde 20 contanier açarak , her contanier'a ayrı cpu,ram ve disk vererek yönetim sağlayabilirsiniz.)
Docker bir bakıma birbirinden bağımsız vm'ciklerdir. Aşağıdaki scripti dilediğiniz gibi ekleme çıkarma yapabilirsiniz. En latta xxx.sh ile , docker içinde yapılması gereken herşeyi , contanier içine girmeden dışarıdan tetikleyebilirsiniz. Örneğin wget ile dosya indirme(hazır kurulum wordpress contanier'ları, bazı ince ayarlar vs..) Docker çok gelişmiş bir yapıdır.
Önce sunucumuzu docker kuralım
Redhat(centos 6 ve 7 için)
yum -y install epel-release
yum -y update
yum -y install git
yum -y install npm nodejs
yum -y install unzip
curl -fsSL
https://get.docker.com/ | sh
systemctl enable docker.service
systemctl start docker.service
usermod -aG docker $(whoami)
docker pull centos
mkdir -p ~/root/docker && cd $_
Aşıdaki yaml dosyamızı > Dockerfile isminde kayıt edelim
docker build --rm --no-cache -t proje/nginx_server .
ile nginx+php+mongo serverımızın şablon sunucumuzu oluşturuyoruz.
docker pull proje/nginx_server
docker run -d -p 80:80 -v proje/nginx_server > bu şekildede 80 portuna ilk kutumuzu çalıştırıyoruz.
Nginx proxy server ve docker ui ile yönetim ve yönlendirmeleri kolaylaştırabilirsiniz. Bu konuya değinmedim ihtiyaç halinde yazarız
FROM centos/systemd
MAINTAINER "docker-name" <xx@xx.com>
RUN echo $'[mongodb]\n\
name=MongoDB Repository\n\
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/\n\
gpgcheck=0 \n\
enabled=1 \n'\
>> /etc/yum.repos.d/mongodb.repo
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN yum -y install mongo-10gen mongo-10gen-server; systemctl enable mongod.service
RUN yum -y install nginx; yum clean all; systemctl enable nginx.service
RUN yum -y install redis; yum clean all; systemctl enable redis.service
RUN yum -y install pkgconfig openssl tar hostname initscripts net-tools unzip wget nano git php56w-fpm php56w-pecl php56w-pdo php56w-soap php56w-mbstring php56w-pecl-memcached php56w-devel php56w-pecl-memcache php56w-pecl-redis; yum clean all; systemctl enable php-fpm.service
RUN ln -sf /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
RUN echo "extension=memcache.so" >> /etc/php.ini
RUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php.ini
RUN sed -i -e "s/;date.timezone =/date.timezone =Europe\/Istanbul/g" /etc/php.ini
RUN mkdir -p /var/www/html/docker.xxx.com/public_html
RUN mkdir -p /var/www/html/docker.xxx.com/logs/
RUN chown -R apache:apache /var/www/html/docker.xxx.com/public_html/
RUN echo $'<?php \n\
phpinfo(); \n\
?> \n'\
>> /var/www/html/docker.xxx.com/public_html/info.php
RUN echo $' server {\n\
server_name docker.xxx.com;\n\
listen 61;\n\
root /var/www/html/docker.xxx.com/public_html;\n\
access_log /var/www/html/docker.xxx.com/logs/docker.xxx.com.log;\n\
error_log /var/www/html/docker.xxx.com/logs/docker.xxx.com.log;\n\
index index.php;\n\
location / {\n\
try_files $uri $uri/ /index.php?$query_string;\n\
if (!-f $request_filename){\n\
set $rule_0 1$rule_0;\n\
}\n\
if ($rule_0 = "1"){\n\
rewrite ^/(.*?)$ /index.php?params=$1 last;\n\
}\n\
}\n\
location ~ \.php$ {\n\
fastcgi_index index.php;\n\
fastcgi_split_path_info ^(.+\.php)(.*)$;\n\
fastcgi_keep_conn on;\n\
include /etc/nginx/fastcgi_params;\n\
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;\n\
fastcgi_pass 127.0.0.1:9000;\n\
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n\
}\n\
location ~ /\.ht {\n\
deny all;\n\
}\n\
}\n'\
>> /etc/nginx/conf.d/default.conf
ADD xxx.sh /xxx.sh
EXPOSE 80
CMD ["/usr/sbin/init"]