-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (55 loc) · 1.58 KB
/
Dockerfile
File metadata and controls
65 lines (55 loc) · 1.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
# Define PHP version argument before the FROM instruction
ARG PHP_VERSION=8.1
FROM php:${PHP_VERSION}-cli
# Accept UID and GID as build arguments
ARG UID
ARG GID
# Install system dependencies and PHP extensions
RUN apt-get update && apt-get install -y \
git \
unzip \
curl \
libzip-dev \
libpq-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
libonig-dev \
libxml2-dev \
libmcrypt-dev \
libssl-dev \
zlib1g-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
pdo_pgsql \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
soap \
intl \
opcache \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Install and enable PCOV for code coverage (preferred for performance)
RUN pecl install pcov && \
docker-php-ext-enable pcov
# Alternatively, install and enable Xdebug for code coverage and debugging (optional)
# RUN pecl install xdebug && \
# docker-php-ext-enable xdebug && \
# echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
# Add a non-root user with UID and GID from arguments
RUN groupadd -g $GID appgroup && \
useradd -u $UID -g appgroup -m appuser
# Switch to the non-root user
USER appuser
# Set working directory
WORKDIR /app
# Set Git safe directory for the host-mounted folder
RUN git config --global --add safe.directory /app
# Default command
CMD ["php", "-a"]