Skip to content

Commit 70ba6e3

Browse files
committed
merge develop into master
2 parents 935ad61 + e08d724 commit 70ba6e3

File tree

14 files changed

+235
-60
lines changed

14 files changed

+235
-60
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ jobs:
6565
- run:
6666
name: LIVE Build Tests
6767
command: |
68-
docker exec apache_hg-web_1 /bin/bash /opt/tests/build_tests.sh
68+
docker exec apache_web_1 /bin/bash /opt/tests/build_tests.sh
6969
7070
- run:
7171
name: Container Logs
7272
command: |
7373
mkdir -p /tmp/container-build
74-
docker logs apache_hg-web_1 > /tmp/container-build/log_output-LIVE_Apache.txt
75-
docker logs apache_hg-db_1 > /tmp/container-build/log_output-LIVE_MySQL.txt
74+
docker logs apache_web_1 > /tmp/container-build/log_output-LIVE_Apache.txt
75+
docker logs apache_db_1 > /tmp/container-build/log_output-LIVE_MySQL.txt
7676
7777
7878

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ COPY ./app /opt/app
4646
COPY ./tests /opt/tests
4747

4848
# Unit tests run via build_tests.sh
49-
RUN tar xf /opt/tests/2.1.6.tar.gz -C /opt/tests/
49+
RUN tar xf /opt/tests/shunit2-2.1.7.tar.gz -C /opt/tests/
5050

5151
# SUPERVISOR
5252
RUN chmod -R 755 /opt/* \

Makefile

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
#!/bin/sh
2+
13
# Build a container via the command "make build"
24
# By Jason Gegere <jason@htmlgraphic.com>
35

6+
SHELL = /bin/sh
7+
8+
include .env # .env file needs to created for this to work properly
9+
410
TAG = 1.8.1
511
CONTAINER = apache
612
IMAGE_REPO = htmlgraphic
713
IMAGE_NAME = $(IMAGE_REPO)/$(CONTAINER)
8-
include .env # .env file needs to created for this to work properly
14+
NODE_ENV=$(shell grep NODE_ENVIRONMENT .env | cut -d '=' -f 2-)
15+
16+
17+
ifeq ($(NODE_ENV),dev)
18+
COMPOSE_FILE = docker-compose.local.yml
19+
else
20+
COMPOSE_FILE = docker-compose.yml
21+
endif
922

1023

1124
all:: help
@@ -29,7 +42,7 @@ env:
2942
@[ ! -f .env ] && echo " .env file does not exist, copy env template \n" && cp .env.example .env || echo " env file exists \n"
3043
@echo "The following environment varibles exist:"
3144
@echo $(shell sed 's/=.*//' .env)
32-
@echo "\n"
45+
@echo ''
3346

3447

3548
build:
@@ -44,18 +57,22 @@ push:
4457
docker push $(IMAGE_NAME):$(TAG)
4558

4659
run:
47-
@echo 'Checking... initial run structure'
48-
@if [ ! -d "~/SITES/docker" ]; then \
49-
echo " Creating project folders" && sudo mkdir -p ~/SITES && sudo mkdir -p ~/SITES/docker; fi
60+
@echo 'Setting environment varibles...'
5061
@make env
51-
@echo "Upon initial setup run the following on the MySQL system, this will setup a GLOBAL admin:"
52-
@echo ""
62+
@echo "Checking... initial directory structure \n"
63+
@if [ $(NODE_ENV) == 'dev' ]; then \
64+
if [ ! -d "~/SITES/docker" ]; then \
65+
echo " Creating project folders \n" && sudo mkdir -p ~/SITES && sudo mkdir -p ~/SITES/docker; fi \
66+
fi
67+
@echo 'Run the following on the MySQL system, this will setup a GLOBAL admin:'
68+
@echo ''
5369
@echo " docker exec -it apache_db /bin/bash \n \
5470
mysql -p$(MYSQL_ROOT_PASSWORD) \n \
5571
GRANT ALL PRIVILEGES ON * . * TO '$(MYSQL_USER)'@'%' with grant option; \n"
5672

5773
@echo " THE PASSWORD FOR $(MYSQL_USER) IS $(MYSQL_PASSWORD); \n"
58-
docker-compose -f docker-compose.local.yml up -d
74+
docker-compose -f $(COMPOSE_FILE) up -d
75+
5976

