Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mubarokahh/migrating-app-to-container-


https://github.com/mubarokahh/migrating-app-to-container-

deployment-automation docker docker-container docker-image

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# MIGRATING TO THE CLOUD WITH CONTAINERIZATION
In this project,when i talk about containers, I imply docker. Although there are other containerization technology,docker is the standard tool for deploying application its dependencies and configuration in a sandbox also known as containers in an operating system.

For my previous projects, i have been using VMs to deploy web solution. For efficiency purpose, i will be using docker to deploy my application.Unlike a VM, Docker allocated not the whole guest OS for your application, but only isolated minimal part of it - this isolated container has all that your application needs and at the same time is lighter, faster, and can be shipped as a Docker image to multiple physical or virtual environments, as long as this environment can run Docker engine. This approach also solves the environment incompatibility issue. It is a well-known problem when a developer sends his application to you, you try to deploy it, deployment fails, and the developer replies, "- It works on my machine!". With Docker - if the application is shipped as a container, it has its own environment isolated from the rest of the world, and it will always work the same way on any server that has Docker engine.

## Installing docker engine
For the purpose of this project, i installed docker desktop that is conpartible with my local host.

Screenshot 2024-01-18 at 21 18 16

## Deploying mySQL into a container in docker engine.

`docker run --name -e MYSQL_ROOT_PASSWORD= -d mysql/mysql-server:latest`

I aaded the needed values into the command and the got the container up and running.

Screenshot 2024-01-18 at 21 47 29

## Connecting to the MySQL Docker Container

I connected directly to the mySQL server as to creating another container to serve as mySQL client

`docker exec -it mubarokah mysql -uroot -p`

Screenshot 2024-01-20 at 18 09 57

## Preparing database schema

- Cloning the following repository (git clone https://github.com/darey-devops/tooling.git)

- Exporting the location of the SQL file that contains data for setting up the MySQL database: `export tooling_db_schema=~/tooling_db_schema.sql`

- Using the SQL script to create the database and prepare the schema: `docker exec -i mysql-server mysql -uroot -p$MYSQL_PW < $tooling_db_schema`

Screenshot 2024-01-20 at 22 23 34

- I updated the db_conn.php with the connection details to the database.

$servername = "mysqlserverhost";
$username = "mubarokah";
$password = "*****";
$dbname = "toolingdb";

## Runing the Tooling Application

Containerizing the Tooling Appliaction

- I ran the following command in the directory that has dockerfile

'docker build -t tooling:0.0.1'

Screenshot 2024-01-21 at 17 37 57

- Running the container

'docker run --network tooling_app_network -p 8085:80 -it tooling:0.0.1'

Screenshot 2024-01-21 at 18 03 17

Screenshot 2024-01-25 at 12 09 09

## Migarating the php-Todo app into a containerized application

- Cloning this repsository 'https://github.com/Mubarokahh/php-todo.git'
- I created mysql container for the php-todo

Screenshot 2024-01-29 at 12 11 20
- The dockerfile

Screenshot 2024-01-29 at 13 15 02

- Creating a docker image with the build command

`docker build -t php-todo:0.0.3 .`

Screenshot 2024-01-29 at 13 30 24

- Running the container

- Running the artisan migrate command inside the php-todo container since it was ignored during the build process
Screenshot 2024-01-29 at 16 16 00