-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (60 loc) · 2.58 KB
/
Dockerfile
File metadata and controls
68 lines (60 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# syntax=docker/dockerfile:1
###
# PHP Dev Container
# Utility Tools: PHP, bash, Composer, Box, micro.sfx
###
ARG PHP_VERSION=8.5.4
FROM php:${PHP_VERSION}-cli-alpine AS php_dev_container
# Composer environment variables:
# * default user is superuser (root), so allow them
# * put cache directory in a readable/writable location
# _Note_: When running `composer` in container, use `--no-cache` option
ENV COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_CACHE_DIR=/tmp/.composer/cache
# Install dependencies:
# * bash: for shell access and scripting
# * curl: for downloading build tools (box, micro.sfx)
# * libzip-dev: for composer packages that use ZIP archives
# _Note (Alpine)_: `--no-cache` includes `--update` and keeps image size minimal
#
# Then install PHP extensions
#
# _Note (Hadolint)_: No version locking, since Alpine only ever provides one version
# hadolint ignore=DL3018
RUN apk add --update --no-cache \
bash \
curl \
libzip-dev \
unzip
# Copy Composer binary from composer image
# _Note (Hadolint)_: False positive as `COPY` works with images too
# See: https://github.com/hadolint/hadolint/issues/197#issuecomment-1016595425
# hadolint ignore=DL3022
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Download Box (PHAR builder) — used by `make app-phar`
# https://github.com/box-project/box/releases
ARG BOX_VERSION=4.7.0
RUN curl --fail --location --silent \
-o /usr/local/bin/box \
"https://github.com/box-project/box/releases/download/${BOX_VERSION}/box.phar" \
&& chmod +x /usr/local/bin/box
# Download micro.sfx (static PHP runtime) for all target platforms — used by `make app-prep-release`
# https://static-php.dev/en/guide/precompiled.html
ARG PHP_VERSION
RUN for PLATFORM in linux-x86_64 linux-aarch64 macos-x86_64 macos-aarch64; do \
curl --fail --location --silent \
-o /tmp/micro.tar.gz \
"https://dl.static-php.dev/static-php-cli/common/php-${PHP_VERSION}-micro-${PLATFORM}.tar.gz" \
&& tar xzf /tmp/micro.tar.gz -C /usr/local/lib/ \
&& mv /usr/local/lib/micro.sfx "/usr/local/lib/micro-${PLATFORM}.sfx" \
&& rm /tmp/micro.tar.gz; \
done \
&& curl --fail --location --silent \
-o /tmp/micro-win.zip \
"https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${PHP_VERSION}-micro-win.zip" \
&& unzip -q /tmp/micro-win.zip micro.sfx -d /usr/local/lib/ \
&& mv /usr/local/lib/micro.sfx /usr/local/lib/micro-windows-x86_64.sfx \
&& rm /tmp/micro-win.zip
WORKDIR /app
# Copy the application files (excluding those listed in .dockerignore)
COPY . .