Skip to content

Commit c6c709c

Browse files
committed
Adding support for Docker container
1 parent 369ff66 commit c6c709c

12 files changed

+982
-200
lines changed

GetAddressByDescription.jar

3.18 KB
Binary file not shown.

composer.lock

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

docker-compose.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1-
version: '3'
2-
1+
version: "3.7"
32
services:
4-
5-
web:
6-
image: nginx:latest
7-
ports:
8-
- "8080:80"
3+
web-server:
4+
build:
5+
dockerfile: php.Dockerfile
6+
context: .
7+
restart: always
98
volumes:
10-
- ./:/var/www
11-
- ./docker/default.conf:/etc/nginx/conf.d/default.conf
12-
links:
13-
- php
9+
- "./:/var/www/"
10+
- "./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini"
11+
- "./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
12+
ports:
13+
- "8181:80"
14+
extra_hosts:
15+
- "outside:${HOST_IP}"
16+
environment:
17+
- HOST_IP=${HOST_IP}
1418

15-
php:
16-
build:
17-
context: ./docker/php
19+
mysql-server:
20+
image: mysql:8.0.19
21+
restart: always
22+
environment:
23+
MYSQL_ROOT_PASSWORD: secret
1824
volumes:
19-
- ./:/var/www
25+
- mysql-data:/var/lib/mysql
2026

27+
phpmyadmin:
28+
image: phpmyadmin/phpmyadmin:5.0.1
29+
restart: always
30+
environment:
31+
PMA_HOST: mysql-server
32+
PMA_USER: root
33+
PMA_PASSWORD: secret
34+
ports:
35+
- "5000:80"
36+
volumes:
37+
mysql-data:

docker-instructions.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Turn the container up
2+
docker compose up -d
3+
4+
# List the containers running
5+
docker compose ps
6+
7+
# Turn the container down
8+
docker compose down
9+
10+
# List the volumes
11+
docker volume ls
12+
13+
# Delete the MySQL volume
14+
docker volume rm lamp_mysql-data
15+
16+
# http://localhost:5000/index.php
17+
# http://localhost:8181/index.php
18+
19+
# List modules enabled by default on PHP 7.2, PHP 7.3 and PHP 7.4 Docker containers:
20+
21+
docker run -it --rm php:7.2-fpm php -m
22+
docker run -it --rm php:7.3-fpm php -m
23+
docker run -it --rm php:7.4-fpm php -m
24+
25+
docker run -it --rm php:7.2-apache php -m
26+
docker run -it --rm php:7.3-apache php -m
27+
docker run -it --rm php:7.4-apache php -m
28+
29+
# -----
30+
31+
java -jar GetAddressByDescription.jar "802.11n USB Wireless LAN Card" > host_ip.txt && set /p HOST_IP=<host_ip.txt && rm -rf host_ip.txt echo %HOST_IP% && docker-compose up -d
32+
php -d memory_limit=-1 my_script.php
33+
34+
# The --build flag builds images before starting containers. It’s essential to use this flag because without it the changes that we made in php.Dockerfile won’t take effect.
35+
docker-compose up -d --build web-server

docker/default.conf

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

docker/php/Dockerfile

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

docker/php/conf.d/error_reporting.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error_reporting=E_ALL

docker/php/conf.d/xdebug.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
zend_extension=xdebug
2+
3+
[xdebug]
4+
xdebug.mode=develop,debug
5+
xdebug.client_host=host.docker.internal
6+
xdebug.start_with_request=yes
File renamed without changes.

html/info.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
phpinfo();

html/xdebug-info.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
xdebug_info();
3+
exit;

php.Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM php:7.4-apache
2+
3+
RUN apt -y update
4+
RUN apt -y upgrade
5+
RUN apt -y install apt-utils
6+
7+
RUN apt-get -y update
8+
RUN apt-get -y install git unzip vim zip
9+
RUN apt-get -y install libcurl4-openssl-dev pkg-config
10+
RUN apt-get -y install curl
11+
RUN apt-get -y install libonig-dev
12+
RUN apt-get -y install libpq-dev
13+
RUN apt-get -y install iputils-ping
14+
15+
# https://github.com/dbcli/mycli
16+
RUN apt-get -y install mycli
17+
18+
RUN docker-php-ext-install curl
19+
RUN docker-php-ext-install json
20+
RUN docker-php-ext-install mbstring
21+
RUN docker-php-ext-install mysqli
22+
RUN docker-php-ext-install pdo
23+
RUN docker-php-ext-install pdo_mysql
24+
RUN docker-php-ext-install pdo_pgsql
25+
RUN docker-php-ext-install pgsql
26+
27+
RUN pecl install xdebug && docker-php-ext-enable xdebug
28+
29+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
30+
RUN a2enmod rewrite && service apache2 restart

0 commit comments

Comments
 (0)