Skip to content

Commit 4e0a7e8

Browse files
committed
Multiple Makefile improvements. Moved templates into template/
1 parent 13621a4 commit 4e0a7e8

7 files changed

Lines changed: 47 additions & 18 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea/
2+
generated/

Makefile

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,55 @@
1-
V=5.6
21
VERSION=1.0.0
3-
IMAGE=jestefane/php-$(V)-cli:$(VERSION)
4-
52
VERSIONS=5.5 5.6 7.0 7.1
3+
GENERATED_DIR=generated
4+
BUILDS_DIR=$(GENERATED_DIR)/builds
5+
BINS_DIR=$(GENERATED_DIR)/bins
6+
BIN_DIR=/usr/local/bin
67

7-
build:
8-
@echo Building $(IMAGE)
9-
docker build -t $(IMAGE) $(V)
10-
11-
rm_image:
12-
docker rmi $(IMAGE) || true
8+
builds: templates
9+
@{ \
10+
for version in $(VERSIONS); \
11+
do \
12+
cli=jestefane/php-dev:$$version-cli-$(VERSION); \
13+
echo Building $$cli; \
14+
docker build -t $$cli $(BUILDS_DIR)/$$version; \
15+
done; \
16+
}
1317

14-
rebuild: rm_image build
18+
rm_images:
19+
@{ \
20+
for version in $(VERSIONS); \
21+
do \
22+
cli=jestefane/php-dev:$$version-cli-$(VERSION); \
23+
docker rmi $$cli || true; \
24+
done; \
25+
}
1526

27+
rebuild: rm_images builds
1628

17-
templates:
18-
{ \
29+
templates: rm_templates
30+
@{ \
1931
for version in $(VERSIONS); \
2032
do \
33+
echo Building for PHP $$version; \
2134
regex=s!%%PHP_VERSION%%!$$version!g\;s!%%IMAGE_VERSION%%!$(VERSION)!g; \
22-
mkdir -p $$version; \
23-
cp php.ini $$version; \
24-
sed $$regex Dockerfile.template > $$version/Dockerfile; \
25-
sed $$regex composer.template > bins/composer-$$version; \
35+
version_dir=$(BUILDS_DIR)/$$version; \
36+
mkdir -p $$version_dir; \
37+
sed $$regex template/Dockerfile.template > $$version_dir/Dockerfile; \
38+
echo ... Dockerfile; \
39+
cp template/php.ini $$version_dir; \
40+
mkdir -p $(BINS_DIR); \
41+
sed $$regex template/php-cli.template > $(BINS_DIR)/php-cli-$$version; \
42+
echo ... php-cli bin; \
43+
sed $$regex template/composer.template > $(BINS_DIR)/composer-$$version; \
44+
echo ... composer bin; \
2645
done; \
2746
}
2847

48+
rm_templates:
49+
@echo Deleting generated templates
50+
@rm -Rf $(GENERATED_DIR)
51+
52+
cp_bins:
53+
@chmod +x $(BINS_DIR)/*
54+
@cp $(BINS_DIR)/* $(BIN_DIR)
55+
@echo Copied bins into $(BIN_DIR)

php.ini

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

template/php-cli.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker run --rm -it -w=/app -v $(pwd):/app -v ~/.ssh:/root/.ssh -v $HOME/.composer-docker:/composer jestefane/php-dev:%%PHP_VERSION%%-cli-%%IMAGE_VERSION%% $@
File renamed without changes.

0 commit comments

Comments
 (0)