6077
start: run
6178

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
[![Beerpay](https://beerpay.io/htmlgraphic/Apache/badge.svg?style=beer)](https://beerpay.io/htmlgraphic/Apache) [![Beerpay](https://beerpay.io/htmlgraphic/Apache/make-wish.svg?style=flat)](https://beerpay.io/htmlgraphic/Apache)
88

99

10-
This repo will give you a turn key Docker container build for use in **production** OR **dev**. The setup includes an Apache web service, PHP 7.3, PHP Composer, linked [MySQL 5.7.26](https://hub.docker.com/_/mysql) instance and a data container volume.
10+
This repo will give you a turn key Docker container build for use in **production** OR **dev**. The setup includes an Apache web service, PHP 7.3, PHP Composer, linked [MySQL 5.7.28](https://hub.docker.com/_/mysql) instance and a data container volume.
1111

12-
In this repo you will find a number of complete Dockerfile builds used in **dev** or **production** environments. Listed below is an explanation of each file. [Ask a question!](https://github.com/htmlgraphic/Apache/issues/new)
12+
Using containers offer a huge advantage when developing locally or in prodcution. Use this containers for development and deployment. Changing `NODE_ENVIRONMENT` within to `.env` to `dev` or `production` will offer a dynamic environment.
13+
14+
Listed below is an explanation of each file. [Ask a question!](https://github.com/htmlgraphic/Apache/issues/new)
1315

1416
#### Dependencies
1517
- Docker [Download](https://hub.docker.com/search/?type=edition&offering=community)
@@ -31,8 +33,8 @@ Apache # → Root of Docker Build
3133
│ ├── sample.conf # → located within `/data/apache2/sites-enabled` duplicate / modify to host others domains
3234
│ └── supervisord # → Supervisor is a client / server system which monitors and controls a number of processes on UNIX-like operating systems
3335
├── .env.example # → Rename file to `.env` for local environment variables used within build
34-
├── .circleci/ # → CircleCI 2.0
35-
│ └── config.yml # → CircleCI Config
36+
├── .circleci/
37+
│ └── config.yml # → CircleCI 2.0 Config
3638
├── docker-compose.local.yml # → Dev build
3739
├── docker-compose.yml # → Production build
3840
├── Dockerfile # → Uses a basefile build to help speed up the docker container build process

app/index.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@
55
<!-- Latest compiled and minified CSS -->
66
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
77
<style>
8-
body {font-family: 'Open Sans', sans-serif; font-weight: 300; font-size: 14px; text-align: center; padding: 50px; }
9-
div img#logo {margin: 0 auto 40px auto; float: none;}
8+
body {
9+
font-family: 'Open Sans', sans-serif;
10+
font-weight: 300;
11+
font-size: 14px;
12+
text-align: center;
13+
padding: 50px;
14+
}
15+
div img#logo {
16+
margin: 0 auto 40px auto;
17+
float: none;
18+
}
1019
.e {
1120
background-color: #ccf;
1221
width: 300px;
@@ -85,6 +94,26 @@
8594
<td class="text-right">SMTP_HOST</td>
8695
<td class="text-left"><?= getenv('SMTP_HOST'); ?></td>
8796
</tr>
97+
<tr>
98+
<td class="text-right">max_execution_time</td>
99+
<td class="text-left"><?= ini_get('max_execution_time'); ?></td>
100+
</tr>
101+
<tr>
102+
<td class="text-right">memory_limit</td>
103+
<td class="text-left"><?= ini_get('memory_limit'); ?></td>
104+
</tr>
105+
<tr>
106+
<td class="text-right">upload_max_filesize</td>
107+
<td class="text-left"><?= ini_get('upload_max_filesize'); ?></td>
108+
</tr>
109+
<tr>
110+
<td class="text-right">post_max_size</td>
111+
<td class="text-left"><?= ini_get('post_max_size'); ?></td>
112+
</tr>
113+
<tr>
114+
<td class="text-right">max_input_time</td>
115+
<td class="text-left"><?= ini_get('max_input_time'); ?></td>
116+
</tr>
88117
</tbody>
89118
</table>
90119
</div>

app/php_extensions.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
# Ensure that chars show in browser correctly.
3+
header('Content-Type: text/plain; charset=utf-8');
4+
5+
// The following modules, should exist in the build
6+
$mods_check = explode(',', 'apache2handler,apcu,calendar,ctype,curl,date,dom,exif,fileinfo,filter,ftp,gd,gettext,hash,iconv,imagick,json,libxml,mbstring,mcrypt,mysqli,mysqlnd,openssl,pcre,pdo,pdo_mysql,phar,posix,readline,reflection,session,shmop,simplexml,sockets,spl,standard,sysvmsg,sysvsem,sysvshm,tokenizer,wddx,xml,xmlreader,xmlwriter,xsl,zend opcache,zip,zlib');
7+
8+
// Sort alphabetically.
9+
sort($mods_check);
10+
11+
// Get regular (non-Zend) extensions.
12+
$mods = get_loaded_extensions();
13+
14+
// 'zend_extensions' param only introduced in PHP 5.2.4,
15+
// setting the param returns NULL in PHP 5.1.
16+
$zend_mods = get_loaded_extensions(true);
17+
if ($zend_mods) {
18+
$mods = array_merge($mods, $zend_mods);
19+
}
20+
$mods = array_map('strtolower', $mods);
21+
// Remove duplicates.
22+
$mods = array_unique($mods);
23+
24+
print 'Extensions: ' ."\n\n";
25+
26+
#
27+
# Output modules table.
28+
#
29+
foreach($mods_check as $mod) {
30+
# Search for Apache module, does it exist
31+
printf('%-16s ', $mod);
32+
if(in_array($mod, $mods)) {
33+
echo '| ✓ ';
34+
} else {
35+
echo '| ';
36+
}
37+
echo "\n";
38+
}

app/run.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fi
6767

6868
#####
6969
#
70-
# Edit files on the instance for improved preformance
70+
# Edit files on the container, improving preformance
7171
# Modify php.ini for each build
7272
# Check for proper environment
7373
# Route mail to SMTP queuing servers
@@ -88,11 +88,18 @@ if [ ! -f /etc/php/7.3/apache2/build ]; then
8888
sed -i 's|;session.save_path = "/var/lib/php5"|session.save_path = "/tmp"|g' /etc/php/7.3/apache2/php.ini
8989
sed -i 's|session.gc_probability = 0|session.gc_probability = 1|g' /etc/php/7.3/apache2/php.ini
9090

91-
# Increase memory & upload limitations
91+
# Update Apache / PHP Config
9292
sed -i 's|max_execution_time = 30|max_execution_time = 300|g' /etc/php/7.3/apache2/php.ini
9393
sed -i 's|memory_limit = 128M|memory_limit = -1|g' /etc/php/7.3/apache2/php.ini
9494
sed -i 's|upload_max_filesize = 2M|upload_max_filesize = 1000M|g' /etc/php/7.3/apache2/php.ini
9595
sed -i 's|post_max_size = 8M|post_max_size = 1000M|g' /etc/php/7.3/apache2/php.ini
96+
sed -i 's|max_input_time = 60|max_input_time = 300|g' /etc/php/7.3/apache2/php.ini
97+
98+
# Update CLI Config
99+
sed -i 's|memory_limit = 128M|memory_limit = -1|g' /etc/php/7.3/cli/php.ini
100+
sed -i 's|upload_max_filesize = 2M|upload_max_filesize = 1000M|g' /etc/php/7.3/cli/php.ini
101+
sed -i 's|post_max_size = 8M|post_max_size = 1000M|g' /etc/php/7.3/cli/php.ini
102+
96103

97104
# Add build file to remove duplicate script execution
98105
echo 1 > /etc/php/7.3/apache2/build

app/supervisord

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,3 @@ stderr_logfile=/var/log/supervisor/%(program_name)s-stderr.log
2929
command=/opt/app/postfix.sh
3030
autostart=true
3131
autorestart=true
32-
33-
[program:sshd]
34-
command=/usr/sbin/sshd -D

docker-compose.local.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.3'
22
services:
33
web:
44
image: 'htmlgraphic/apache:latest' # PHP v7.3.2-3+ubuntu18.04.1+deb.sury.org+1
@@ -13,8 +13,13 @@ services:
1313
- '443:443'
1414
env_file:
1515
- .env
16+
logging:
17+
driver: "json-file"
18+
options:
19+
max-size: "200k"
20+
max-file: "10"
1621
db:
17-
image: 'mysql:5.7.25'
22+
image: 'mysql:5.7.28'
1823
container_name: apache_db
1924
volumes:
2025
- 'db-data:/var/lib/mysql'

docker-compose.yml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
version: '3'
2-
hg-web:
3-
image: 'htmlgraphic/apache:envoyer' # PHP v7.3.2-3+ubuntu18.04.1+deb.sury.org+1
4-
ports:
5-
- "80:80"
6-
- "443:443"
7-
environment:
8-
- NODE_ENVIRONMENT=production
9-
env_file:
10-
- .env
11-
links:
12-
- "hg-db:mysql"
13-
hg-db:
14-
image: 'mysql:5.7.25'
15-
environment:
16-
- MYSQL_DATABASE=htmlgraphic
17-
- MYSQL_PASSWORD=new_password
18-
- MYSQL_ROOT_PASSWORD=new_passwordac
19-
- MYSQL_USER=admin
20-
expose:
21-
- "3306"
22-
volumes_from:
23-
- db-data
24-
db-data:
25-
image: 'busybox:latest'
26-
volumes:
27-
- "/var/lib/mysql"
1+
version: '3.3'
2+
services:
3+
web:
4+
image: 'htmlgraphic/apache:envoyer' # PHP v7.3.2-3+ubuntu18.04.1+deb.sury.org+1
5+
ports:
6+
- "80:80"
7+
- "443:443"
8+
env_file:
9+
- .env
10+
volumes:
11+
- '/var/data:/data'
12+
- '/etc/letsencrypt:/etc/letsencrypt'
13+
links:
14+
- "db:mysql"
15+
logging:
16+
driver: "json-file"
17+
options:
18+
max-size: "200k"
19+
max-file: "10"
20+
db:
21+
image: 'mysql:5.7.28'
22+
environment:
23+
- MYSQL_DATABASE=htmlgraphic
24+
- MYSQL_PASSWORD=new_password
25+
- MYSQL_ROOT_PASSWORD=new_passwordac
26+
- MYSQL_USER=admin
27+
expose:
28+
- "3306"
29+
volumes:
30+
- 'db-data:/var/lib/mysql'
31+
volumes:
32+
db-data:

0 commit comments

Comments
 (0)