Giter Site home page Giter Site logo

spkorhonen / vanilla-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vanilla/vanilla-docker

0.0 1.0 0.0 2.14 MB

A sweet Docker setup for Vanilla Forums

License: MIT License

Shell 2.29% PHP 19.98% Smarty 0.70% Dockerfile 1.06% Python 75.98%

vanilla-docker's Introduction

Vanilla Docker environment

Only supports Mac OSX at the moment but everything can be easily adapted to work on other platforms. Assume that you are using PhpStorm as your IDE.

This repository contains a ready-for-development environment to develop against Vanilla.

The containers

perconadb / mariadb

SQL database.

  • Accessible from the container with the hosts "database".
  • Accessible from the docker host machine with the hosts "database", "localhost", "127.0.0.1'
  • The user is "root" and there is no password.

Defaults to perconadb. To change that set the environment variable VANILLA_DOCKER_DATABASE to mariadb in your .bash_profile.

httpd

Apache 2 web server.

nginx

nginx web server

php-fpm

php-fpm with PHP 7.3

Sphinx

Sphinx search service (service-sphinx.yml).

Installing Sphinx

Before enabling make sure that:

  • Your database is named vanilla_dev
  • You have set Plugins.Sphinx.Server = sphinx in your config
  • You have set Plugins.Sphinx.SphinxAPIDir = /sphinx/ in your config
  • You have enabled the sphinx plugin
  • You symlinked one of the configs-available as sphinx.conf in resources/usr/local/etc/sphinx/conf.d
  • Example from conf.d/: ln -s configs-available/standard.sphinx.conf sphinx.conf
  • For unit tests use the everything.sphinx.conf

Sphinx unit testing config

  • Ensure you have a test database vanilla_test.
  • Ensure you are using the everything.sphinx.conf config for sphinx.
  • Ensure that your phpunit.xml and phpunit.dist.xml have the following environmental value: <env name="TEST_SPHINX_HOST" value="sphinx" />

Re-indexing your database

There are a couple of handly scripts to run the re-indexer. You can run them from the command line like so:

docker exec -t sphinx bash /root/index.delta.sh
docker exec -t sphinx bash /root/index.all.sh

Installing the Sphinx indexr crontab

If you need to have Sphinx indexes updated regularly run install-sphinx-cron.sh.

  • by default it will reindex delta indexes every minute and reindex all indexes every 5 min.
  • by default cron jobs hit sphinx container
  • if your environment or tasked to be different you need to change install-sphinx-cron.sh accordingly

Note that the easiest way to run this script is through docker:

docker exec -t sphinx bash /root/install-sphinx-cron.sh

Setup

For this setup to work properly you need to clone all vanilla repositories in the same base directory

  1. Get Docker for OSX and install it.

    • Do not forget to tune up the allocated Memory and CPUs. Docker > Preferences > Advanced
  2. Get Brew, Yarn & Node

  3. Get Composer and install it.

  4. Create a directory for your project. In this example, we'll use my-vanilla-project, but you can use any name.

  5. Move into your project directory.

  6. Clone or download vanilla/vanilla-docker into your project directory.

  7. Clone or download vanilla/vanilla into your project directory.

  8. Clone or download any other project dependencies into your project directory (for example, any of vanilla/addons), and install according to their instructions. Note: All addons, plugins, themes, etc, must be located in the project directory. Everything outside of the project directory will not be made available inside of the Docker container.

  9. You should have the following structure

    my-vanilla-project
    ├── vanilla
    ├── vanilla-docker
    ├── ...
    
  10. Move into the vanilla directory.

  11. Run composer install which will install Vanilla's dependencies.

  12. Move up and over into the vanilla-docker directory.

  13. Run sudo ./mac-setup.sh which will:

    • Add a self signed certificate *.vanilla.localhost to your keychain.
    • Safely update your /etc/hosts.
    • Add 192.0.2.1 as a loopback IP address.
    • Create a docker volume named "datastorage" which will contain the database data.
  14. Run docker-compose up --build (It will take a while the first time). You'll know it worked if you see something like

    Successfully built…
    Successfully tagged…
    Creating database ... done
    Creating php-fpm  ... done
    Creating httpd    ... done
    Creating nginx    ... done
    Attaching to database, php-fpm, httpd, nginx
    …
    php-fpm     | done.
    

    and voila -> dev.vanilla.localhost shows the Vanilla installer.

  15. Run the installer!

    • It is recommended to use vanilla_dev as the database name since some services are configured to use that database.
    • It is recommended to use database for the host name.
    • It is recommended to use root as the username.

To properly stop the containers you need to run docker-compose down.

Do not forget to run docker-compose up --build to start up the services every time you restart your computer.

Running optional services

To run additional services (named service-*.yml) you can specify which .yml file to run like so:

docker-compose -f docker-compose.yml -f docker-compose.override.yml -f service-sphinx.yml up --build

You can add as many services as you want that way. You can create a script named custom.boot.sh, with the combination of services that you want, so that it is easier to start the services that you want.

Generally, there should be documentation inside the .yml file of the service that gives you information about it.

For more information: understanding-multiple-compose-files

Using your local database

To start all containers except the database one you can use:

docker-compose -f docker-compose.yml up --build

This will skip docker-compose.override.yml. Note that by doing so you will probably have to add additional configurations to make sure that the database is reachable from the containers.

To address that issue you have 2 ways of doing it:

  • You always have the possibility of using the loopback ip 192.0.2.1 that is installed by the mac-setup.sh script if your database is installed directly on your machine.
  • You can also create custom.*.yml file to extends the existing services and add extra-hosts to the services. Example: custom.dbhost.yml
    version: "3"
    
    services:
        php-fpm:
            extra_hosts:
                database: 192.0.2.1
    
    You can then do:
    docker-compose -f docker-compose.yml -f custom.dbhost.yml up --build

You can also delete the datastorage volume created by mac-setup.sh since you won't be using it.

Xdebug

See Make Xdebug work with PhpStorm.

Unit tests

See Make unit tests work within PhpStorm.

F.A.Q

Q. Why is everything so slow?

A. You are probably running on the APFS file system that became the standard with macOS High Sierra and which has pretty bad performance with Docker for Mac. Having the database on your host instead of inside docker might help a lot. See #10.

vanilla-docker's People

Contributors

daazku avatar charrondev avatar alex-mtl avatar initvector avatar tburry avatar danni-stark avatar linc avatar cchabilall83 avatar jreko avatar olets avatar alexbrohman avatar evach-vf avatar nervoustwit avatar

Watchers

James Cloos avatar

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.