-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
56 lines (49 loc) · 1.97 KB
/
Dockerfile
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
FROM php:7.4.30-apache
ARG DEBIAN_FRONTEND=noninteractive
# Update
RUN apt-get -y update --fix-missing && \
apt-get --no-install-recommends install -y apt-utils && \
apt-get install -y libzip-dev && \
apt-get install -y zip && \
apt-get install -y libcurl4-openssl-dev && \
apt-get install -y curl && \
apt-get install -y git && \
apt-get install -y openssl && \
apt-get install -y libicu-dev && \
apt-get install -y libsqlite3-dev && \
apt-get install -y libsqlite3-0
# 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"
# Install required PHP Extensions
RUN docker-php-ext-install pdo_mysql \
&& docker-php-ext-install pdo_sqlite \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install json \
&& docker-php-ext-install pcntl \
&& docker-php-ext-install zip \
&& docker-php-ext-install curl \
&& docker-php-ext-install bcmath \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# 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
# Enable apache module rewrite
RUN a2enmod rewrite headers