File tree Expand file tree Collapse file tree 8 files changed +87
-11
lines changed Expand file tree Collapse file tree 8 files changed +87
-11
lines changed Original file line number Diff line number Diff line change
1
+ # Target build/use environment
1
2
APP_ENV=local
3
+ BUILD_IMAGE=php-5.6-apache
4
+ BUILD_IMAGE_TAG=v0.0.3
5
+
6
+ # Making the npm versions changeable
7
+ NPM_VERSION=6.4.1
8
+
9
+ # App webserver ports
2
10
APP_PORT=8080
3
- APP_PORT_SSL =8043
11
+ APP_SSL_PORT =8043
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ Other Packages Included:
17
17
- nodejs
18
18
- default-mysql-client
19
19
- vim
20
- - npm i npm@6.4.1 -g
20
+ - npm i npm@` $NPM_VERSION ` [ ^ npm_version_note ] -g
21
21
- yaml-1.3.0
22
22
23
23
PHP Extensions:
@@ -32,10 +32,22 @@ PHP Extensions:
32
32
33
33
Build the *** Docker Image*** without using *** cached*** versions of previous image build stages.
34
34
35
+ ### Helper Script
36
+
37
+ A helper script is available with the repo to force recreate the build & use the ` docker-compose.yaml ` file which reads the ` .env ` file.
38
+
39
+ ``` bash
40
+ ./build-web.sh
41
+ ```
42
+
43
+ ### The long Way
44
+
35
45
``` bash
36
46
sudo docker build \
37
47
-f php-5-6-apache.Dockerfile \
38
48
--target php-5-6-build \
49
+ --build-arg APP_ENV=local \
50
+ --build-arg NPM_VERSION=6.4.1 \
39
51
--no-cache \
40
52
-t php-5-6-web-server:latest \
41
53
.
@@ -50,6 +62,10 @@ sudo docker build \
50
62
- Using ` --target php-5-6-build `
51
63
52
64
To select the *** build target stage*** [ ^ multi_stage_builds_note ] from the * Dockerfile* .
65
+
66
+ - Using ` --build-arg ARG=value `
67
+
68
+ To set build argument values to use.
53
69
54
70
### Create A Container
55
71
@@ -136,6 +152,8 @@ This Apache2 + PHP 5.6 build environment should ***NOT*** be used anywhere near
136
152
137
153
[ ^ docker_pull_cmd_note ] : Use ` docker pull ewc2020/web:php-5.6-apache ` to get a copy of the image.
138
154
155
+ [ ^ npm_version_note ] : Uses a ` .env ` *** build-arg*** called *** NPM_VERSION*** to specify the npm version.
156
+
139
157
[ ^ multi_stage_builds_note ] : Used mostly in *** Multi Stage*** image builds.
140
158
141
159
[ ^ compose_name_note ] : The ` php-5-6-web-server ` container name to build the image for.
Original file line number Diff line number Diff line change 5
5
# NOTE:
6
6
# Rebuild the Web Docker image composition.
7
7
8
+ echo -e " Rebuilding EWC Web Docker Image"
9
+
10
+ # source the environment variables
11
+ set -o allexport; source .env; set +o allexport
12
+
8
13
docker-compose build --no-cache php-5-6-web-server \
9
- && docker-compose up -d
14
+ && docker-compose up -d
15
+ echo -e " http://localhost:$APP_PORT /"
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ version: '3.7'
2
2
3
3
# Services/Containers to orchestrate in this composition
4
4
services :
5
+
5
6
# Basic PHP 5.6 & Apache2 Image Container
6
7
php-5-6-web-server :
7
8
container_name : php-5-6-web-server
@@ -12,21 +13,20 @@ services:
12
13
target : php-5-6-build
13
14
dockerfile : php-5-6-apache.Dockerfile
14
15
args :
16
+ - NPM_VERSION=${NPM_VERSION}
15
17
- APP_ENV=${APP_ENV}
16
18
labels :
17
19
ewc.name : " Web Server"
18
20
ewc.description : " PHP & Apache Web Server"
19
21
ewc.php.version : " 5.6"
20
- ewc.label-with-empty-value : " "
21
- image : php-5-6-web-server:latest
22
+ image : $BUILD_IMAGE:$BUILD_IMAGE_TAG
22
23
environment :
24
+ - NPM_VERSION=${NPM_VERSION}
23
25
- APP_ENV=${APP_ENV}
24
- - APP_PORT=${APP_PORT}
25
- - APP_PORT_SSL=${APP_PORT_SSL}
26
26
working_dir : /var/www
27
27
ports :
28
28
- ${APP_PORT}:80
29
- - ${APP_PORT_SSL }:443
29
+ - ${APP_SSL_PORT }:443
30
30
volumes :
31
31
- ./public_html:/var/www/html
32
32
- ./docker-files/php/local.ini:/usr/local/etc/php.ini
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # USAGE:
3
+ # env-prep.sh
4
+ #
5
+ # NOTE:
6
+ # This will copy the .env-example file to .env for use with the docker-compose.
7
+
8
+ echo -e " Initializing PHP 5.6 & Apache2 Webserver Build Environment"
9
+
10
+ if [ ! -f " $PWD /.env" ]; then
11
+ # Copy the default .env-example file
12
+ echo -e " No environment for build process"
13
+ echo -e " Copying default environment for build process"
14
+ cp -a " $PWD /.env-example" " $PWD /.env"
15
+ fi
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ FROM php:5.6-apache as php-5-6-build
4
4
LABEL evilwizardcreations.image.authors="evil.wizard95@googlemail.com" \
5
5
evilwizardcreations.image.php.version="5.6"
6
6
7
+ ARG NPM_VERSION=6.4.1
8
+ ENV NPM_VERSION=$NPM_VERSION
9
+
7
10
# copy the specific Composer PHAR version from the Composer image into the PHP image
8
11
COPY --from=composer:1.7.1 /usr/bin/composer /usr/bin/composer
9
12
@@ -31,7 +34,7 @@ RUN set -ex; \
31
34
default-mysql-client \
32
35
vim; \
33
36
apt-get clean; \
34
- npm i npm@6.4.1 -g
37
+ npm i npm@$NPM_VERSION -g
35
38
36
39
# Install some php extensions from the docker built source.
37
40
RUN docker-php-ext-install gettext mysqli pdo_mysql zip
Original file line number Diff line number Diff line change 4
4
<meta charset="UTF-8">
5
5
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6
6
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Document </title>
7
+ <title>Apache2 & PHP </title>
8
8
</head>
9
9
<body>
10
10
<p>
11
- Well look at that <?php echo " this is a php script " ; ?> <br />
11
+ Well look at that this is a php script running on PHP version <?php echo phpversion () ; ?> <br />
12
12
take a look at <a href="phpinfo.php" title="phpinfo">phpinfo()</a>
13
13
</p>
14
14
</body>
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # USAGE:
3
+ # push-build.sh
4
+ #
5
+ # NOTE:
6
+ # This wil tag the created image to the webserver repo & push the tagged imaged as latest.
7
+
8
+ echo -e " Publishing EWC Web Docker Image Build"
9
+
10
+ # source the environment variables
11
+ set -o allexport; source .env; set +o allexport
12
+
13
+ image=${BUILD_IMAGE:- php-5.6-apache}
14
+ image_tag=${BUILD_IMAGE_TAG:- v0.0.3}
15
+
16
+ # Tag the local copy to the remote webserver repo & push the release version
17
+ echo -e " Tagging build image as :$image_tag to webserver repo"
18
+ docker tag $image :$image_tag ewc2020/web:$image -$image_tag
19
+ echo -e " Pushing :$image -$image_tag to webserver repo"
20
+ docker push ewc2020/web:$image -$image_tag
21
+
22
+ # Tag the local webserver to :image & push the image tag version
23
+ echo -e " Tagging webserver image :$image -$image_tag to :$image -latest in webserver repo"
24
+ docker tag ewc2020/web:$image -$image_tag ewc2020/web:$image -latest
25
+ echo -e " Pushing :$image -latest to webserver repo"
26
+ docker push ewc2020/web:$image -latest
You can’t perform that action at this time.
0 commit comments