magently / docker

0 stars 2 forks source link

dont persist data #1

Open brunokunace opened 5 years ago

brunokunace commented 5 years ago

Hi, i try to use this image, but all time when i restart a docker-compose, all instalation procede again.

PS.: I need to change admin password everytime too, have way to set this on enviroment?

my docker-compose

version: '2'

services:
  # MySQL container
  magento-db:
    container_name: magento-db
    image: mysql:5.7
    ports:
      - 3306:3306
    volumes:
      - .docker/mysql/:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: magento
      MYSQL_DATABASE: magento

  # App container
  magento-app:
    container_name: magento-app
    image: magently/magento2
    links:
      - magento-db
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./packages/:/app/packages/
    environment:
      - MYSQL_HOST=magento-db
      - MYSQL_USER=root
      - MYSQL_PASSWORD=magento
      - MYSQL_DATABASE=magento

Thanks!

brunokunace commented 5 years ago

I try use -env image, but have some errors and not installing....

edit here later

dominikklemetowski commented 5 years ago

Hi. I checked with your exact docker-compose file and for me it works as expected. Installation proceeds (because it includes packages installation steps like running migrations), but it's not full installation. Store data persists (products, categories).

Admin password is set to default every time container starts, though. You can pass some variables to the installation process including admin credentials. Look at the entrypoint part:

# Install Magento 2
gosu "application" php "$MAGENTO_PATH/bin/magento" setup:install \
  --base-url=$MAGENTO_URL \
  --backend-frontname=$MAGENTO_BACKEND_FRONTNAME \
  --language=$MAGENTO_LANGUAGE \
  --timezone=$MAGENTO_TIMEZONE \
  --currency=$MAGENTO_DEFAULT_CURRENCY \
  --db-host=$MYSQL_HOST \
  --db-name=$MYSQL_DATABASE \
  --db-user=$MYSQL_USER \
  --db-password=$MYSQL_PASSWORD \
  --use-secure=0 \
  --base-url-secure=0 \
  --use-secure-admin=0 \
  --admin-firstname=$MAGENTO_ADMIN_FIRSTNAME \
  --admin-lastname=$MAGENTO_ADMIN_LASTNAME \
  --admin-email=$MAGENTO_ADMIN_EMAIL \
  --admin-user=$MAGENTO_ADMIN_USERNAME \
  --admin-password=$MAGENTO_ADMIN_PASSWORD