├── LICENSE ├── README.md ├── docker-compose.yml ├── nginx ├── Dockerfile └── nginx.conf ├── php └── Dockerfile └── sqlserver └── Dockerfile /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Edson Horácio Junior 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Docker-compose with PHP, SQL Server & Nginx 2 | -- 3 | 4 | Start containers 5 | ``` 6 | $ docker-compose up 7 | ``` -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | app: 5 | build: ./php 6 | volumes: 7 | - ./../:/var/www/html/my-site 8 | depends_on: 9 | - sqlserver 10 | working_dir: /var/www/html/my-site 11 | 12 | nginx: 13 | build: ./nginx 14 | restart: always 15 | depends_on: 16 | - app 17 | ports: 18 | - 8008:80 19 | volumes_from: 20 | - app 21 | 22 | sqlserver: 23 | build: ./sqlserver 24 | hostname: 'sqlserver' 25 | environment: 26 | ACCEPT_EULA: Y 27 | MSSQL_SA_PASSWORD: Admin@12345 28 | ports: 29 | - 1433:1433 30 | volumes: 31 | - ms-sqlserver-data:/var/opt/mssql 32 | 33 | volumes: 34 | ms-sqlserver-data: 35 | driver: local -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx 2 | 3 | COPY nginx.conf /etc/nginx/conf.d/default.conf -------------------------------------------------------------------------------- /nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default; 3 | 4 | root /var/www/html/my-site; 5 | index default.php; 6 | 7 | client_max_body_size 108M; 8 | gzip_static on; 9 | 10 | location / { 11 | if (!-e $request_filename) { 12 | rewrite ^.*$ /index.php last; 13 | } 14 | } 15 | 16 | location ~ \.php$ { 17 | fastcgi_pass app:9000; 18 | fastcgi_index index.php; 19 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 20 | fastcgi_param PHP_VALUE "error_log=/var/log/nginx/my-site_php_errors.log"; 21 | fastcgi_buffers 16 16k; 22 | fastcgi_buffer_size 32k; 23 | include fastcgi_params; 24 | } 25 | 26 | #access_log /var/www/html/my-site/log/access.log; 27 | error_log /var/www/html/my-site/log/error.log; 28 | } -------------------------------------------------------------------------------- /php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-fpm 2 | 3 | # Get repository and install wget and vim 4 | RUN apt-get update && apt-get install -y \ 5 | wget \ 6 | apt-utils \ 7 | gnupg \ 8 | software-properties-common \ 9 | apt-transport-https \ 10 | libxml2-dev \ 11 | unixodbc-dev 12 | 13 | # necessário para sqlsrv 14 | RUN wget -qO - https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ 15 | && wget -qO - https://packages.microsoft.com/config/debian/9/prod.list \ 16 | > /etc/apt/sources.list.d/mssql-release.list 17 | 18 | # Install PHP extensions deps 19 | RUN apt-get update \ 20 | && apt-get install --no-install-recommends -y \ 21 | libfreetype6-dev \ 22 | libjpeg62-turbo-dev \ 23 | libmcrypt-dev \ 24 | libpng-dev \ 25 | zlib1g-dev \ 26 | libicu-dev \ 27 | g++ \ 28 | unixodbc-dev \ 29 | && ACCEPT_EULA=Y apt-get install --no-install-recommends -y msodbcsql17 mssql-tools \ 30 | && apt-get install --no-install-recommends -y libxml2-dev \ 31 | libaio-dev \ 32 | libmemcached-dev \ 33 | freetds-dev \ 34 | libssl-dev \ 35 | openssl \ 36 | supervisor 37 | 38 | # Install PHP extensions 39 | RUN pecl install sqlsrv pdo_sqlsrv 40 | 41 | # PRA VER SE TEM ALGUM BUG NO PHP 42 | # RUN php -i | grep "Configure Command" 43 | 44 | RUN docker-php-ext-install \ 45 | iconv \ 46 | mcrypt \ 47 | sockets \ 48 | pdo \ 49 | pdo_mysql \ 50 | && docker-php-ext-enable \ 51 | sqlsrv \ 52 | pdo_sqlsrv 53 | 54 | # Clean repository 55 | RUN apt-get autoremove -y && \ 56 | apt-get clean && \ 57 | rm -rf /var/lib/apt/lists/* -------------------------------------------------------------------------------- /sqlserver/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/mssql-server-linux:2017-latest --------------------------------------------------------------------------------