Because is no one official Magento image exists, i try to create one from scratch.
First of all i investigate some tutorials and create Dockerfile and docker-compose configuration to combine:
- Ubuntu image with php7.4 directly, because magento dont work with "latest" version of ubuntu php 8.
- Mysql DB.
- Elasticsearch.
- Container nenwork.
Magento will work on 5000 port, mysql - on 3306, elasticsearch on 9200 and 9300.
MySql user will be: magento with password "password" and DB name will be magento_demo.
Next i run all in one:
docker-compose uo --build
To install Magento in container, i should enter it
docker exec -it magento-demo-web bash
Than i should run installation because Magento has composer package.
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /workspaces/magento-demo/install
NOTE: in this command you should use:
"username": "<Public key>"
"password": "<Private key>"
Those keys are in Magento official site Account section and we will use them in local installation because Magento package is proprietal and we should be secure in access to it. This command will download all the Magento files as specified by the magento/project-community-edition project from the https://repo.magento.com/ repository. To obtain this keys i follow the next guide [https://devdocs.magento.com/guides/v2.4/install-gde/prereq/connect-auth.html].
Than, Magento placed all files in "install" folder and i should move them directly in our root folder (WORKDIR: /workspace/magento-demo) manually or with command:
mv ./install/* ./
We now need to actually install Magento like this
bin/magento setup:install \
--base-url=http://localhost:5000 \
--db-host=mysql \
--db-name=magento_demo \
--db-user=magento \
--db-password=password \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/New_York \
--use-rewrites=1 \
--elasticsearch-host=elasticsearch \
--elasticsearch-port=9200
Once that command is done, i am ready to rock and roll. Lets run the next command:
php -S 0.0.0.0:5000 -t ./pub/ ./phpserver/router.php
And than, i should navigating to localhost:5000
in browser. I see empty Magento homepage.
Magento will empty, but i found some commands to install sample datas. NOTE: This will also use secure magento repository and i will need auth with Publik and Private keys:
bin/magento sampledata:deploy
bin/magento setup:upgrade
bin/magento indexer:reindex
bin/magento cache:flush
bin/magento info:adminuri
For example:
magento@8e550a9e9b38:/workspaces/magento-demo$ bin/magento info:adminuri
Admin URI: /admin_1xbhov
Admin URL should be:
http://localhost:5000/admin_1xbhov
bin/magento admin:user:create --admin-firstname=John --admin-lastname=Doe [email protected] --admin-user=j.doe --admin-password=A0b9%t3g
bin/magento mo:di Magento_TwoFactorAuth
Remove previous installation:
rm app/etc/env.php
or
rm /workspace/magento-demo
NOTE: I should set correct permissions for the whole Magento 2 installation directory by running the below command:
find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;
Profit...
- Upload API2Cart bridge file (ex. magento_ai2cart_plugin.zip).
- Enter into your shop hosting machine via SSH.
- Place magento_ai2cart_plugin.zip file into temporary folder.
- Unzip magento_ai2cart_plugin.zip into temporary folder.
- Find Magento 2 server installation path and copy the archive content into shop folder ./app/code/<Plugin_Vendor>/<Plugin_Name>
- Check vendor/name in plugin file composer.json in section "autoload" >> "psr-4" >> "...".
- It should be like this: ""Api2cart\BridgeConnector\".
- Set path to plugin folder like this: ./app/code/Api2cart/BridgeConnector/
- Run command in server console from the Magento 2 server root folder: php bin/magento setup:upgrade
- Run command php bin/magento setup:static-content:deploy -f
- Open your Admin section of Magento 2 Web site.
- Look on the left side menu bottom.
- Click on API2CART BRIDGECONNECTOR.
- Click on the blue button INSTALL CONNECTOR.
- Copy secret code from the field YOUR STORE KEY.
- Open the Vincofy Web site.
- Sign in as Vendor.
- Open My Shops menu in the left side menu.
- Click Connect my store and select Magento option.
- Fill all necessary fields, store name, store URL and insert the secret key (YOUR STORE KEY).
- Click on Integrate this.