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
12APP_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
210APP_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:
1717- nodejs
1818- default-mysql-client
1919- vim
20- - npm i npm@6.4.1 -g
20+ - npm i npm@` $NPM_VERSION ` [ ^ npm_version_note ] -g
2121- yaml-1.3.0
2222
2323PHP Extensions:
@@ -32,10 +32,22 @@ PHP Extensions:
3232
3333Build the *** Docker Image*** without using *** cached*** versions of previous image build stages.
3434
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+
3545``` bash
3646sudo docker build \
3747 -f php-5-6-apache.Dockerfile \
3848 --target php-5-6-build \
49+ --build-arg APP_ENV=local \
50+ --build-arg NPM_VERSION=6.4.1 \
3951 --no-cache \
4052 -t php-5-6-web-server:latest \
4153 .
@@ -50,6 +62,10 @@ sudo docker build \
5062- Using ` --target php-5-6-build `
5163
5264 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.
5369
5470### Create A Container
5571
@@ -136,6 +152,8 @@ This Apache2 + PHP 5.6 build environment should ***NOT*** be used anywhere near
136152
137153[ ^ docker_pull_cmd_note ] : Use ` docker pull ewc2020/web:php-5.6-apache ` to get a copy of the image.
138154
155+ [ ^ npm_version_note ] : Uses a ` .env ` *** build-arg*** called *** NPM_VERSION*** to specify the npm version.
156+
139157[ ^ multi_stage_builds_note ] : Used mostly in *** Multi Stage*** image builds.
140158
141159[ ^ 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 55# NOTE:
66# Rebuild the Web Docker image composition.
77
8+ echo -e " Rebuilding EWC Web Docker Image"
9+
10+ # source the environment variables
11+ set -o allexport; source .env; set +o allexport
12+
813docker-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'
22
33# Services/Containers to orchestrate in this composition
44services :
5+
56 # Basic PHP 5.6 & Apache2 Image Container
67 php-5-6-web-server :
78 container_name : php-5-6-web-server
@@ -12,21 +13,20 @@ services:
1213 target : php-5-6-build
1314 dockerfile : php-5-6-apache.Dockerfile
1415 args :
16+ - NPM_VERSION=${NPM_VERSION}
1517 - APP_ENV=${APP_ENV}
1618 labels :
1719 ewc.name : " Web Server"
1820 ewc.description : " PHP & Apache Web Server"
1921 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
2223 environment :
24+ - NPM_VERSION=${NPM_VERSION}
2325 - APP_ENV=${APP_ENV}
24- - APP_PORT=${APP_PORT}
25- - APP_PORT_SSL=${APP_PORT_SSL}
2626 working_dir : /var/www
2727 ports :
2828 - ${APP_PORT}:80
29- - ${APP_PORT_SSL }:443
29+ - ${APP_SSL_PORT }:443
3030 volumes :
3131 - ./public_html:/var/www/html
3232 - ./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
44LABEL evilwizardcreations.image.authors="evil.wizard95@googlemail.com" \
55 evilwizardcreations.image.php.version="5.6"
66
7+ ARG NPM_VERSION=6.4.1
8+ ENV NPM_VERSION=$NPM_VERSION
9+
710# copy the specific Composer PHAR version from the Composer image into the PHP image
811COPY --from=composer:1.7.1 /usr/bin/composer /usr/bin/composer
912
@@ -31,7 +34,7 @@ RUN set -ex; \
3134 default-mysql-client \
3235 vim; \
3336 apt-get clean; \
34- npm i npm@6.4.1 -g
37+ npm i npm@$NPM_VERSION -g
3538
3639# Install some php extensions from the docker built source.
3740RUN docker-php-ext-install gettext mysqli pdo_mysql zip
Original file line number Diff line number Diff line change 44 <meta charset="UTF-8">
55 <meta http-equiv="X-UA-Compatible" content="IE=edge">
66 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7- <title>Document </title>
7+ <title>Apache2 & PHP </title>
88</head>
99<body>
1010 <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 />
1212 take a look at <a href="phpinfo.php" title="phpinfo">phpinfo()</a>
1313 </p>
1414</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