diff --git a/.command/compile b/.command/compile new file mode 100755 index 00000000..23af668a --- /dev/null +++ b/.command/compile @@ -0,0 +1,5 @@ +#!/bin/bash + +bin/magento cache:clean +bin/magento cache:flush +bin/magento setup:di:compile diff --git a/.command/setup.sh b/.command/install similarity index 91% rename from .command/setup.sh rename to .command/install index 3910b8b1..d48035bf 100755 --- a/.command/setup.sh +++ b/.command/install @@ -2,11 +2,8 @@ source "$PWD/.env" -echo $ADMIN_EMAIL - -exit php /var/www/html/bin/magento setup:install \ - --base-url=http://localhost:$PORT \ + --base-url=$APP_URL \ --db-host=mysql \ --db-name=$MYSQL_DATABASE \ --db-user=$MYSQL_USER \ diff --git a/.command/set-base-url b/.command/set-base-url new file mode 100755 index 00000000..c633e9c6 --- /dev/null +++ b/.command/set-base-url @@ -0,0 +1,5 @@ +#!/bin/bash + +source "$PWD/.env" + +bin/magento setup:store-config:set --base-url $APP_URL diff --git a/.env b/.env index 040e7ba8..e1fe3680 100755 --- a/.env +++ b/.env @@ -1,7 +1,8 @@ # NETWORK -PORT=8000 +PORT=81 +APP_URL=http://localhost:${PORT} -# Docker +# MYSQL MYSQL_USER=magento MYSQL_DATABASE=magento MYSQL_PASSWORD=secret diff --git a/Dockerfile b/Dockerfile index 28daba9b..d2b18e54 100755 --- a/Dockerfile +++ b/Dockerfile @@ -62,12 +62,6 @@ RUN sed -i 's/memory_limit = 128M/memory_limit = -1/' /etc/php81/php.ini # Working file WORKDIR /var/www/html - -# Composer -COPY ./composer.json /var/www/html/ -COPY ./auth.json /var/www/html/ -RUN composer install - COPY ./docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/Readme.md b/Readme.md new file mode 100644 index 00000000..cdb1bf94 --- /dev/null +++ b/Readme.md @@ -0,0 +1,34 @@ +# Reference and build +## Start on Docker +```sh +docker compose up +``` +## Setup magento2 + +> [!Important] +> Is linux os +```sh +chmod +x ./docker_exec +``` +> Install docker +```sh +./docker_exec ./command/install +``` +> Disable 2FA to login to admin +```sh +./docker_exec bin/magento module:disable Magento_TwoFactorAuth +./docker_exec bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth +``` +> Compile +```sh +./docker_exec ./command/compile +``` +> Gelink login to admin +``` +app/etc/env.php:4 +``` +``` +backend.frontName => 'admin_*' +``` +> http://localhost:81/admin_* +>> 81: Port of docker diff --git a/docker-compose.yml b/docker-compose.yml index ce6d5fd4..5728cec6 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,8 +16,8 @@ services: elasticsearch: image: elasticsearch:7.17.14 ports: - - 9200:9200 - - 9300:9300 + - :9200 + - :9300 environment: - ELASTIC_PASSWORD=${ELASTIC_PASSWORD} - discovery.type=single-node @@ -33,7 +33,7 @@ services: depends_on: - mysql ports: - - 7777:8080 + - :8080 mysql: image: bitnami/mysql:5.7 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 380105ff..af1360bb 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -8,6 +8,9 @@ if [ ! -d "$PWD/vendor" ]; then composer install fi +source "$PWD/.env" + +# Do something get environment chown -R apache:apache /var/www/html chmod -R 775 /var/www/html diff --git a/docker-exec.cmd b/docker-exec.cmd new file mode 100755 index 00000000..7c7c8a81 --- /dev/null +++ b/docker-exec.cmd @@ -0,0 +1,3 @@ +@echo off +echo "run docker..." +docker exec -it magento2 %*