Code Monkey home page Code Monkey logo

docker-dev-environment's Introduction

Docker-based development environment

Features

  • PHP 7.1 + Nginx + Composer, Bower, NPM (for newer projects)
  • PHP 5.4 + Apache (for older projects)
  • Node.js 7
  • MongoDB
  • MySQL (MariaDB)
  • Redis

You can run docker-compose on your local machine, but I recommend to run it within virtual machine, in this way it will not interfere with your host machine setup.

Prerequisites

...or Docker on your host machine.

Note: If you using Vagrant with VirtualBox - it is recommended to install VirtualBox guest additions plugin:

vagrant plugin install vagrant-vbguest

Install and run

  • Checkout repository or download and unpack ZIP archive
  • Run vagrant up from project directory. Vagrant will create a virtual machine, assign it ip 192.168.55.55 and install Docker. This step may take some time for first time (depending on your host machine performance and network bandwidth) since Docker needs to download base images and build custom ones)
  • Meanwhile you need to add test domains to your hosts file
192.168.55.55 php7nginxHost.local
192.168.55.55 php54apacheHost.local
192.168.55.55 nodeWelcomeApp.local
  • Open one of the URLs

  • Please, note

    • You may need to restart your browser
    • If you typing in URLs manually, first time a browser may require to type in http:// explicitly
  • Add more PHP projects to Nginx or Apache config folders or Node apps to docker-compose.yml file or customize Node image.

To check containers - login to virtual machine - run vagrant ssh from project dir, then run docker ps. To see logs run docker logs -f <container-name>

Notes

MySQL

MySQL host is mariadb (within Docker containers) and root password is 12345 by default, chnage it right away

MongoDB

Auth is enabled

When container is ready - manually create userAdminAnyDatabase user using Localhost Exception

https://docs.mongodb.com/manual/tutorial/enable-authentication/

And then users for databases

https://docs.mongodb.com/manual/tutorial/create-users/

TL;DR

mongo

use admin

db.createUser({ user: 'admin', pwd: '<password>', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });

mongo -u admin -p <password> --authenticationDatabase admin

use <db-name>

db.createUser({
	user: "<user-name>",
	pwd: "<userPassword>",
	roles: [
	   { role: "readWrite", db: "<db-name>" }
	]
});

Data

MySQL and MongoDB data folders are mounted to ~/docker-data/ on a host machine (or VM, in case of Vagrant/VirtualBox).

Shared folders speed

If you concerned about shared folders speed (honestly, you should be) use NFS for sharing your folders.

For example (making default folder available in VM under /vagrant_nfs):

config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant_nfs", type: "nfs"

Someone may say that it will not work on Windows (since Vagrant official site says so) but it is not true, it woks with winnfsd plugin.

docker-dev-environment's People

Contributors

jazzfog avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

pavlopx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.