Sign inSign up

radmas/mtc-plus-application

By radmas

Updated about 5 years ago

Symfony2 Backoffice dependencies for Improve Your City.

Image
0

6.0K

radmas/mtc-plus-application repository overview

MTC-PLUS docker-compose

Detailed guide for noobs

1. Install Linux. It must be Ubuntu 16.04 based.
  • User: radmas
  • Password: r4dm4s

Run sudo visudo

Add at the end of document: radmas ALL=(ALL:ALL) NOPASSWD:ALL

Run sudo apt-get install git curl vim guake terminator

2. Install zsh and oh-my-zsh
sudo apt install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Install zsh plugins (optional):

  • Edit $HOME/.zshrc
  • Search for plugins=()
  • Add git, wd, ruby and any plugins you want: plugins=(git wd ruby)
3. Install the dependency managers: RVM, NVM.

For RVM:

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source $HOME/.zshrc

Then, configure your shell as a login shell and install RVM:

rvm install 2.3
rvm use ruby-2.3 --default
gem install bundle

For NVM:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

...And add this lines to .zshrc:

echo "export NVM_DIR=\"$HOME/.nvm\"" >> $HOME/.zshrc
echo "[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\"" >> $HOME/.zshrc
source $HOME/.zshrc

Install node 0.12.17 with nvm install 0.12.17

Install npm with sudo apt install npm

Install grunt-cli with sudo npm install -g grunt-cli

4. Install docker.
sudo apt-get update
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
sudo apt-get update
sudo apt-get install -y docker-engine
sudo usermod -aG docker $(whoami)
Restart your system
5. Install docker-compose.
  • Run sudo su
  • Go to the docker-compose github repository and follow the steps.
  • Return to radmas user acount running exit
EXAMPLE:
curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
6. Install Google Chrome.
7. Setup your SSH keys and repository access into Bitbucket.org

Generate your SSH keys: Open a terminal and run ssh-keygen -t rsa -b 4096 -C "[email protected]"

Example:

nacho@nacho-mint ~ $ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/nacho/.ssh/id_rsa): 
Created directory '/home/nacho/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/nacho/.ssh/id_rsa.
Your public key has been saved in /home/nacho/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:C539VfCLc0H0HTdbdE2u+YU7GiOiMUsMjYt3axhM6Ro [email protected]
The key's randomart image is:
+---[RSA 4096]----+
|              oBB|
|              .+@|
|     .         o*|
|    oo . o    .=o|
|   +o o S .  o=o.|
|  E.++ . . . .oo.|
|  .ooo* o . + o .|
|  ...o.* . . + . |
|     .+     .    |
+----[SHA256]-----+

Add your entity to ssh-agent: ssh-add ~/.ssh/id_rsa:

nacho@nacho-mint ~/.ssh $ ssh-add ~/.ssh/id_rsa
Identity added: /home/nacho/.ssh/id_rsa (/home/nacho/.ssh/id_rsa)

Add your public key (id_rsa.pub) to Bitbucket: profile->bitbucket settings->ssh keys

To get the id_rsa.pub contents, run cat $HOME/.ssh/id_rsa.pub

8. Configure your git global username and email.
git config --global user.name "Your Name"
git config --global user.email [email protected]
9. Clone the mtc-plus-docker repository
  • Run mkdir -p $HOME/dev/radmas && cd $HOME/dev/radmas
  • Run git clone [email protected]:radmas/mtc-plus-docker.git
  • Run cd $HOME/dev/radmas/mtc-plus-docker
10. Clone iyc-open010 repository
  1. Clone the iyc git repository in $HOME/dev/radmas/mtc-plus-docker/code/mtc_dev running cd $HOME/dev/radmas/mtc-plus-docker/code && git clone [email protected]:radmas/iyc-open010.git mtc_dev
  2. Add a bin/vars.cfg file starting from the bin/vars.cfg.tpl template. You can use cp vars.cfg.tpl vars.cfg && sed -i 's/vfernando/vhost/g' vars.cfg replacing vhost with your own.
  3. Execute the configuration script in bin/create_aliases. It will add some aliases in your $HOME/.zshrc file
  4. Run source $HOME/.zshrc
  5. Run cd ../code/mtc_dev and then bundle install
  6. Start your environment with mtc-compose up -d
  7. Finally, run rake
  8. Visit mtc.v<<developer>>.lan in your browser. (Your domain must be configured in DNS server, ask your administrator)

Note: If you just want to use the project in your system and not in a network, you can add your address to /etc/hosts running echo "127.0.0.1 mtc.<<your_vhost>>.lan" | sudo tee --append /etc/hosts

It should work!

11. Add warp points to key locations in project (optional)
  • Docker folder: cd $HOME/dev/radmas/mtc-plus-docker && wd add docker
  • Code folder: cd $HOME/dev/radmas/mtc-plus-docker/code/mtc_dev && wd add mtc_dev
12. Install Mongobooster or a Mongo Client of your choice.
  • Connect to localhost:27018
13. Install PHPStorm.
  • Download tar, unzip and read Install-Linux-tar.txt
  • Optional: Add phpstorm.sh to PATH
  • Optional (recomended): select Create desktop entry for all users (you can do this later)
  • Don't open a project just yet.
  • Configure your favourite color scheme.
