Permalink
Browse files

Setup of the project with Docker

  • Loading branch information...
nielsvandermolen committed Jun 11, 2018
1 parent b23de32 commit 9c5b1e9f672855e833f6e055c96de5a3198acd49
Showing with 82 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 Dockerfile-mysql
  3. +3 −0 Dockerfile-nginx
  4. +11 −0 Dockerfile-php
  5. +1 −0 README.md
  6. +24 −0 build/nginx/default.conf
  7. +41 −0 docker-compose.yml
@@ -0,0 +1 @@
.idea/
@@ -0,0 +1 @@
FROM mysql:5.6
@@ -0,0 +1,3 @@
FROM nginx:latest
COPY build/nginx/default.conf /etc/nginx/conf.d/
COPY . /var/www/project
@@ -0,0 +1,11 @@
FROM php:fpm
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
zlib1g-dev \
libxml2-dev \
&& docker-php-ext-install \
pdo_mysql \
zip
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
COPY . /var/www/project
WORKDIR /var/www/project/
@@ -0,0 +1 @@
See blog article
@@ -0,0 +1,24 @@
server {
listen 80;
root /var/www/project/public;

location / {
try_files $uri /index.php$is_args$args;
}

location ~ ^/index\.php(/|$) {
# Connect to the Docker service using fpm
fastcgi_pass fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}

error_log /dev/stdout info;
access_log /var/log/nginx/project_access.log;
}
@@ -0,0 +1,41 @@
version: "3"

services:
fpm:
build: # Info to build the Docker image
context: . # Specify where the Dockerfile is located (e.g. in the root directory of the project)
dockerfile: Dockerfile-php # Specify the name of the Dockerfile
environment: # You can use this section to set environment variables. But you can also use the .env file.
- DATABASE_URL=mysql://root:root@db:3306/project_db # Connection string for the database.
volumes:
- ./project/:/var/www/project/ # Location of the project for php-fpm. Note this should be the same for NGINX.
networks:
- symfony # Docker containers (services) that need to connect to each other should be on the same network.

nginx:
build:
context: .
dockerfile: Dockerfile-nginx
volumes:
- ./project/:/var/www/project/
ports:
- 8001:80 # Ports that are exposed, you can connect to port 8001 to port 80 of the container.
networks:
- symfony

db:
image: mysql:5.6
environment:
- MYSQL_ROOT_PASSWORD=root # Setting the MYSQL credentials to root:root.
volumes:
- symfony_db:/var/lib/mysql:cached # Persist the database in a Docker volume.
ports:
- 3311:3306
networks:
- symfony

volumes:
symfony_db:

networks:
symfony:

0 comments on commit 9c5b1e9

Please sign in to comment.