Skip to content

Commit 7de3074

Browse files
Update README.md
1 parent c194ca4 commit 7de3074

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,90 @@ docker exec -it 8294e1800058 /bin/sh
7373
8. This way the basic setup is done and you can change the composer file accordingly. In case any additional PHP library is needed, update the PHP docker file and rebuild the PHP Docker image.
7474

7575
## Detailed Explanation
76+
1. Install [docker](https://www.docker.com/) on your machine. You may verify the installation by running below command on your terminal.
77+
```
78+
docker -D info
79+
```
80+
81+
2. Fork this repository to your machine where you want to manage your codebase.
82+
3. Spin up the docker now using below command to create PHP, Apache and MySql containers.
83+
```
84+
docker-compose up -d
85+
```
86+
Adding the `-d` means it will start in detached mode, allowing you to continue to use that terminal window while the containers run in the background.
87+
88+
Once you run this command, it will create all the containers and install all the relevant libraries defined in docker files. I will talk about individual docker files in detail separately. If it runs successfully, you will see the below messages.
89+
90+
```
91+
Creating mysql ... done
92+
Creating php ... done
93+
Creating apache ... done
94+
```
95+
4. Now take a look at PHP, Apache and MySql containers using below command:
96+
```
97+
docker ps
98+
```
99+
| CONTAINER ID | IMAGE | COMMAND | CREATED | STATUS | PORTS | NAMES |
100+
| -------------| ------ | ------ | ------- | ------ | ----- | -----|
101+
| 09f51b5f330b | dockerize-existing-drupal-project_apache | "httpd-foreground" | 32 seconds ago | Up 30 seconds | 0.0.0.0:80->80/tcp | apache |
102+
| 8294e1800058 | dockerize-existing-drupal-project_php | "docker-php-entrypoi…" | 33 seconds ago | Up 31 seconds | 9000/tcp | php |
103+
| d8b2cbac5695 | mysql:8.0.0 | "docker-entrypoint.s…" | 33 seconds ago | Up 31 seconds | 0.0.0.0:3306->3306/tcp | mysql |
104+
5. Now jump into the PHP container using the `docker exec` command.
105+
```
106+
docker exec -it 8294e1800058 /bin/sh
107+
```
108+
Since you will be using the `root` user inside the container, so you should have permissions to do anything. The code in your git repository can be found at `/var/www/html` in the container. To ensure container mounted is successful, run the below command.
109+
```
110+
/var/www/html # ls
111+
```
112+
If it shows you `index.php` that means it mounts to your local repository i.e. `docroot`
113+
6. Now hit the http://localhost:80 in browser to ensure setup is successful. Along with the below output, you will also see phpinfo() output.
114+
```
115+
Congratulations!! Docker setup connection is successful.
116+
Checking MySQL integration with php.
117+
MySql connection is successful!
118+
```
119+
7. Now the docker setup is done, you can put your local codebase inside the `docroot`. Now it's up to you whether you want to run multiple drupal instances within this repository or a single one. If you want to manage multiple repositories then keep the project folder inside the `docroot` repository. For example, in our case, it's `drupal8` repository.
120+
121+
```
122+
.
123+
├── LICENSE
124+
├── README.md
125+
├── apache
126+
│   ├── Dockerfile
127+
│   └── local.apache.conf
128+
├── docker-compose.yml
129+
├── docroot
130+
│   └── drupal8
131+
| ├── config
132+
│   ├── drush
133+
│   ├── scripts
134+
│   ├── vendor
135+
│   └── web
136+
| ├── core
137+
│   ├── modules
138+
│   ├── profiles
139+
│   ├── sites
140+
│   └── themes
141+
└── php
142+
└── Dockerfile
143+
```
144+
145+
Now this project Drupal's docroot should be located at `/var/www/html/drupal8/web`.
146+
147+
8. Now update your project's database credentials in `settings.php` or `local.settings.php` wherever you are managing. As we are already in PHP container `/var/www/html/drupal8/web`, hence we can import the database using Drush:
148+
149+
```
150+
drush sql:dump --result-file=../backup.sql
151+
```
152+
Here `backup.sql` is your mysql database backup file. It can different in your case.
153+
9. Now access your drupal project in browser. For example, in our case it would be below URL:
154+
```
155+
http://localhost/drupal8/web
156+
```
157+
We may create virtual host entry for above URL.
158+
10.
159+
76160
--WIP---
77161

78162
## Issues and Resolutions

0 commit comments

Comments
 (0)