Skip to content

Commit 27d2bc7

Browse files
author
Igor Sukhinin
committed
Updated to the newer version
1 parent 8a96746 commit 27d2bc7

File tree

23 files changed

+215
-229
lines changed

23 files changed

+215
-229
lines changed

.env

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# App Settings
22
APP_NAME=docker
33
APP_PATH=./app
4-
# To launch the app in dev environment just leave it empty
5-
APP_ENV=prod
64

7-
# Dev MySQL Settings
8-
MYSQL_DATABASE=db
9-
MYSQL_USER=db
10-
MYSQL_PASSWORD=db
11-
MYSQL_ROOT_PASSWORD=root
5+
# MySQL settings
6+
DB_HOST=db
7+
DB_NAME=dbname
8+
DB_USER=dbuser
9+
DB_PASS=dbpass
10+
11+
#EOF

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
.idea
1+
/.idea
2+
/etc/log/nginx/
3+
/etc/db/data/
4+
!/etc/db/data/.gitkeep
5+
!/etc/log/nginx/.gitkeep
6+
7+
.env.*

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!make
2+
include .env
3+
export
4+
5+
DOCKER_COMPOSE=docker-compose -p $(APP_NAME) -f "etc/docker-compose/docker-compose.run.yaml"
6+
7+
.DEFAULT_GOAL := help
8+
9+
help: ## Shows this help messages
10+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
11+
12+
build: ## Builds Docker images for the project
13+
@docker-compose -f "etc/docker-compose/docker-compose.build.yaml" build
14+
15+
up: ## Starts all containers
16+
@${DOCKER_COMPOSE} up
17+
18+
down: ## Stops all containers
19+
@${DOCKER_COMPOSE} down

README.md

Lines changed: 19 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,35 @@
1-
Nginx + Php-fpm + Apache + MySQL + NodeJS + phpMyAdmin with Docker-Compose
1+
nginx + PHP-FPM + Apache + MySQL + NodeJS + phpMyAdmin with Docker-Compose
22
==========================================================================
33

44
Initial configuration to install a web environment with the following images:
55

6-
- nginx: it will be running as a reverse-proxy for Apache; the static data (images, texts, js scripts, etc) will be
7-
returned by nginx itself
8-
- Php-fpm 7.2: it will install `composer` and try to run it with `composer install`
9-
- Apache (httpd): it will be proxying the requests to PHP-FPM
10-
- MySQL 8: default access credentials are defined in `.env` file incl. the root password
11-
- NodeJS: will try to run `npm run dev` or `npm run dev` depending on the settings defined in `.env` file
12-
- phpMyAdmin: it will be available on the port `5426`, e.g. `http://localhost:5426`
6+
- nginx: reverse-proxy for Apache and PhpMyAdmin
7+
- PHP-FPM 8.2 with `composer`
8+
- Apache (httpd): as a proxy for requests to PHP-FPM
9+
- MySQL 8: default access credentials are defined in `.env` file
10+
- NodeJS 21
11+
- phpMyAdmin 5.2: it will be available on the port `81`, e.g. `http://localhost:81`
1312

14-
## Prerequisites
13+
## Installation
1514

16-
Please make sure docker & docker-compose are installed on the target machine.
15+
### Prerequisites
1716

18-
If you are not sure, please run the following command (Ubuntu):
19-
20-
```
21-
sudo apt-get install docker docker-compose -y
22-
```
23-
24-
## Initial Settings
25-
26-
Navigate to the root directory and open `.env` file for editing:
27-
28-
```
29-
# App Settings
30-
APP_NAME=docker
31-
APP_PATH=./app
32-
# To launch the app in dev environment just remove prod
33-
APP_ENV=prod
34-
```
35-
36-
## Run Docker-Compose
37-
38-
To build the images and run the configuration please navigate to the root directory and run the following command
17+
- Docker 24.0
18+
- Docker Compose 2.22
3919

40-
```
41-
docker-compose up -d --build
42-
```
20+
### Build and Run
4321

44-
Remove option `-d` if you don't want to run it in the detached mode.
22+
1. Run `make build` to build the Docker images
23+
2. Run `make up` to run the Docker containers
4524

46-
If the images are already built just run the following command
25+
All the commands above can be run with one command:
4726

4827
```
49-
docker-compose up -d
28+
make build && make up
5029
```
5130

52-
Docker Management
53-
-----------------
54-
55-
### Start Docker containers
56-
57-
When the containers are built you can start the containers by using the following command
58-
59-
`docker-compose up` OR `docker-compose up -d` for the _detached_ mode.
60-
61-
### Stop Docker containers
62-
63-
To stop Docker containers you can use the following command
64-
65-
`docker-compose down`
66-
67-
### Log in to Containers
68-
69-
To log in to the container you can use one of the following commands
70-
71-
- NGINX: `docker-compose exec web sh`
72-
73-
- PHP: `docker-compose exec php sh`
74-
75-
- APACHE: `docker-compose exec apache sh`
76-
77-
- MYSQL: `docker-compose exec db sh`
78-
79-
- NODEJS: `docker-compose exec nodejs sh`
80-
81-
- PHPMYADMIN: `docker-compose exec phpmyadmin sh`
31+
As a result, the application will be available at http://localhost/.
8232

83-
### Troubleshooting
33+
### Stopping the Application
8434

85-
- Docker can't run the container on the default port `80`: Please check if there is no other app which uses the same
86-
port on your machine. You can also change the default port for `nginx` in the file `docker-compose.yml`.
87-
- Can't log in to `php` container: Please check all running Docker processes by using the following command
88-
`docker-compose ps`. Check if you are using the correct name.
35+
To stop the application, run `make down`.

app/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"license": "MIT"
3+
}

docker-compose.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

etc/db/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mysql:8.1.0

etc/db/data/.gitkeep

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: '3'
2+
3+
services:
4+
php:
5+
build:
6+
context: ./../../
7+
dockerfile: ./etc/php/Dockerfile
8+
image: docker-php-local
9+
10+
db:
11+
build:
12+
context: ./../../
13+
dockerfile: ./etc/db/Dockerfile
14+
image: docker-db-local
15+
16+
phpmyadmin:
17+
build:
18+
context: ./../../
19+
dockerfile: ./etc/phpmyadmin/Dockerfile
20+
image: docker-phpmyadmin-local
21+
22+
nodejs:
23+
build:
24+
context: ./../../
25+
dockerfile: ./etc/nodejs/Dockerfile
26+
image: docker-nodejs-local
27+
28+
apache:
29+
build:
30+
context: ./../../
31+
dockerfile: ./etc/httpd/Dockerfile
32+
image: docker-apache-local
33+
34+
nginx:
35+
build:
36+
context: ./../../
37+
dockerfile: ./etc/nginx/Dockerfile
38+
image: docker-nginx-local

0 commit comments

Comments
 (0)