alexcheng1982 / docker-magento2

Docker image for Magento Open Source 2
MIT License
381 stars 258 forks source link

Documentation request #1

Open sivajik34 opened 7 years ago

sivajik34 commented 7 years ago

I forked the repo,then i cloned to my local,then I checkout to 2.1 branch by fetching the original repo. I renamed to docker-compose.yml . Now i ran docker-compose up -d . Now what are the steps needed to run the magento in host browser? Can you add documentation?

sivajik34 commented 7 years ago

I ran docker ps command. after that i used web container with install-magento command. it showing an error like no such file . so now i ran docker exex -it container-id /bin/bash

sh /usr/local/bin/install-magento now its working fine. Note: i'm using windows 10 as a host.I want to edit files from host.can you help me on this? really confusion on docker volumes part.

alexcheng1982 commented 7 years ago

I don't have a Windows 10 machine, you can refer to this page on how to edit the host file.

If you are using the new native docker client (not Boot2Docker), you can modify the host file by adding this (not tested):

127.0.0.1 local.magento
alexcheng1982 commented 7 years ago

For documentation, you can see my Magento 1.x repo. These two follow the same instructions.

sivajik34 commented 7 years ago

Can you give me some direction to edit magento source code from host editor for example using net beans? and I want to commit the code to github/gitlab. I mean i want to work with docker.It shouldn't be only for demo purpose. Is it really useful in development environment? In my office 1 designer(windows),1 tester(windows),2 developers(ubuntu),1 lead(windows),1 project manager(mac). I don't have proper idea utilizing docker.but in everywhere present technology trending topic is docker.Really it will save the time? Thanks in advance.

sivajik34 commented 7 years ago

windows mounting not working.its throwing an error like composer.json not found when i'm trying to build. do you have any idea ? what is the issue.

in appdata folder I placed my code.and i commented some lines like downloading code from github,and moving code to container.

FROM alexcheng/apache2-php7

MAINTAINER Fu Cheng <alexcheng1982@gmail.com>

RUN a2enmod rewrite

# ENV MAGENTO_VERSION 2.1.1

# RUN rm -rf /var/www/html/*
# RUN cd /tmp && curl https://codeload.github.com/magento/magento2/tar.gz/$MAGENTO_VERSION -o $MAGENTO_VERSION.tar.gz && tar xvf $MAGENTO_VERSION.tar.gz && mv magento2-$MAGENTO_VERSION/* magento2-$MAGENTO_VERSION/.htaccess /var/www/html

RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN requirements="libpng12-dev libmcrypt-dev libmcrypt4 libcurl3-dev libfreetype6 libjpeg-turbo8 libjpeg-turbo8-dev libpng12-dev libfreetype6-dev libicu-dev libxslt1-dev" \
    && apt-get update && apt-get install -y $requirements && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && docker-php-ext-install mcrypt \
    && docker-php-ext-install mbstring \
    && docker-php-ext-install zip \
    && docker-php-ext-install intl \
    && docker-php-ext-install xsl \
    && docker-php-ext-install soap \
    && requirementsToRemove="libpng12-dev libmcrypt-dev libcurl3-dev libpng12-dev libfreetype6-dev libjpeg-turbo8-dev" \
    && apt-get purge --auto-remove -y $requirementsToRemove

COPY ./auth.json /var/www/.composer/
RUN chsh -s /bin/bash www-data
RUN chown -R www-data:www-data /var/www
RUN su www-data -c "cd /var/www/html && composer install"
RUN cd /var/www/html \
    && find . -type d -exec chmod 770 {} \; \
    && find . -type f -exec chmod 660 {} \; \
    && chmod u+x bin/magento

COPY ./bin/install-magento /usr/local/bin/install-magento
RUN chmod +x /usr/local/bin/install-magento

COPY ./bin/install-sampledata /usr/local/bin/install-sampledata
RUN chmod +x /usr/local/bin/install-sampledata

RUN echo "memory_limit=1024M" > /usr/local/etc/php/conf.d/memory-limit.ini

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /var/www/html

VOLUME /var/www/html/var
VOLUME /var/www/html/pub

# Add cron job
ADD crontab /etc/cron.d/magento2-cron
RUN chmod 0644 /etc/cron.d/magento2-cron
RUN crontab -u www-data /etc/cron.d/magento2-cron
version: '2'
services:
  web:
    build: .
    ports:
      - "81:80"
    volumes:
      - '/c/Users/Admin/docker-magento2/appdata:/var/www/html/'
    links:
      - db
    env_file:
      - env
  db:
    image: mysql:5.6.23
    volumes_from:
      - dbdata
    env_file:
      - env
  dbdata:
    image: alexcheng/data
    volumes:
      - /var/lib/mysql
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    ports:
      - "8580:80"
    links:
      - db       
alexcheng1982 commented 7 years ago

You shouldn't mount the whole Magento source directory, because you don't need to modify source code of core Magento files. You just need to mount your own extension/theme code. For example, if you are developing a theme,

volumes:
  - ./dev/theme:/var/www/html/app/design/frontend/mytheme/default
le-ecalahorra commented 6 years ago

Hello,

Following this issue; I'm agreed we don't need to mount the whole Magento Soruce; but would be nice to have the whole code in a host folder in order to run PhpStorm Project and debug whatever is necessary.

I tried to add the volume: "- ./src:/var/www/html" and I had the same poblem as @sivajik34.

Any solution?

ioan-ghisoi commented 6 years ago

Sry for the very general question but can I run this on circle ci? I mean how do i start it?

alexcheng1982 commented 6 years ago

Circle CI supports running Docker images. So just use this Docker image in its config file. You can use run in the config file to install Magento.

On Wed, Nov 29, 2017 at 6:07 AM, Ioan Ghisoi notifications@github.com wrote:

Sry for the very general question but can I run this on circle ci? I mean how do i start it?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/alexcheng1982/docker-magento2/issues/1#issuecomment-347592916, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHgEEyZ-HYGW6wGzldZIbmihy4JvHnEks5s7D25gaJpZM4KP7qp .

-- Regards Alex Cheng

murnun commented 6 years ago

@alexcheng1982 - Completely agree on not touching core files but any recommendation as to how we can setup our IDE and XDebugger etc for full development workflow?

victorw999 commented 6 years ago

RE: Previous Comment

I don't have a Windows 10 machine, you can refer to this page on how to edit the host file. If you are using the new native docker client (not Boot2Docker), you can modify the host file by adding this (not tested):

127.0.0.1 local.magento

This is what i did with "Windows-10-Home" and "Docker Toolbox":

  1. Verify docker IP: docker-machine ip say the output is 192.168.99.100
  2. Update Window host file: c:\windows\system32\drivers\etc\hosts add line 192.168.99.100 local.magento
  3. launch website from browser http:\\local.magento launch phpmyadmin via http:\\local.magento:8580
alexcheng1982 commented 6 years ago

Added more doc about development and testing using this Docker image.

taqvi commented 3 years ago

@alexcheng1982 can you share how to configure this image for Xdebug with phpstrom please, its much needed thing!!