diff --git a/DEV/Dockerfile b/DEV/Dockerfile index bafc93f..6aead2c 100644 --- a/DEV/Dockerfile +++ b/DEV/Dockerfile @@ -1,6 +1,6 @@ # sd-swoole FROM php:7.1-cli -MAINTAINER Jincheng Zhang 896369042@qq.com +MAINTAINER peterpang 10846295@qq.com # 构建swoole环境,在这里安装了php,swoole,composer COPY sshd_config /etc/ssh/ RUN apt-get update && apt-get install -y \ @@ -15,17 +15,17 @@ RUN apt-get update && apt-get install -y \ subversion \ supervisor \ --no-install-recommends \ - && docker-php-ext-install zip opcache bcmath pdo_mysql \ + && docker-php-ext-install zip opcache bcmath pdo_mysql mysqli \ && cd /home && rm -rf temp && mkdir temp && cd temp \ - && wget https://github.com/swoole/swoole-src/archive/v1.9.19.tar.gz \ + && wget https://github.com/swoole/swoole-src/archive/v1.10.3.tar.gz \ https://github.com/redis/hiredis/archive/v0.13.3.tar.gz \ https://github.com/phpredis/phpredis/archive/3.1.3.tar.gz \ && tar -xzvf 3.1.3.tar.gz \ && tar -xzvf v0.13.3.tar.gz \ - && tar -xzvf v1.9.19.tar.gz \ + && tar -xzvf v1.10.3.tar.gz \ && cd /home/temp/hiredis-0.13.3 \ && make -j && make install && ldconfig \ - && cd /home/temp/swoole-src-1.9.19 \ + && cd /home/temp/swoole-src-1.10.3 \ && phpize && ./configure --enable-async-redis --enable-openssl && make \ && make install \ && pecl install inotify \ @@ -50,9 +50,9 @@ RUN apt-get update && apt-get install -y \ && apt-get autoclean \ && apt-get autoremove \ && rm -rf /var/lib/apt/lists/* \ -#添加ssh用户 + #添加ssh用户 && useradd admin \ - && echo 'root:123' | chpasswd \ + && echo 'root:123456' | chpasswd \ && /etc/init.d/ssh restart COPY ./config/* /usr/local/etc/php/conf.d/ diff --git a/DEV/docker-compose.yml b/DEV/docker-compose.yml index f5cd2da..62d4e61 100644 --- a/DEV/docker-compose.yml +++ b/DEV/docker-compose.yml @@ -5,10 +5,10 @@ services: container_name: mysql image: mysql:5.7 environment: - MYSQL_ROOT_PASSWORD: "root" - MYSQL_USER: "youwo" - MYSQL_PASSWORD: "123456" - MYSQL_DATABASE: "youwo_dliao" + MYSQL_ROOT_PASSWORD: "ecube123" + MYSQL_USER: "root" + MYSQL_PASSWORD: "ecube123" + MYSQL_DATABASE: "one" volumes: - /home/docker/mysql:/var/lib/mysql ports: @@ -23,81 +23,59 @@ services: ports: - "16379:6379" - # SD框架阿里云内网registry-internal.cn-hangzhou.aliyuncs.com/youwoxing/dev - ojl: - container_name: ojl - image: registry.cn-hangzhou.aliyuncs.com/youwoxing/dev + # SD框架阿里云内网 registry.cn-hangzhou.aliyuncs.com/peterpang/dev + peter: + container_name: peter + image: registry-internal.cn-hangzhou.aliyuncs.com/peterpang/dev links: - mysql - redis volumes: - - /home/docker_user/ojl:/home - ports: + - /home/docker_user/peter:/home + ports: + - "10181:8081" - "10183:8083" - "10193:9093" - "10122:22" - zch: - container_name: zch - image: registry.cn-hangzhou.aliyuncs.com/youwoxing/dev + ljj: + container_name: ljj + image: registry-internal.cn-hangzhou.aliyuncs.com/peterpang/dev links: - mysql - redis volumes: - - /home/docker_user/zch:/home + - /home/docker_user/ljj:/home ports: + - "10281:8081" - "10283:8083" - "10293:9093" - "10222:22" - ln: - container_name: ln - image: registry.cn-hangzhou.aliyuncs.com/youwoxing/dev + hy: + container_name: hy + image: registry-internal.cn-hangzhou.aliyuncs.com/peterpang/dev links: - mysql - redis volumes: - - /home/docker_user/ln:/home + - /home/docker_user/hy:/home ports: + - "10381:8081" - "10383:8083" - "10393:9093" - "10322:22" - - dwx: - container_name: dwx - image: registry.cn-hangzhou.aliyuncs.com/youwoxing/dev + + jm: + container_name: jm + image: registry-internal.cn-hangzhou.aliyuncs.com/peterpang/dev links: - mysql - redis volumes: - - /home/docker_user/dwx:/home + - /home/docker_user/jm:/home ports: + - "10481:8081" - "10483:8083" - "10493:9093" - "10422:22" - - lc: - container_name: lc - image: registry.cn-hangzhou.aliyuncs.com/youwoxing/dev - links: - - mysql - - redis - volumes: - - /home/docker_user/lc:/home - ports: - - "10583:8083" - - "10593:9093" - - "10522:22" - - jxy: - container_name: jxy - image: registry.cn-hangzhou.aliyuncs.com/youwoxing/dev - links: - - mysql - - redis - volumes: - - /home/docker_user/jxy:/home - ports: - - "10683:8083" - - "10693:9093" - - "10622:22" \ No newline at end of file diff --git a/NODE/Dockerfile b/NODE/Dockerfile new file mode 100644 index 0000000..a2c3387 --- /dev/null +++ b/NODE/Dockerfile @@ -0,0 +1,68 @@ +FROM alpine:3.6 + +ENV NODE_VERSION 9.5.0 + +RUN addgroup -g 1000 node \ + && adduser -u 1000 -G node -s /bin/sh -D node \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + binutils-gold \ + curl \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python \ + # gpg keys listed at https://github.com/nodejs/node#release-team + && for key in \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + FD3A5288F042B6850C66B31F09FE44734EB7990E \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + B9AE9905FFD7803F25714661B63B535A4C206CA9 \ + 56730D5401028683275BD23C23EFEFE93C4CFFFE \ + 77984A986EBC2AA786BC0F66B01FBB92821C587A \ + ; do \ + gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ + gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \ + done \ + && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install \ + && apk del .build-deps \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt + +ENV YARN_VERSION 1.3.2 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ + gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \ + done \ + && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && mkdir -p /opt/yarn \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \ + && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn + +CMD [ "node" ] \ No newline at end of file diff --git a/SD/Dockerfile b/SD/Dockerfile index 3acf2a6..396f129 100644 --- a/SD/Dockerfile +++ b/SD/Dockerfile @@ -1,6 +1,6 @@ # sd-swoole -FROM registry.cn-hangzhou.aliyuncs.com/youwoxing/swoole -MAINTAINER Jincheng Zhang 896369042@qq.com +FROM registry.cn-hangzhou.aliyuncs.com/youwoxing/sd +MAINTAINER peterpang 10846295@qq.com RUN mkdir /apps COPY composer.json /apps/composer.json # 安装SD框架 diff --git a/SD/composer.json b/SD/composer.json index a27fa3e..15d977b 100644 --- a/SD/composer.json +++ b/SD/composer.json @@ -1,6 +1,6 @@ { "require": { - "tmtbe/swooledistributed":">=2.5.0" + "tmtbe/swooledistributed":">=2.7.3" }, "autoload": { "psr-4": { diff --git a/docker-lemp b/docker-lemp new file mode 160000 index 0000000..6148b52 --- /dev/null +++ b/docker-lemp @@ -0,0 +1 @@ +Subproject commit 6148b52ba170d3eaf682fb83240ae5ef2e08ef79 diff --git a/nginx-php7/.travis.yml b/nginx-php7/.travis.yml new file mode 100644 index 0000000..de8b646 --- /dev/null +++ b/nginx-php7/.travis.yml @@ -0,0 +1,15 @@ +services: + - docker + +env: + global: + - COMMIT=${TRAVIS_COMMIT::8} + - REPO=trafex/alpine-nginx-php7 + +script: + - docker --version + - export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi` + - docker login -u $DOCKER_USER -p $DOCKER_PASS + - docker build -t $REPO:$COMMIT . + - docker tag $REPO:$COMMIT $REPO:$TAG + - docker push $REPO diff --git a/nginx-php7/Dockerfile b/nginx-php7/Dockerfile new file mode 100644 index 0000000..ab5526b --- /dev/null +++ b/nginx-php7/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:16.04 + +MAINTAINER peterpang 10846295@qq.com +# 构建swoole环境,在这里安装了php,swoole,composer +COPY sshd_config /etc/ssh/ + +ENV DEBIAN_FRONTEND noninteractive + +## Install php nginx mysql supervisor +RUN apt update && \ + apt install -y php7.0-fpm php7.0-mysql php7.0-gd php7.0-mcrypt php7.0-mysql php7.0-curl \ + php7.0-phalcon \ + nginx \ + curl \ + zlib1g-dev \ + vim \ + libssl-dev \ + unzip \ + wget \ + git \ + make \ + openssh-server \ + subversion \ + supervisor \ + --no-install-recommends \ + #添加ssh用户 + && useradd admin \ + && echo 'root:123456' | chpasswd \ + && /etc/init.d/ssh restart + +## Configuration +RUN sed -i 's/^listen\s*=.*$/listen = 127.0.0.1:9000/' /etc/php/7.0/fpm/pool.d/www.conf && \ + sed -i 's/^\;error_log\s*=\s*syslog\s*$/error_log = \/var\/log\/php\/cgi.log/' /etc/php/7.0/fpm/php.ini && \ + sed -i 's/^\;error_log\s*=\s*syslog\s*$/error_log = \/var\/log\/php\/cli.log/' /etc/php/7.0/cli/php.ini && \ +COPY files/root / + +WORKDIR /var/www/ + +VOLUME ["/var/www/"] + +EXPOSE 80 + +ENTRYPOINT ["/entrypoint.sh", "/usr/sbin/sshd","-D"] diff --git a/nginx-php7/config/fpm-pool.conf b/nginx-php7/config/fpm-pool.conf new file mode 100644 index 0000000..741c1ed --- /dev/null +++ b/nginx-php7/config/fpm-pool.conf @@ -0,0 +1,38 @@ +[global] +; Log to stderr +error_log = /dev/stderr + +[www] +; Enable status page +pm.status_path = /fpm-status + +; Ondemand process manager +pm = ondemand + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = 50 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +pm.process_idle_timeout = 10s; + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +pm.max_requests = 500 + +; Make sure the FPM workers can reach the environment variables for configuration +clear_env = no + +; Catch output from PHP +catch_workers_output = yes diff --git a/nginx-php7/config/nginx.conf b/nginx-php7/config/nginx.conf new file mode 100644 index 0000000..7c6bad6 --- /dev/null +++ b/nginx-php7/config/nginx.conf @@ -0,0 +1,68 @@ +worker_processes 1; +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for" ' + '$request_time $upstream_response_time $pipe $upstream_cache_status'; + + access_log /dev/stdout main_timed; + error_log /dev/stderr notice; + + keepalive_timeout 65; + + server { + listen [::]:80 default_server; + listen 80 default_server; + server_name _; + + sendfile off; + + root /var/www/html; + index index.php index.html; + + location / { + # First attempt to serve request as file, then + # as directory, then fall back to index.php + try_files $uri $uri/ /index.php?q=$uri&$args; + } + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/lib/nginx/html; + } + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass 127.0.0.1:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_index index.php; + include fastcgi_params; + } + + location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { + expires 5d; + } + + # deny access to . files, for security + # + location ~ /\. { + log_not_found off; + deny all; + } + } +} diff --git a/nginx-php7/config/php.ini b/nginx-php7/config/php.ini new file mode 100644 index 0000000..7bb1be5 --- /dev/null +++ b/nginx-php7/config/php.ini @@ -0,0 +1,2 @@ +[Date] +date.timezone="UTC" diff --git a/nginx-php7/config/supervisord.conf b/nginx-php7/config/supervisord.conf new file mode 100644 index 0000000..6801c89 --- /dev/null +++ b/nginx-php7/config/supervisord.conf @@ -0,0 +1,20 @@ +[supervisord] +nodaemon=true + +[program:php-fpm] +command=php-fpm7 -F +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=false +startretries=0 + +[program:nginx] +command=nginx -g 'daemon off;' +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=false +startretries=0 diff --git a/nginx-php7/docker-compose.yml b/nginx-php7/docker-compose.yml new file mode 100644 index 0000000..e60652b --- /dev/null +++ b/nginx-php7/docker-compose.yml @@ -0,0 +1,37 @@ +version: "2" +services: + # MySQL 5.7: https://hub.docker.com/_/mysql/ + mysql: + container_name: mysql + image: mysql:5.7 + environment: + MYSQL_ROOT_PASSWORD: "test123" + MYSQL_USER: "root" + MYSQL_PASSWORD: "test123" + MYSQL_DATABASE: "one" + volumes: + - /home/docker/mysql:/var/lib/mysql + ports: + - "13306:3306" + + # Redis 3.2.10: https://hub.docker.com/_/redis/ + redis: + container_name: redis + image: redis:3.2.10 + volumes: + - /home/docker/redis:/data + ports: + - "16379:6379" + + # SD框架阿里云内网 registry.cn-hangzhou.aliyuncs.com/peterpang/dev + peter: + container_name: peter + image: registry-internal.cn-hangzhou.aliyuncs.com/peterpang/dev + links: + - mysql + - redis + volumes: + - /home/docker_user/peter:/var/www/html + ports: + - "10181:80" + - "10122:22" diff --git a/nginx-php7/files/root/entrypoint.sh b/nginx-php7/files/root/entrypoint.sh new file mode 100755 index 0000000..a16800a --- /dev/null +++ b/nginx-php7/files/root/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +chown -R www-data:www-data /var/www /var/log/php + +# init mysql db if necessary +if [ ! -d /var/lib/mysql/mysql ];then + mysqld --initialize-insecure --user=root --datadir=/var/lib/mysql +fi + +chown -R mysql:mysql /var/lib/mysql /var/run/mysqld + +exec /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf diff --git a/nginx-php7/files/root/etc/nginx/sites-enabled/default b/nginx-php7/files/root/etc/nginx/sites-enabled/default new file mode 100644 index 0000000..d377519 --- /dev/null +++ b/nginx-php7/files/root/etc/nginx/sites-enabled/default @@ -0,0 +1,37 @@ +server { + listen 80; + + index index.php; + + root /var/www/; + charset utf8; + + location / { + + gzip on; + try_files $uri/index.php $uri /index.php; + + if (!-f $request_filename) { + rewrite (.*) /index.php; + } + + } + + location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { + expires 30d; + gzip on; + } + + location ~ .*\.(js|css)?$ { + expires 1h; + + } + + # php fastcgi setting + location ~ \.php$ { + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/nginx-php7/files/root/etc/supervisor/conf.d/mysql.conf b/nginx-php7/files/root/etc/supervisor/conf.d/mysql.conf new file mode 100644 index 0000000..119b5d9 --- /dev/null +++ b/nginx-php7/files/root/etc/supervisor/conf.d/mysql.conf @@ -0,0 +1,3 @@ +[program:mysql] +command=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe +autorestart=true diff --git a/nginx-php7/files/root/etc/supervisor/conf.d/nginx.conf b/nginx-php7/files/root/etc/supervisor/conf.d/nginx.conf new file mode 100644 index 0000000..1fc1f7a --- /dev/null +++ b/nginx-php7/files/root/etc/supervisor/conf.d/nginx.conf @@ -0,0 +1,2 @@ +[program:nginx] +command=/usr/sbin/nginx -g "daemon off;" diff --git a/nginx-php7/files/root/etc/supervisor/conf.d/php-fpm.conf b/nginx-php7/files/root/etc/supervisor/conf.d/php-fpm.conf new file mode 100644 index 0000000..1a679d2 --- /dev/null +++ b/nginx-php7/files/root/etc/supervisor/conf.d/php-fpm.conf @@ -0,0 +1,2 @@ +[program:php-fpm] +command=/usr/sbin/php-fpm7.1 --nodaemonize --fpm-config /etc/php/7.1/fpm/php-fpm.conf diff --git a/nginx-php7/files/root/run/php/.gitkeep b/nginx-php7/files/root/run/php/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nginx-php7/files/root/var/log/php/cgi.log b/nginx-php7/files/root/var/log/php/cgi.log new file mode 100644 index 0000000..e69de29 diff --git a/nginx-php7/files/root/var/log/php/cli.log b/nginx-php7/files/root/var/log/php/cli.log new file mode 100644 index 0000000..e69de29 diff --git a/nginx-php7/files/root/var/run/mysqld/.gitkeep b/nginx-php7/files/root/var/run/mysqld/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nginx-php7/files/root/var/www/index.php b/nginx-php7/files/root/var/www/index.php new file mode 100644 index 0000000..c4837a3 --- /dev/null +++ b/nginx-php7/files/root/var/www/index.php @@ -0,0 +1 @@ +&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e[1;36m\]Docker|\[\e[0m\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then +# . /etc/bash_completion +#fi \ No newline at end of file diff --git a/phalcon-docker-nginx/build/nginx.conf b/phalcon-docker-nginx/build/nginx.conf new file mode 100644 index 0000000..987c991 --- /dev/null +++ b/phalcon-docker-nginx/build/nginx.conf @@ -0,0 +1,35 @@ +server { + + listen 80 default_server; + + root /var/www/public/; + index index.php index.html index.htm; + + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?_url=$uri&$args; + } + + location = /favicon.ico { log_not_found off; access_log off; } + location = /robots.txt { access_log off; log_not_found off; } + + error_page 404 /index.php; + + # pass the PHP scripts to php7.0-fpm + # Note: \.php$ is susceptible to file upload attacks + # Consider using: "location ~ ^/(index|app|app_dev|config)\.php(/|$) {" + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + fastcgi_param HTTPS off; + } + + # Deny .htaccess file access + location ~ /\.ht { + deny all; + } +} \ No newline at end of file diff --git a/phalcon-docker-nginx/build/php.ini b/phalcon-docker-nginx/build/php.ini new file mode 100644 index 0000000..c5814df --- /dev/null +++ b/phalcon-docker-nginx/build/php.ini @@ -0,0 +1,2 @@ +[Date] +date.timezone=America/Sao_Paulo \ No newline at end of file diff --git a/phalcon-docker-nginx/build/supervisord.conf b/phalcon-docker-nginx/build/supervisord.conf new file mode 100644 index 0000000..606cca4 --- /dev/null +++ b/phalcon-docker-nginx/build/supervisord.conf @@ -0,0 +1,16 @@ +[supervisord] +nodaemon=true + +[program:php-fpm] +command=php-fpm7.0 -F +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:nginx] +command=nginx -g 'daemon off;' +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file diff --git a/phalcon-docker-nginx/docker-compose.yml b/phalcon-docker-nginx/docker-compose.yml new file mode 100644 index 0000000..de220fa --- /dev/null +++ b/phalcon-docker-nginx/docker-compose.yml @@ -0,0 +1,18 @@ +version: '2' + +services: + phalcon: + image: 27tech/phalcon + ports: + - "9000:9000" + volumes: + - /home/docker_user/peter:/var/www/html + + nginx: + image: richarvey/nginx-php-fpm + links: + - phalcon:php + ports: + - "8080:80" + volumes: + - /home/docker_user/peter:/var/www/html \ No newline at end of file diff --git a/phalcon-docker-nginx/shell.bash b/phalcon-docker-nginx/shell.bash new file mode 100644 index 0000000..1638f41 --- /dev/null +++ b/phalcon-docker-nginx/shell.bash @@ -0,0 +1,111 @@ +#!/bin/bash +appname="phalcon-docker-nginx" +host="user@host" + +echo $1 $2 + +run() { + echo "docker run \ + $env \ + --name=$appname \ + -p 8888:80 \ + $mode \ + --restart=unless-stopped $appname" +} + +if [ $1 == "local" ] + then + + env="-e ENV_PROD=0" + + mode="-it" + + if [ $2 == "deploy" ] + then + + if [ $3 == "daemon" ] + then + mode="-d" + fi + + docker build -t $appname . + docker stop $appname + docker rm $appname + eval $(run) + + fi + + if [ $2 == "stop" ] + then + docker stop $appname + fi + + if [ $2 == "exec" ] + then + docker exec -it $appname $3 + fi + + if [ $2 == "shell" ] + then + docker exec -it $appname bash + fi + + if [ $2 == "start" ] + then + docker start $appname + fi + + if [ $2 == "logs" ] + then + docker logs -f $appname + fi +fi + +if [ $1 == "remote" ] + then + + env="-e ENV_PROD=1" + + mode="-it" + + if [ $2 == "deploy" ] + then + ssh -tt $host "mkdir $appname && cd $appname && sudo chmod 777 * -R" + rsync --progress --exclude-from '.deployignore' -avz -e "ssh" . $host:$appname + ssh -tt $host "cd $appname && docker build -t $appname ." + ssh -tt $host "cd $appname && docker stop $appname" + ssh -tt $host "cd $appname && docker rm $appname" + + if [ $3 == "daemon" ] + then + mode="-d" + fi + + ssh -tt $host "cd $appname && $(run)" + fi + + if [ $2 == "stop" ] + then + ssh -tt $host "docker stop $appname" + fi + + if [ $2 == "exec" ] + then + ssh -tt $host "docker exec -it $appname $3" + fi + + if [ $2 == "start" ] + then + ssh -tt $host "cd $appname && docker start $appname" + fi + + if [ $2 == "shell" ] + then + docker exec -it $appname bash + fi + + if [ $2 == "logs" ] + then + ssh -tt $host "docker logs -f $appname" + fi +fi \ No newline at end of file diff --git a/phalcon-docker-nginx/src/index.php b/phalcon-docker-nginx/src/index.php new file mode 100644 index 0000000..3d09c0f --- /dev/null +++ b/phalcon-docker-nginx/src/index.php @@ -0,0 +1,22 @@ +get( + "/", + function () { + echo "