-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (54 loc) · 1.48 KB
/
Dockerfile
File metadata and controls
69 lines (54 loc) · 1.48 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
69
ARG PHP_VERSION=8.1
FROM php:${PHP_VERSION}-cli-alpine
LABEL maintainer="lorenzo.dessimoni@gmail.com" \
version="1.0"
# Install runtime dependencies
RUN apk add --no-cache \
bash \
git \
libstdc++ \
vim \
nano \
curl \
aspell \
aspell-en
# Install build dependencies for PHP extensions
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
autoconf \
g++ \
make \
linux-headers
# Install Xdebug (optional based on XDEBUG_MODE)
ARG XDEBUG_MODE=off
RUN if [ "${XDEBUG_MODE}" != "0" ] && [ "${XDEBUG_MODE}" != "off" ]; then \
pecl install xdebug && docker-php-ext-enable xdebug; \
fi
# Remove build dependencies
RUN apk del .build-deps
# Install Composer
ARG COMPOSER_VERSION=2.9.2
RUN curl -L -o /usr/local/bin/composer \
https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar \
&& chmod +x /usr/local/bin/composer
# Verify installations
RUN php -v && composer --version
# Create non-root user
ARG USER_ID=1000
ARG GROUP_ID=1000
RUN addgroup -g ${GROUP_ID} app \
&& adduser -D -u ${USER_ID} -G app app
# Create Composer directories with proper permissions
RUN mkdir -p /home/app/.composer/cache \
&& chown -R app:app /home/app/.composer
# Set working directory
WORKDIR /app
# Change ownership
RUN chown -R app:app /app
# Switch to non-root user
USER app
# Set default command
CMD ["bash"]
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD php -v || exit 1