drewm-mailchimp-api
SUCCESS
33m 38s
History Source
SummaryIterations3Transcript48Dockerfile
Dockerfile53 lines · 1264 chars
# Multi-stage build using the official Composer image for dependency installation
FROM composer:2 as builder

WORKDIR /app

# Copy the repository into the builder
COPY . .

# Create a sanitized composer.json to avoid dev dependencies and phpunit constraints during build
RUN cat > composer.json <<'JSON'
{
  "name": "drewm/mailchimp-api",
  "description": "MailChimp API",
  "license": "MIT",
  "require": {
    "php": ">=5.3",
    "ext-curl": "*",
    "ext-json": "*"
  },
  "autoload": {
    "psr-4": {
      "DrewM\\MailChimp\\": "src"
    }
  }
}
JSON

# Install PHP dependencies (no dev dependencies to avoid PHPUnit constraints)
RUN composer install --no-interaction --prefer-dist --no-progress --no-dev

# Runtime image using PHP 8.4 on Alpine
FROM php:8.4.19-fpm-alpine3.22

# Install runtime system dependencies
RUN apk add --no-cache curl unzip

WORKDIR /app

# Copy vendor and source from builder
COPY --from=builder /app/vendor /app/vendor
COPY --from=builder /app/src /app/src
COPY --from=builder /app/composer.json /app/composer.json

# Ensure correct permissions for the www-data user
RUN chown -R www-data:www-data /app
USER www-data

# Expose port for PHP-FPM (default in this image)
EXPOSE 9000

# Run PHP-FPM in foreground
CMD ["php-fpm", "-F"]