Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update on docker #18

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@ Stores → Configuration → Dropday → Order Automation
- Test Mode - Enable Test mode
- Account ID - Account ID from Dropday Dashboard
- API Key - Secret Key be provided by Dropday Dashboard




Setup by Docker
===============


```
docker-compose up -d
```

It will take some time to deploy the setup in contaier

### Setup magento password

```
sh password.sh
```

### To install extension

```
sh install-dropday.sh
```


46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

version: '2'
services:
mariadb:
image: docker.io/bitnami/mariadb:10.6
platform: linux/arm64/v8
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_magento
- MARIADB_DATABASE=bitnami_magento
volumes:
- 'mariadb_data:/bitnami/mariadb'
magento:
image: bitnami/magento:latest
platform: linux/arm64/v8
ports:
- '80:8080'
- '443:8443'
environment:
- MAGENTO_HOST=localhost
- MAGENTO_DATABASE_HOST=mariadb
- MAGENTO_DATABASE_PORT_NUMBER=3306
- MAGENTO_DATABASE_USER=bn_magento
- MAGENTO_DATABASE_NAME=bitnami_magento
- ELASTICSEARCH_HOST=elasticsearch
- ELASTICSEARCH_PORT_NUMBER=9200
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- 'magento_data:/bitnami/magento'
depends_on:
- mariadb
- elasticsearch
elasticsearch:
image: docker.io/bitnami/elasticsearch:7
platform: linux/arm64/v8
volumes:
- 'elasticsearch_data:/bitnami/elasticsearch/data'
volumes:
mariadb_data:
driver: local
magento_data:
driver: local
elasticsearch_data:
driver: local
29 changes: 29 additions & 0 deletions install-dropday.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Name of the Magento container
CONTAINER_NAME="magento-magento-1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target assumes the project is cloned in a directory called "magento". This project should be able to live in any directory name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the directory name. This is the name of the container which is set prior and will remain same everythime any one setup the code

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the name of the container is determine by the folder that is lives in.

So magento-magento-1 is based on {directory}-{service}-{instance}.

I know this for a fact, because I ran the script from insude dropday-io-magento. And the name became dropday-io-magento-magento-1.


# Ask for the username and password
read -p "Enter Dropday Username: " USERNAME
read -s -p "Enter Dropday Password: " PASSWORD
echo

# Enter the Magento Docker container
docker exec -it $CONTAINER_NAME bash -c "
# Set up authentication for Composer
composer global config http-basic.repo.magento.com \"$USERNAME\" \"$PASSWORD\"

# Navigate to the Magento directory
cd /bitnami/magento/

# Use composer to install the Dropday extension
composer require dropday-io/module-orderautomation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing this extension with compose makes a copy of the master/main branch of this extension. While we want this Docker project to enable developers to work on their current branch.
Therefor, the code should be mounted through the volumes. See code of this #15.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bash script created to install extension in the magento container because we need to install magento first in the container that was done on installing php apache magento and running all services there through a single image which is taken from public repo docker hub of bitnami. We can achieve this installation by creating docker file other then script but it will also doing the installtion through the script. The container have attached volume this extension will be stored in the volume this is the one time script running


# Run Magento commands to setup and compile the extension
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:clean
Comment on lines +23 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the extension code base is mounted, I believe it will be installed automatically on installation.

"

echo "Dropday extension installation completed."

24 changes: 24 additions & 0 deletions password.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Name of the Magento container
CONTAINER_NAME="magento-magento-1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also assumes that the project lives inside a folder called magento.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also not the directory name. This is the name of the container which is set prior and will remain same everytime any one setup the code


# Admin user details
ADMIN_USER="admin-testing"
ADMIN_PASSWORD="NewPass123"
ADMIN_EMAIL="[email protected]"

# Enter the Magento Docker container, create the admin user, and then display the result.
docker exec -it $CONTAINER_NAME bash -c "
echo 'Creating admin user...'
magento admin:user:create --admin-user='$ADMIN_USER' --admin-password='$ADMIN_PASSWORD' --admin-email='$ADMIN_EMAIL'

if [ \$? -eq 0 ]; then
echo 'Admin user creation successful!'
else
echo 'Failed to create the admin user.'
fi
"

echo "Script execution completed."