Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created July 20, 2025 13:26
Show Gist options
  • Save radityopw/ee4d4d99fc305692db6cdbb30db6f812 to your computer and use it in GitHub Desktop.
Save radityopw/ee4d4d99fc305692db6cdbb30db6f812 to your computer and use it in GitHub Desktop.
Docker file untuk php 8.3 yang dibuat khusus untuk GCP dengan library firestore dan cloud storage
# Use the official PHP image.
# https://hub.docker.com/_/php
FROM php:8.3-apache
# Menginstal dependensi yang diperlukan untuk ekstensi PHP
# Pastikan untuk membersihkan cache APT setelah instalasi untuk menjaga ukuran image tetap kecil
RUN apt-get update && apt-get install -y libcurl4-openssl-dev autoconf zlib1g-dev && rm -rf /var/lib/apt/lists/*
# Menginstal ekstensi PHP curl
RUN docker-php-ext-install curl
# Configure PHP for Cloud Run.
# Precompile PHP code with opcache.
RUN docker-php-ext-install -j "$(nproc)" opcache
RUN set -ex; \
{ \
echo "; Cloud Run enforces memory & timeouts"; \
echo "memory_limit = -1"; \
echo "max_execution_time = 0"; \
echo "; File upload at Cloud Run network limit"; \
echo "upload_max_filesize = 32M"; \
echo "post_max_size = 32M"; \
echo "; Configure Opcache for Containers"; \
echo "opcache.enable = On"; \
echo "opcache.validate_timestamps = Off"; \
echo "; Configure Opcache Memory (Application-specific)"; \
echo "opcache.memory_consumption = 32"; \
} > "$PHP_INI_DIR/conf.d/cloud-run.ini"
RUN pecl install protobuf \
&& docker-php-ext-enable protobuf
RUN pecl install grpc \
&& docker-php-ext-enable grpc
# Ensure the webserver has permissions to execute index.php
RUN chown -R www-data:www-data /var/www/html
# Use the PORT environment variable in Apache configuration files.
# https://cloud.google.com/run/docs/reference/container-contract#port
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
# Configure PHP for production.
# Switch to the production php.ini for production operations.
# RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# https://github.com/docker-library/docs/blob/master/php/README.md#configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment