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
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: alexcheng/magento2
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/magento2-extension
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you mount it as a volume to this current repo, because the purpose is to develop on the extension with Docker as develop environment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Resolve this issue.


# 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."

32 changes: 32 additions & 0 deletions readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Setting Up Your Magento Environment
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you update the README.md and make it in the same style. Place it at the bottom, under the title "Test and Developing with Docker"


Starting Services:

Initiate your Docker containers by executing the following command:

docker-compose up -d

Verifying Container Names:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about the container names?

m(16:59:32) Magento $ docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS          PORTS                                                 NAMES
3a753d1fb033   alexcheng/magento2        "/sbin/my_init"          15 minutes ago   Up 15 minutes   80/tcp, 0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp   magento-magento-1
a8233be62425   bitnami/elasticsearch:7   "/opt/bitnami/script…"   15 minutes ago   Up 15 minutes   9200/tcp, 9300/tcp                                    magento-elasticsearch-1
8f3938b9699c   bitnami/mariadb:10.6      "/opt/bitnami/script…"   15 minutes ago   Up 15 minutes   3306/tcp                                              magento-mariadb-1


After initiating the containers, it's recommended to confirm their names. You can list the active containers using:

docker ps

Admin User Setup:

Before you proceed, ensure that you modify the container name in the script to match the actual name of your Magento container. Once done, execute the password setup
script:

sh password.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you automate this process.

Read #14 again. It's all about reproducibility of this extension. Too many manual steps will cause human error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

m(16:59:26) Magento $ sh password.sh
Creating admin user...
bash: line 2: magento: command not found
Failed to create the admin user.
Script execution completed.


Accessing the Admin Dashboard:

You can access the Magento admin dashboard by navigating to:

localhost/admin
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not reachable at all.


Installing Dropday Extension:

To add the Dropday extension to your Magento setup, run the following script:

sh install-dropday.sh