From 04c1b1d307adee4717061aa69a6a84ecdc9e1e8e Mon Sep 17 00:00:00 2001 From: Yoann Lecuyer Date: Wed, 11 May 2016 18:15:54 -0500 Subject: [PATCH] Docker dev environment (#90) --- .env.example | 18 +++++++++--------- Dockerfile-nginx | 2 ++ Dockerfile-php | 13 +++++++++++++ config/app.php | 2 +- docker-compose.yml | 31 +++++++++++++++++++++++++++++++ nginx.conf | 19 +++++++++++++++++++ readme.md | 18 ++++++++++++++++++ 7 files changed, 93 insertions(+), 10 deletions(-) create mode 100644 Dockerfile-nginx create mode 100644 Dockerfile-php create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/.env.example b/.env.example index 16b673c6..5aceaa85 100644 --- a/.env.example +++ b/.env.example @@ -2,19 +2,19 @@ APP_ENV=production APP_DEBUG=false APP_URL= APP_CIPHER=rijndael-128 -APP_KEY=SomeRandomString +APP_KEY= APP_TIMEZONE -DB_TYPE=mysql -DB_HOST=localhost +DB_TYPE=pgsql +DB_HOST=db DB_DATABASE=attendize -DB_USERNAME= -DB_PASSWORD= +DB_USERNAME=attendize +DB_PASSWORD=attendize MAIL_DRIVER=smtp -MAIL_PORT=587 -MAIL_ENCRYPTION=tls -MAIL_HOST= +MAIL_PORT=25 +MAIL_ENCRYPTION= +MAIL_HOST=maildev MAIL_FROM_ADDRESS= MAIL_FROM_NAME= MAIL_PASSWORD= @@ -24,4 +24,4 @@ GOOGLE_ANALYTICS_ID= TWITTER_WIDGET_ID= -LOG=single \ No newline at end of file +LOG=errorlog diff --git a/Dockerfile-nginx b/Dockerfile-nginx new file mode 100644 index 00000000..8fe57077 --- /dev/null +++ b/Dockerfile-nginx @@ -0,0 +1,2 @@ +FROM nginx:latest +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/Dockerfile-php b/Dockerfile-php new file mode 100644 index 00000000..694d53f6 --- /dev/null +++ b/Dockerfile-php @@ -0,0 +1,13 @@ +FROM php:fpm +RUN apt-get update && apt-get install -y \ + libpq-dev \ + libmcrypt-dev \ + libpng12-dev \ + libjpeg62-turbo-dev \ + libfreetype6-dev \ + libxrender1 \ + libfontconfig \ + libxext-dev \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) pdo_pgsql pgsql mcrypt gd zip +WORKDIR /usr/share/nginx/html/attendize diff --git a/config/app.php b/config/app.php index b4878922..86f42166 100644 --- a/config/app.php +++ b/config/app.php @@ -107,7 +107,7 @@ return [ | */ - 'log' => 'daily', + 'log' => env('LOG', 'daily'), /* |-------------------------------------------------------------------------- diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8bd849e0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +web: + build: . + dockerfile: Dockerfile-nginx + ports: + - "8080:80" + links: + - php + volumes: + - .:/usr/share/nginx/html/attendize +php: + build: . + dockerfile: Dockerfile-php + links: + - db + - maildev + volumes: + - .:/usr/share/nginx/html/attendize +db: + image: postgres + environment: + - POSTGRES_USER=attendize + - POSTGRES_PASSWORD=attendize + - POSTGRES_DB=attendize + ports: + - "5433:5432" + volumes: + - ./docker/pgdata:/var/lib/postgresql/data +maildev: + image: djfarrelly/maildev + ports: + - "1080:80" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..c7c665b0 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +server { + listen 80 default_server; + server_name localhost; + + root /usr/share/nginx/html/attendize/public; + index index.php; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass php:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + +} diff --git a/readme.md b/readme.md index 85490280..da758a9a 100644 --- a/readme.md +++ b/readme.md @@ -57,6 +57,24 @@ Limited Documentation available at https://www.attendize.com/documentation.php. Feel free to fork and contribute. I could use the help! +## Docker dev environment + +To run a docker dev entionment do the following: + +``` +git clone https://github.com/Attendize/Attendize +cd Attendize +cp .env.example .env +docker-compose build +docker run --rm -v $(pwd):/app composer/composer install +docker-compose up +docker-compose run php php artisan attendize:install +chmod a+w -R storage +chmod a+w -R public/user_content +``` + +Attendize will be available at `http://localhost:8080` and maildev at `http://localhost:1080` + ## License Attendize is open-sourced software licensed under the Attribution Assurance License