Build a local tiny Virtual Machine which allows you to run Miaou on any OS (including Windows/OS X)
Requirements (for Windows/OS X users only, Linux can run Docker on its own)
- Docker-machine (version 0.3.0+) => an executable to rename
docker-machine
and to move somewhere in yourPATH
- VirtualBox
A simple yet powerful script that use Docker Machine to build a local Docker aware VM (it uses boot2docker in the background).
It's also used to set some useful aliases in the VM (such asdocker-compose
which run Docker Compose in a container).
- Miscellaneous useful Ubuntu packages
- Ruby and
sass
- IOJS with
nodemon
,uglify-js
andbuster
globally installed
This file is the default ENTRYPOINT of the image. It will be executed every time you run the Miaou container. This is where you should put all your project specific stuff (e.g. run services, run a Makefile, etc.).
This file (using Docker Compose) is the recommended way to build the whole environment. It will run and link several containers through a single command.
Keep in mind that this could also be done using many long docker
commands without the need of docker-compose
at all.
-
Go to the docker directory
cd /path/to/miaou/docker
and typedocker-machine-dev
(if on Windows) or./docker-machine-dev.sh
(if on OS X). If you followed the Requirements above, after a few seconds you will be landed in the VM where you will be able to rundocker
commands. -
Now that you are in your VM, you can build the image
docker-compose
with:docker build -t docker-compose github.com/docker/compose
At this point, you should be able to run docker-compose
which is an alias picked from docker-machine-dev
script.
-
Then, again,
cd
to the docker directory (the VM shared yourC:\Users\
(windows) or/Users/
(os x) folder as/c/Users/
or/Users/
--- see complete reference here). -
Build and run the whole Miaou environment with:
docker-compose run miaou
It will leave you in the Miaou container at /var/www/html
where you will be able to manage everything like if you were on a server with everything installed.
If you exit
this container, it will be stopped then you'll have 2 solutions to come back in it:
- Remove the container with docker rm docker_miaou_run_1
then run it again with docker-compose run miaou
- Restart the container with docker start docker_miaou_run_1
then execute bash
in it with docker exec -it docker_miaou_run_1 bash
-
Once you have all the containers running, you'll have to create all the tables in your database. The whole database is running in its own container. In order to be able to run SQL commands, type
docker exec -it docker_postgres_1 psql -U miaou -w
. Now that you have a prompt formiaou
psql user, copy/paste the content of the SQL creation file located atsql/postgres.creation.sql
in Miaou sources, then exit the container with\q
. -
Copy the
docker/config.js
preconfigured file to the root of the Miaou sources. -
Now to be able to log in Miaou, you have to set a OAuth provider (here we'll use Google which is really easy to configure). First, go to
https://console.developers.google.com/project
, create a new project, then go toAPIs & auth
>Credentials
toCreate new OAuth Client ID
. SelectWeb application
as Application type, sethttp://miaou.dev
as Authorized Javascript origins andhttp://miaou.dev/auth/google/callback
as Authorized redirect URIs. Now you'll be given a Client ID and a Client secret that you'll have to copy/paste in theconfig.js
file. -
Go back to the Miaou container (see step 4. if you exited the container) then fetch all Miaou dependencies and build assets:
npm install
make
-
At this point, you should be able to start Miaou, so run the application with
nodemon main.js
(thanks to nodemon, the server will restart automatically after each file modification). -
Finally, update your own hosts file (e.g.
C:\Windows\System32\drivers\etc\hosts
on Windows) to bind the VM IP address tomiaou.dev
. You can check the VM IP by runningdocker-machine ip dev
in your host terminal. Typically, it should be192.168.99.100
. So add this line to your hosts file:192.168.99.100 miaou.dev
Now you should see your Miaou application running in your host browser at miaou.dev
.
When you want to stop contribute to Miaou, exit
your VM then stop it with docker-machine stop dev
.
# Host terminal
cd C:\Users\myMiaouSources\docker
docker-machine-dev
# VM terminal
cd /c/Users/myMiaouSources/docker
docker-compose run miaou
# Miaou container
nodemon main.js
This issue comes from your application shared folders, vboxsf
seems to be not powerful enough to handle so many files.
There are currently 2 workarounds for this kind of issue:
- In your Miaou container, copy the
package.json
file to another (not shared) directory. Runnpm install
there. Then copy back the newnode_modules
directory to the root of Miaou sources.
or
- Run
npm install
on your host machine (it requires you to havenpm
already installed on your host of course).