Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.

Commit a5d3d1c

Browse files
committed
updated readme
1 parent 8302e34 commit a5d3d1c

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,17 @@ Options:
1212
- `--env` builds the image
1313
with configuration stored in config-{env} folder
1414
- `--php` selects php version (builds from the {version}-fpm-alpine base).
15+
- `--customize folder` the name of the folder under `custom` to build from the resulting image. By default all folders under custom will be built.
16+
17+
The script will automatically build your custom images by placing your Dockerfiles in the `custom` folder. Your image will have the name of the folder it is placed in, tagged with latest. E.g. for the example folder the image will be built as `example:latest`.
1518

1619
Example:
1720

18-
`./build.sh devimage:latest --env dev --php 7.1.8`
21+
`./build.sh phpdevbase:latest --env dev --php 7.1.8 --customize phpdev`
1922

2023
Then you can start your container with the built image:
2124

22-
`docker run -d -p 31287:80 --name dev-container devimage:latest`
23-
24-
Or base your images on it (Dockerfile):
25-
26-
FROM devimage:latest
27-
28-
ENV SERVER_ROOT /var/www/public
29-
ENV APP_ENV dev
30-
31-
EXPOSE 80
25+
`docker run -d -p 31287:80 --name dev-container phpdev:latest`
3226

3327
Available PHP versions:
3428

build.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ optional arguments:
3939
--help displays this help message
4040
--env environment use config-{env} configuration
4141
--php version set php version / base image
42+
--customize folder the folder under ./custom to build from the resulting image;
43+
44+
By default the script will build all folders in ./custom
4245
4346
EOM
4447

@@ -62,24 +65,28 @@ success() {
6265
for arg in "$@"; do
6366
shift
6467
case "$arg" in
65-
"--help") set -- "$@" "-h" ;;
66-
"--env") set -- "$@" "-e" ;;
67-
"--php") set -- "$@" "-p" ;;
68-
*) set -- "$@" "$arg"
68+
"--help") set -- "$@" "-h" ;;
69+
"--env") set -- "$@" "-e" ;;
70+
"--php") set -- "$@" "-p" ;;
71+
"--customize") set -- "$@" "-c" ;;
72+
*) set -- "$@" "$arg"
6973
esac
7074
done
7175

7276
shift
7377

7478
# Parse short options
75-
while getopts "e:p:" o; do
79+
while getopts "e:p:c:" o; do
7680
case "${o}" in
7781
e)
7882
e=${OPTARG}
7983
;;
8084
p)
8185
p=${OPTARG}
8286
;;
87+
c)
88+
c=${OPTARG}
89+
;;
8390
*)
8491
usage
8592
;;
@@ -90,6 +97,7 @@ shift $((OPTIND-1))
9097

9198
CONFIG_DIR=$e
9299
CONFIG_VER=$p
100+
CUSTOMIZE=$c
93101

94102
#Init defaults
95103
if
@@ -136,7 +144,11 @@ if [ -d "$PWD/custom" ]; then
136144

137145
for i in * ; do
138146

139-
if [ -d "$i" ] && [ -f "${BUILD_DIR}/${i}/Dockerfile" ]; then
147+
if [ ! -z "$CUSTOMIZE" ] && [ "$i" != "$CUSTOMIZE" ]; then
148+
continue
149+
fi
150+
151+
if [ -d "$i" ] && [ -f "${BUILD_DIR}/${i}/Dockerfile" ]; then
140152

141153
DOCKERFILE_PATH="${BUILD_DIR}/${i}/Dockerfile"
142154
info "Building custom image $i:latest ..."
@@ -146,7 +158,9 @@ if [ -d "$PWD/custom" ]; then
146158
--build-arg BUILD_FROM="${BUILDNAME}" \
147159
"$BUILD_DIR/$i"
148160

149-
fi
161+
else
162+
warning "Folder ${i} can't be built. Dockerfile missing!"
163+
fi
150164

151165
done
152166

custom/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*
12
!example

custom/example/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ FROM $BUILD_FROM
66
#Start your customizations here
77

88
#Example
9-
#
10-
#PostregSQL and zip suppoer
11-
#RUN set -ex \
12-
# && apk --no-cache add postgresql-dev \
13-
# && docker-php-ext-install pdo pdo_pgsql zip
9+
10+
#PostregSQL and zip support
11+
RUN set -ex \
12+
&& apk --no-cache add postgresql-dev \
13+
&& docker-php-ext-install pdo pdo_pgsql zip
1414

1515
#Expose port 80
16-
#EXPOSE 80
16+
EXPOSE 80

0 commit comments

Comments
 (0)