From ca61275eebd485fb54b97daa857cc9170b6fb9de Mon Sep 17 00:00:00 2001 From: sanjay sankhla Date: Mon, 9 Oct 2023 15:51:52 +0530 Subject: [PATCH 1/7] update readme file for assignment --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8310d21..4a69f18 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Tasks: * Create a Docker Compose file (docker-compose.yml) to orchestrate the WordPress application. * Include services for WordPress and the database (e.g., MySQL or MariaDB). * Configure network settings and dependencies between services. -* Use environment variables or .env files to manage configuration settings securely. +* Use environment variables to manage configuration settings securely. ### 3) Optimize the Database for Performance: * Research and implement database optimization strategies to enhance performance. * Consider techniques such as indexing, caching, and query optimization. From 35109a27ce4f98138710a47cb9a931cf96742715 Mon Sep 17 00:00:00 2001 From: manjushindhe <124366232+manjushindhe@users.noreply.github.com> Date: Thu, 12 Oct 2023 01:29:09 +0530 Subject: [PATCH 2/7] Docker assignment "I am fully committed to the task at hand." "I am putting my heart and soul into this project." "I'm dedicated to achieving the best possible results." I also shared google drive link --- README.md | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/README.md b/README.md index 4a69f18..5ceac9a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ +Create a directory for your WordPress project +mkdir my-wordpress-project +Navigate to it in your terminal. +cd my-wordpress-project +Inside your project directory, create a file +nano Dockerfile +In the Dockerfile, start by specifying the base image +# Use an official WordPress image as the base image +FROM wordpress:latest +#Set author label +LABEL maintainer="manjushindhe123@gmail.com" +Use the Expose port 80 +EXPOSE 80 +#Command to run when the container starts +CMD ["apache2-foreground"] +Save the changes to your Dockerfile and exit your text editor + # Assignment: Dockerizing WordPress with Dockerfile, Docker Compose, and Database Optimization @@ -42,3 +59,141 @@ Your assignment will be evaluated based on the following criteria: Note: Please make sure to test your Dockerized WordPress application thoroughly to ensure it functions as expected. Good luck with your assignment! If you have any questions or need further assistance, feel free to ask. +Approach for Dockerizing WordPress : Gone through the official Docker documentation on WordPress & write the Dockerfile and docker-Compose.yml file with the help of the documentation and some of my prior knowledge on networking and docker. + +Approach for optimizing the database : Research about different database optimization strategies. Having the basic knowledge of MYSQL queries given a big advantage. + +Challenges encountered during the process : My laptop was having some issues related to storage. So, i had to used a AWS EC2 instance. +## Deployment + Step 1: +Build the Docker image using the following command: +```bash + docker build -t my-wordpress-image . +Once the image is built, you can verify its existence by running: + docker image +``` +To run the container from image +```bash + docker run -p 8080:80 --name my-wordpress-container my-wordpress-image +``` +To get access of the website just hit the following url in the browser +```bash + http://localhost:8080 +``` + +## Step 2: +To start containers defined in a 'docker-compose.yml' +```bash + docker-compose up -d +``` +To get access of the website just hit the following url in the browser +```bash + http://localhost:8081 or http://your-server-ip +``` +## Step 3: +To access the MySQL Container +```bash + docker exec -it my-mysql bash +``` +To log in to MySQL and enter the password +```bash + mysql -u root -p +``` +To use databse and showing the tables +```bash + use wordpress; + show table; +``` +To Analyze Query Performance : +Identify slow-running queries using the EXPLAIN statement +```bash + EXPLAIN SELECT * FROM wp_posts WHERE post_status = 'publish'; +``` +Indexing : +Identify frequently used columns adding indexes to them +```bash + CREATE INDEX idx_title ON wp_posts (post_title); +``` +Ensure that each table has a primary key +```bash + ALTER TABLE wp_posts ADD PRIMARY KEY (ID); +``` +Optimize Queries : Only retrieve the columns needed +```bash + SELECT post_title, post_date FROM wp_posts WHERE post_status = 'publish'; +``` +Regular Maintenance : Analyze and Optimize Tables +```bash +ANALYZE TABLE wp_posts; +OPTIMIZE TABLE wp_posts; +``` +Remove Unnecessary Data : Periodically remove old or unused data to reduce the size of your database. + +Partitioning (For Large Tables) : Partitioning them to distribute data across multiple partitions. + +Monitor Performance : Continuously monitor the performance of database using tools like MySQL's Performance Schema +## Documentation + +[Documentation]https://drive.google.com/file/d/1xFKGbz8nsE3uvnvHmwa581daW5pxyDv1/view?usp=sharing + +--- +version: '3.7' +services: + + --- +version: '3.7' +services: + + wordpress: + image: wordpress + restart: always + ports: + - 8080:80 + environment: + WORDPRESS_DB_HOST: db + WORDPRESS_DB_USER: manju + WORDPRESS_DB_PASSWORD_FILE: /run/secrets/db_password + WORDPRESS_DB_NAME: wpdb + secrets: + - db_password + volumes: + - wordpress:/var/www/html + + db: + image: mysql:5.7.28 + ports: + - "3306:3306" + environment: + MYSQL_DATABASE: wpdb + MYSQL_USER: manju + MYSQL_PASSWORD_FILE: /run/secrets/db_password + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password + secrets: + - db_password + - db_root_password + volumes: + - db:/var/lib/mysql + networks: + - default + + phpmyadmin: + image: phpmyadmin/phpmyadmin + links: + - db:db + ports: + - 8282:80 + environment: + MYSQL_USER: manju + MYSQL_PASSWORD_FILE: /run/secrets/db_password + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password + secrets: + - db_password + - db_root_password +secrets: + db_password: + file: db_password.txt + db_root_password: + file: db_root_password.txt +volumes: + wordpress: + db: From f8bbe8243f734ca8a05442c9772abda09352a7a4 Mon Sep 17 00:00:00 2001 From: manjushindhe <124366232+manjushindhe@users.noreply.github.com> Date: Thu, 12 Oct 2023 01:54:43 +0530 Subject: [PATCH 3/7] docker_compose.yaml --- docker_compose.yaml | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 docker_compose.yaml diff --git a/docker_compose.yaml b/docker_compose.yaml new file mode 100644 index 0000000..63c8c51 --- /dev/null +++ b/docker_compose.yaml @@ -0,0 +1,61 @@ +--- +version: '3.7' +services: + + --- +version: '3.7' +services: + + wordpress: + image: wordpress + restart: always + ports: + - 8080:80 + environment: + WORDPRESS_DB_HOST: db + WORDPRESS_DB_USER: manju + WORDPRESS_DB_PASSWORD_FILE: /run/secrets/db_password + WORDPRESS_DB_NAME: wpdb + secrets: + - db_password + volumes: + - wordpress:/var/www/html + + db: + image: mysql:5.7.28 + ports: + - "3306:3306" + environment: + MYSQL_DATABASE: wpdb + MYSQL_USER: manju + MYSQL_PASSWORD_FILE: /run/secrets/db_password + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password + secrets: + - db_password + - db_root_password + volumes: + - db:/var/lib/mysql + networks: + - default + + phpmyadmin: + image: phpmyadmin/phpmyadmin + links: + - db:db + ports: + - 8282:80 + environment: + MYSQL_USER: manju + MYSQL_PASSWORD_FILE: /run/secrets/db_password + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password + secrets: + - db_password + - db_root_password +secrets: + db_password: + file: db_password.txt + db_root_password: + file: db_root_password.txt +volumes: + wordpress: + db: From 024e5a9c1eea2809be0be86d3517711f111ce1c9 Mon Sep 17 00:00:00 2001 From: manjushindhe <124366232+manjushindhe@users.noreply.github.com> Date: Thu, 12 Oct 2023 01:57:37 +0530 Subject: [PATCH 4/7] README.md --- README.md | 62 +------------------------------------------------------ 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/README.md b/README.md index 5ceac9a..35693e9 100644 --- a/README.md +++ b/README.md @@ -136,64 +136,4 @@ Monitor Performance : Continuously monitor the performance of database using too [Documentation]https://drive.google.com/file/d/1xFKGbz8nsE3uvnvHmwa581daW5pxyDv1/view?usp=sharing ---- -version: '3.7' -services: - - --- -version: '3.7' -services: - - wordpress: - image: wordpress - restart: always - ports: - - 8080:80 - environment: - WORDPRESS_DB_HOST: db - WORDPRESS_DB_USER: manju - WORDPRESS_DB_PASSWORD_FILE: /run/secrets/db_password - WORDPRESS_DB_NAME: wpdb - secrets: - - db_password - volumes: - - wordpress:/var/www/html - - db: - image: mysql:5.7.28 - ports: - - "3306:3306" - environment: - MYSQL_DATABASE: wpdb - MYSQL_USER: manju - MYSQL_PASSWORD_FILE: /run/secrets/db_password - MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password - secrets: - - db_password - - db_root_password - volumes: - - db:/var/lib/mysql - networks: - - default - - phpmyadmin: - image: phpmyadmin/phpmyadmin - links: - - db:db - ports: - - 8282:80 - environment: - MYSQL_USER: manju - MYSQL_PASSWORD_FILE: /run/secrets/db_password - MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password - secrets: - - db_password - - db_root_password -secrets: - db_password: - file: db_password.txt - db_root_password: - file: db_root_password.txt -volumes: - wordpress: - db: + From c09acba5bf0a99c4551575ac7ae270c5eedbd660 Mon Sep 17 00:00:00 2001 From: manjushindhe <124366232+manjushindhe@users.noreply.github.com> Date: Thu, 12 Oct 2023 02:00:29 +0530 Subject: [PATCH 5/7] README.md --- README.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/README.md b/README.md index 35693e9..e53c333 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,3 @@ -Create a directory for your WordPress project -mkdir my-wordpress-project -Navigate to it in your terminal. -cd my-wordpress-project -Inside your project directory, create a file -nano Dockerfile -In the Dockerfile, start by specifying the base image -# Use an official WordPress image as the base image -FROM wordpress:latest -#Set author label -LABEL maintainer="manjushindhe123@gmail.com" -Use the Expose port 80 -EXPOSE 80 -#Command to run when the container starts -CMD ["apache2-foreground"] -Save the changes to your Dockerfile and exit your text editor - - # Assignment: Dockerizing WordPress with Dockerfile, Docker Compose, and Database Optimization ### Objective: The goal of this assignment is to Dockerize a WordPress application using best practices for Dockerfile and Docker Compose, as well as to optimize the database for improved performance. You are also required to create a Readme file to document your approach and provide additional notes related to the task. From 928c5fde354a326965ec386c06b52199ec8219bf Mon Sep 17 00:00:00 2001 From: manjushindhe <124366232+manjushindhe@users.noreply.github.com> Date: Thu, 12 Oct 2023 02:27:47 +0530 Subject: [PATCH 6/7] README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e53c333..fcb9500 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,6 @@ Partitioning (For Large Tables) : Partitioning them to distribute data across mu Monitor Performance : Continuously monitor the performance of database using tools like MySQL's Performance Schema ## Documentation -[Documentation]https://drive.google.com/file/d/1xFKGbz8nsE3uvnvHmwa581daW5pxyDv1/view?usp=sharing +[Documentation]https://drive.google.com/file/d/1Hg1HVKEvQ1AfaMrXGnh9jTEAuk-m5YKL/view?usp=sharing From b39eea1ad02d7216d81f7845543ef361826ae252 Mon Sep 17 00:00:00 2001 From: manjushindhe <124366232+manjushindhe@users.noreply.github.com> Date: Thu, 12 Oct 2023 08:45:07 +0530 Subject: [PATCH 7/7] README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fcb9500..3a8e83e 100644 --- a/README.md +++ b/README.md @@ -118,4 +118,5 @@ Monitor Performance : Continuously monitor the performance of database using too [Documentation]https://drive.google.com/file/d/1Hg1HVKEvQ1AfaMrXGnh9jTEAuk-m5YKL/view?usp=sharing +[Project link] http://13.233.190.208/wp-admin/install.php