Skip to content

Instantly share code, notes, and snippets.

@vrann
Last active June 1, 2018 14:55
Show Gist options
  • Save vrann/73d3d3da7a4c777e54f27ac8eb347ccc to your computer and use it in GitHub Desktop.
Save vrann/73d3d3da7a4c777e54f27ac8eb347ccc to your computer and use it in GitHub Desktop.
Install Magento from GitHub on Docker

Prerequisites

Docker is installed

1. Start Docker Cluster

  1. create directory ~/magento2-docker
  2. add docker-compose.yml to ~/magento2-docker with the following content
version: '3'
services:
  web:
    restart: always
    #build: ./
    image: vrann/magento2devbox-web
    volumes:
      - "~/.gitconfig:/home/magento2/.gitconfig"
      - "~/.composer:/home/magento2/.composer"
      - "~/.ssh:/home/magento2/.ssh"
      - "./shared/logs/apache2:/var/log/apache2"
      - "./shared/logs/php-fpm:/var/log/php-fpm"
      - "./shared/configs/varnish:/home/magento2/configs/varnish"
      - "./shared/.magento-cloud:/home/magento2/.magento-cloud"
    environment:
      - MAGENTO_BACKEND_PATH=admin
      - MAGENTO_ADMIN_USER=admin
      - MAGENTO_ADMIN_PASSWORD=admin123
    ports:
      - "80"
      - "22"
  db:
    restart: always
    image: mysql:5.6
    ports:
      - "3306"
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=magento2
    volumes:
      - "./shared/var/logs/mysql:/var/log/mysql"
  1. run cd ~/magento2-docker
  2. run docker-compose up -d

3. Clone Magento and Copy to Docker

  1. clone Magento fromyour fork to the to ~/magento2
cd ~/
git clone https://github.com/your-name/magento2
  1. copy Magento to docker
cd ~/magento2-docker
docker-compose ps

use the name of the container, such as magento2docker_web_1

docker cp ~/magento2 magento2docker_web_1:/var/www/magento2ce
  1. Link magento code inside docker container
docker-compose exec --user=magento2 web relink.sh
  1. Identify port web
docker-compose port web 80
  1. Use the value returned from previous command, i.e. 32771
docker-compose exec --user=magento2 web install.sh 32771
  1. login to backend http://localhost:32771/index.php/admin/admin/dashboard/
login: admin
password: admin123
@bobbyshaw
Copy link

Note that if you use dinghy for Docker you'll either need to go through the web setup wizard or replace the install.sh command with something more tailored for your machine.

You can find the original script here: https://github.com/vrann/magento2devbox-web/blob/master/scripts/install.sh

You can find your IP by running dinghy ip.

Then log in to your box: docker-compose exec --user=magento2 web bash and run you updated install command, e.g:

magento setup:install --backend-frontname=$MAGENTO_BACKEND_PATH \
--
  | --db-host="db" \
  | --db-name="magento2" \
  | --db-user="root" \
  | --db-password="root" \
  | --admin-user=$MAGENTO_ADMIN_USER \
  | --admin-password=$MAGENTO_ADMIN_PASSWORD\
  | --admin-email="test@user.com" \
  | --admin-use-security-key='0' \
  | --admin-firstname="John" \
  | --admin-lastname="Doe" \
  | --base-url="http://192.168.99.100:32778" \
  | --cleanup-database;
  |  
  | magento cache:flush;

Then you can visit your Magento installation with the dinghy IP and port, e.g. http://192.168.99.100:32778/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment