Skip to content

Commit 13bc61a

Browse files
committed
fix: dockerfile template
1 parent 64cadbd commit 13bc61a

File tree

5 files changed

+32
-170
lines changed

5 files changed

+32
-170
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export DOCKER_BUILDKIT ?= 1
55
export COMPOSE_DOCKER_CLI_BUILD ?= 1
66

77
IMAGE_NAMESPACE ?= wayofdev/php-base
8-
IMAGE_TEMPLATE ?= 7.4-cli-alpine
8+
IMAGE_TEMPLATE ?= 8.2-fpm-alpine
99
IMAGE_TAG ?= $(IMAGE_NAMESPACE):$(IMAGE_TEMPLATE)-latest
1010

1111
DOCKERFILE_DIR ?= ./dist/base/$(IMAGE_TEMPLATE)
@@ -68,9 +68,14 @@ PHONY: all
6868
# ------------------------------------------------------------------------------------
6969
build: ## Build default docker image
7070
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
71-
docker build . -t $(IMAGE_TAG)
71+
docker build -t $(IMAGE_TAG) .
7272
PHONY: build
7373

74+
analyze: ## Analyze docker image
75+
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
76+
dive build -t $(IMAGE_TAG) .
77+
.PHONY: analyze
78+
7479
build-from-cache: ## Build default docker image using cached layers
7580
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
7681
docker build --cache-from $(CACHE_FROM) . -t $(IMAGE_TAG)
@@ -97,7 +102,7 @@ ssh: ## Login into built image
97102
# Ansible Actions
98103
# ------------------------------------------------------------------------------------
99104
generate: ## Generates dockerfiles from ansible templates
100-
ansible-playbook src/generate.yml
105+
ansible-playbook src/playbook.yml
101106
PHONY: generate
102107

103108
clean: ## Cleans up generated files

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<br>
22

33
<div align="center">
4-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/docker-php-base/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only">
5-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/docker-php-base/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only">
4+
<img width="456" src="https://raw.githubusercontent.com/wayofdev/docker-php-base/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only" alt="WayOfDev Logo in light mode">
5+
<img width="456" src="https://raw.githubusercontent.com/wayofdev/docker-php-base/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only" alt="WayOfDev logo in dark mode">
66
</div>
77

88
<br>
@@ -13,7 +13,7 @@
1313
<a href="https://actions-badge.atrox.dev/wayofdev/docker-php-base/goto"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Fdocker-php-base%2Fbadge&style=flat-square"/></a>
1414
<a href="https://github.com/wayofdev/docker-php-base/tags"><img src="https://img.shields.io/github/v/tag/wayofdev/docker-php-base?sort=semver&style=flat-square" alt="Latest Version"></a>
1515
<a href="https://hub.docker.com/repository/docker/wayofdev/php-base"><img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/wayofdev/php-base?style=flat-square"></a>
16-
<a href="LICENSE"><img src="https://img.shields.io/github/license/wayofdev/docker-php-base.svg?style=flat-square&color=blue" alt="Software License"/></a>
16+
<a href="LICENSE.md"><img src="https://img.shields.io/github/license/wayofdev/docker-php-base.svg?style=flat-square&color=blue" alt="Software License"/></a>
1717
<a href="#"><img alt="Commits since latest release" src="https://img.shields.io/github/commits-since/wayofdev/docker-php-base/latest?style=flat-square"></a>
1818
</div>
1919

@@ -93,15 +93,6 @@ ext_pecl_enabled:
9393
- amqp
9494
- protobuf
9595
- yaml
96-
97-
ext_pecl_versions:
98-
redis: "5.3.7"
99-
decimal: "1.4.0"
100-
imagick: "3.7.0"
101-
rdkafka: "6.0.3"
102-
amqp: "1.11.0"
103-
protobuf: "3.22.5"
104-
yaml: "2.2.3"
10596
```
10697
10798
<br>
@@ -118,7 +109,7 @@ $ make generate
118109

119110
To install dependencies and start development you can check contents of our `Makefile`
120111

121-
### Requirments
112+
### Requirements
122113

123114
For testing purposes we use **goss** and **dgoss**, follow installation instructions on [their official README](https://github.com/aelsabbahy/goss/blob/master/extras/dgoss/README.md)
124115

@@ -168,7 +159,7 @@ $ make build IMAGE_TEMPLATE="8.2-supervisord-alpine"
168159

169160
## 🧪 Testing
170161

171-
You can check `Makefile` to get full list of commands for local testing. For testing you can use these comands to test whole role or separate tasks:
162+
You can check `Makefile` to get full list of commands for local testing. For testing, you can use these commands to test whole role or separate tasks:
172163

173164
Testing default image:
174165

@@ -231,10 +222,10 @@ This repository was created in **2022** by [lotyp / wayofdev](https://github.com
231222

232223
## 🫡 Contributors
233224

234-
<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/docker-php-base?style=for-the-badge"/>
225+
<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/docker-php-base?style=for-the-badge" alt="Contributors"/>
235226

236-
<a href="https://github.com/wayofdev/docker-nginx/graphs/contributors">
237-
<img src="https://opencollective.com/wod/contributors.svg?width=890&button=false">
227+
<a href="https://github.com/wayofdev/docker-php-base/graphs/contributors">
228+
<img src="https://opencollective.com/wod/contributors.svg?width=890&button=false" alt="OpenCollective Contributors">
238229
</a>
239230

240231
<br>

src/Dockerfiles/base/Dockerfile.j2

Lines changed: 16 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -33,157 +33,32 @@ ENV PHP_MEMORY_LIMIT="{{ settings_php_ini.php_memory_limit }}"
3333
ENV PHPFPM_SLOWLOG_TIMEOUT="5s"
3434
{% endif %}
3535

36+
COPY --chown=www-data ./configs/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
37+
COPY --chown=www-data ./configs/php.ini /usr/local/etc/php/conf.d/php.ini
38+
3639
RUN set -eux; \
3740
apk -U upgrade -a \
38-
# Add production dependencies
3941
{% if 'supervisord' == php_type %}
4042
&& apk add --no-cache supervisor \
4143
{% endif %}
42-
# Temporary build dependencies for compiling Pecl extensions
43-
&& apk add --no-cache --virtual .temp-build-deps \
44-
$PHPIZE_DEPS \
45-
# Intl - Internationalization; "icu-dev" is temporary build dependency
46-
{% if 'intl' in ext_native_enabled %}
47-
&& apk add --no-cache \
48-
icu-libs \
49-
icu-dev \
50-
&& docker-php-ext-install -j$(nproc) intl \
51-
&& apk del icu-dev \
52-
{% endif %}
53-
# Pcntl - Process control support
54-
{% if 'pcntl' in ext_native_enabled %}
55-
&& docker-php-ext-install -j$(nproc) pcntl \
56-
{% endif %}
57-
{% if 'sockets' in ext_native_enabled %}
58-
&& docker-php-ext-install -j$(nproc) --ini-name docker-php-ext-00-sockets.ini sockets \
59-
{% endif %}
60-
# MySQL
61-
{% if 'pdo_mysql' in ext_native_enabled %}
62-
&& docker-php-ext-install -j$(nproc) pdo_mysql \
63-
{% endif %}
64-
# Postgres; "postgresql-dev" is temporary build dependency
65-
{% if 'pdo_pgsql' in ext_native_enabled %}
66-
&& apk add --no-cache -X https://dl-cdn.alpinelinux.org/alpine/{{ os_version }}/main postgresql-dev \
67-
&& apk add --no-cache -X https://dl-cdn.alpinelinux.org/alpine/{{ os_version }}/main postgresql-libs \
68-
&& docker-php-ext-install -j$(nproc) pdo_pgsql \
69-
&& apk del postgresql-dev \
70-
{% endif %}
71-
# Opcache
72-
{% if 'OPcache' in ext_native_enabled %}
73-
&& docker-php-ext-install -j$(nproc) opcache \
74-
{% endif %}
75-
# Zip
76-
{% if 'zip' in ext_native_enabled %}
77-
&& apk add --no-cache \
78-
libzip \
79-
libzip-dev zlib-dev \
80-
&& docker-php-ext-install -j$(nproc) zip \
81-
&& apk del libzip-dev zlib-dev \
82-
{% endif %}
83-
# Bz2
84-
{% if 'bz2' in ext_native_enabled %}
85-
&& apk add --no-cache \
86-
libbz2 \
87-
bzip2-dev \
88-
&& docker-php-ext-install -j$(nproc) bz2 \
89-
&& apk del bzip2-dev \
90-
{% endif %}
91-
# Bcmath - Arbitrary Precision Mathematics
92-
{% if 'bcmath' in ext_native_enabled %}
93-
&& docker-php-ext-install -j$(nproc) bcmath \
94-
{% endif %}
95-
# Soap Messaging Protocol
96-
{% if 'soap' in ext_native_enabled %}
97-
&& apk add --no-cache libxml2-dev \
98-
&& docker-php-ext-install -j$(nproc) soap \
99-
&& apk del libxml2-dev \
100-
{% endif %}
101-
### Image Processing
102-
# https://www.php.net/manual/en/refs.utilspec.image.php
103-
# Exif - (Exchangeable image information) / Image Meta Data
104-
{% if 'exif' in ext_native_enabled %}
105-
&& docker-php-ext-install -j$(nproc) exif \
106-
{% endif %}
107-
# GD
108-
{% if 'gd' in ext_native_enabled %}
109-
&& apk add --no-cache \
110-
freetype libjpeg-turbo libpng libxpm libwebp \
111-
freetype-dev libjpeg-turbo-dev libpng-dev libxpm-dev libwebp-dev \
112-
&& docker-php-ext-configure gd --enable-gd --with-webp --with-jpeg --with-xpm --with-freetype \
113-
&& docker-php-ext-install -j$(nproc) gd \
114-
&& apk del freetype-dev libjpeg-turbo-dev libpng-dev libxpm-dev libwebp-dev \
115-
{% endif %}
116-
####################################################################################################################
117-
# Pecl Dependencies
118-
# Redis - In-memory data structure store driver; zstd-dev is temporary build dependency
119-
{% if 'redis' in ext_pecl_enabled %}
120-
&& apk add --no-cache \
121-
zstd-libs \
122-
zstd-dev \
123-
&& pecl install redis-{{ ext_pecl_versions.redis }} \
124-
&& docker-php-ext-enable redis \
125-
&& apk del zstd-dev \
126-
{% endif %}
127-
# Decimal - Correctly-rounded arbitrary precision decimal floating point arithmetic
128-
{% if 'decimal' in ext_pecl_enabled %}
129-
&& apk add --no-cache \
130-
mpdecimal-dev \
131-
mpdecimal \
132-
&& pecl install decimal-{{ ext_pecl_versions.decimal }} \
133-
&& docker-php-ext-enable decimal \
134-
&& apk del mpdecimal-dev \
135-
{% endif %}
136-
# Imagick
137-
{% if 'imagick' in ext_pecl_enabled %}
138-
&& apk add --no-cache \
139-
imagemagick libgomp \
140-
imagemagick-dev \
141-
&& pecl install imagick-{{ ext_pecl_versions.imagick }} \
142-
&& docker-php-ext-enable imagick \
143-
&& apk del imagemagick-dev \
144-
{% endif %}
145-
# Client for Apache Kafka
146-
{% if 'rdkafka' in ext_pecl_enabled %}
147-
&& apk add --no-cache \
148-
librdkafka \
149-
librdkafka-dev \
150-
&& pecl install rdkafka-{{ ext_pecl_versions.rdkafka }} \
151-
&& docker-php-ext-enable rdkafka \
152-
&& apk del librdkafka-dev \
153-
{% endif %}
154-
# AMQP - Communicate with any amqp compliant server
155-
{% if 'amqp' in ext_pecl_enabled %}
156-
&& apk add --no-cache \
157-
rabbitmq-c \
158-
rabbitmq-c-dev \
159-
&& pecl install amqp-{{ ext_pecl_versions.amqp }} \
160-
&& docker-php-ext-enable amqp \
161-
&& apk del rabbitmq-c-dev \
162-
{% endif %}
163-
# Protobuf - Google's extensible mechanism for serializing structured data.
164-
# https://spiral.dev/docs/grpc-configuration#toolkit-installation-install-protobuf-extension-optional
165-
{% if 'protobuf' in ext_pecl_enabled %}
166-
&& pecl install protobuf-{{ ext_pecl_versions.protobuf }} \
167-
&& docker-php-ext-enable --ini-name docker-php-ext-10-protobuf.ini protobuf \
168-
{% endif %}
169-
# Yaml parser and emitter
170-
{% if 'yaml' in ext_pecl_enabled %}
171-
&& apk add --no-cache \
172-
yaml \
173-
yaml-dev \
174-
&& pecl install yaml-{{ ext_pecl_versions.yaml }} \
175-
&& docker-php-ext-enable yaml \
176-
&& apk del yaml-dev \
177-
{% endif %}
44+
&& \
45+
curl -sSLf \
46+
-o /usr/local/bin/install-php-extensions \
47+
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
48+
&& chmod +x /usr/local/bin/install-php-extensions \
49+
&& install-php-extensions \
50+
{% for ext in (ext_native_enabled + ext_pecl_enabled) | unique | sort %}
51+
{{ ext }} \
52+
{% endfor %}
53+
&& install-php-extensions --cleanup \
54+
&& rm -rf /var/cache/apk/* \
55+
&& rm -rf /tmp/* \
56+
&& rm -rf /var/log/* \
17857
&& chown -R www-data:www-data /usr/local/etc/php/conf.d/ \
179-
&& apk del -f .temp-build-deps \
18058
&& rm -rf /var/www/html \
18159
&& mkdir /app \
18260
&& chown www-data:www-data /app
18361

184-
COPY --chown=www-data ./configs/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
185-
COPY --chown=www-data ./configs/php.ini /usr/local/etc/php/conf.d/php.ini
186-
18762
{% if 'fpm' == php_type %}
18863
COPY ./configs/php-fpm.d/ /usr/local/etc/php-fpm.d/
18964
{% endif %}

src/group_vars/base.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,4 @@ ext_pecl_enabled:
9898
- protobuf
9999
- yaml
100100

101-
ext_pecl_versions:
102-
redis: "5.3.7"
103-
decimal: "1.4.0"
104-
imagick: "3.7.0"
105-
rdkafka: "6.0.3"
106-
amqp: "1.11.0"
107-
protobuf: "3.22.5"
108-
yaml: "2.2.3"
109-
110101
...
File renamed without changes.

0 commit comments

Comments
 (0)