refactor(Dockerfile): simplify image build and permission handling
- Use fully qualified image names for clarity - Remove manual PHP extension installation as base image likely includes them - Leverage COPY --chown to set permissions directly - Remove redundant permission fix commands - Keep same final command and exposed port
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,30 +1,19 @@
|
||||
FROM thecodingmachine/php:8.4-v4-fpm-alpine
|
||||
FROM docker.io/thecodingmachine/php:8.4-v4-fpm-alpine
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www
|
||||
|
||||
# Install the PHP extension installer helper
|
||||
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
||||
|
||||
# Install system dependencies and PHP extensions in one go
|
||||
# This script handles the 'apk add' and 'apk del' for dev-libraries automatically
|
||||
RUN chmod +x /usr/local/bin/install-php-extensions && \
|
||||
install-php-extensions pdo_mysql mbstring exif pcntl bcmath gd zip intl
|
||||
|
||||
# Get latest Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy application files
|
||||
COPY . /var/www
|
||||
# TheCodingMachine images default to user 'docker' (UID 1000)
|
||||
COPY --chown=docker:docker . /var/www
|
||||
|
||||
# Fix permissions
|
||||
# We do this as root before switching to the unprivileged user
|
||||
RUN chown -R www-data:www-data /var/www && \
|
||||
find /var/www -type d -exec chmod 755 {} + && \
|
||||
find /var/www -type f -exec chmod 644 {} + && \
|
||||
rm -rf /var/www/.circleci /var/www/.github
|
||||
|
||||
USER www-data
|
||||
# You can likely remove the manual chmod/chown lines
|
||||
# as this image handles them via environment variables if needed.
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# Use the image's built-in entrypoint or your artisan command
|
||||
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]
|
||||
Reference in New Issue
Block a user