14. Configure PHP Storm
  • Open the project located on /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev

  • Exclude cache and logs directories in apps/mtc/ and apps/open010 with right clic => Mark Directory As/Excluded

  • Exclude apps/tools/coverage directory with right clic => Mark Directory As/Excluded

  • Install Plugins in File/Settings/Plugins, Browse Repositories: Symfony Plugin and PHP Annotations

    • Configure Symfony Plugin:
      • Enable plugin for this project in File/Settings/Languages&Frameworks/PHP/Symfony
      • Configure translations path to src/Radmas/Open010Bundle/Resources/translations
      • Configure app directory to apps/mtc
      • Configure Container in File/Settings/Languages&Frameworks/PHP/Symfony/Container to:
        • apps/mtc/cache/dev/mtcDevDebugProjectContainer.xml
        • apps/open010/cache/dev/open010DevDebugProjectContainer.xml
      • Configure Routing in File/Settings/Languages&Frameworks/PHP/Symfony/Routing to:
        • apps/mtc/cache/dev/mtcDevUrlGenerator.php
        • apps/open010/cache/dev/open010DevUrlGenerator.php
  • Exclude angular-modules directories from project in File/Settings/Directories

  • Configure PHP remote interpreter

    • Open File/Settings/Languages&Frameworks/PHP
    • Configure CLI Interpreter as a new Remote interpreter, with the following SSH Credentials:
      • Host: localhost
      • Port: 2322
      • User name: radmas
      • Password: d0ck3r (save password)
  • Configure Deployment options for docker

    • Add Server in File/Settings/Build, Execution, Deployment/Deployment
      • Name : v<<developername>>-docker, Type: SFTP
      • Configure server Connection:
        • SFTP Host: localhost
        • Port: 2322
        • Root path: /
        • User name: radmas
        • Password: d0ck3r (save password)
        • (Tests connection)
      • Configure server Mappings:
        • Local Path: /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev
        • Deployment path on server: /var/www/mtc_dev/
        • Web path on server: /var/www/mtc_dev/web
  • Configure XDebug

    • Add new Server In File/Settings/Languages&Frameworks/PHP/Servers
      • Name: v<<developername>>.lan
      • Host: v<<developername>>.lan
      • Port: 80
      • Debugger: Xdebug
      • Use path mappings: true
        • /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev --> /var/www/mtc_dev
        • /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev/src --> /var/www/mtc_dev/src
        • /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev/web --> /var/www/mtc_dev/web
  • Configure Phpunit

    • Add new Configuration "By remote interpreter" In File/Settings/Languages&Frameworks/PHP/PHPUnit
      • CLI Interpreter: The one previously configured (Remote)
      • Path mappings: <Project root> -> /var/www/mtc_dev
      • Use composer autoloader (Path to script: /var/www/mtc_dev/apps/shared/autoload.php)
      • Default configuration file: /var/www/mtc_dev/apps/mtc/phpunit.xml
      • Default bootstrap file: /var/www/mtc_dev/apps/shared/bootstrap.php.cache
  • Configure External tools:

    • Configure new Clean Fixtures Tool in File/Settings/Tools/External Tools:

      • Name: Clean Fixtures with rake
      • Group: External Tools
      • Check all checkboxes
      • Program: rake
      • Parameters: fixtures:clean[test]
      • Working directory: $ProjectFileDir$
    • Configure new Load Fixtures Tool in File/Settings/Tools/External Tools:

      • Name: Load Fixtures with rake
      • Group: External Tools
      • Check all checkboxes
      • Program: rake
      • Parameters: fixtures:load[test]
      • Working directory: $ProjectFileDir$
  • Configure Project Tests

    • Add new PHPUnit configuration in Run/Edit configurations
      • Name: BO tests
      • Defined in the configuration file (Use alternative configuration file: /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev/apps/mtc/phpunit.xml)
      • Before launch: Select External tool 'External Tools/Load Fixtures with rake'
    • Add new PHPUnit configuration in Run/Edit configurations
      • Name: Open010 tests
      • Defined in the configuration file (Use alternative configuration file: /home/radmas/dev/radmas/mtc-plus-docker/code/mtc_dev/apps/open010/phpunit.xml)
      • Before launch: Select External tool 'External Tools/Load Fixtures with rake'
  • Configure Grunt

    • Open Grunt Settings
    • Select Node Interpreter: 0.12.17
    • Select grunt-cli package: /usr/local/lib/node_modules/grunt-cli
  • Remove User File Headers:

    • Go to File/Settings/Editor/File and Code Templates
    • Open Includes tab
    • Clic on PHP File Header, and delete all content.
    • Clic Apply
  • Configure Ruby Highlighting (Optional)

    • Clone this repository somewher in your computer: git clone https://github.com/textmate/ruby.tmbundle.git
    • Go to Settings/Editor/TextMate Bundles, clic the plus button and locate the cloned ruby.tmbundle repository and clic ok.
15. Enjoy!
Quick notes
If you did not call your linux user "radmas":
  • Set up a password for root user with sudo su and passwd
  • Reboot your system and login as root (NOT with sudo su)
  • Execute groupadd radmas and usermod -d /home/radmas -m -g radmas -l radmas <<old_username>> replacing <<old_username>> with your user's name.
  • Fix .zshrc and .bashrc replacing your old username with radmas (all apearences except the vhosts ones)
If you get __rvm_cleanse_variables: function definition file not found error:
  • Run rm -f ~/.zcompdump*
Execute export and prepare notifications workers:
  • mtc-compose kill && mtc-compose rm -f
  • workers-compose up -d

If you want build the project without workers again, you can run workers-compose kill && workers-compose rm -f && mtc-compose up -d

Tag summary

Content type

Image

Digest

Size

896 MB

Last updated

about 5 years ago

docker pull radmas/mtc-plus-application