Update dockerfile

pull/8/head
SuperDev 3 years ago committed by GitHub
parent ace1733843
commit 6e9a7e95ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,61 +1,30 @@
FROM php:7.4-apache FROM php:7.4-apache
COPY . /var/www/html
RUN docker-php-ext-install pdo_mysql
COPY . /var/www/html RUN set -eux; apt-get update; \
apt-get install -y --no-install-recommends libpq-dev \
RUN apt-get update #
# install curl
# 1. development packages libcurl4-openssl-dev \
RUN apt-get install -y \ #
git \ # install gd dependencies
zip \ zlib1g-dev libpng-dev libjpeg-dev \
curl \ libwebp-dev libxpm-dev libfreetype6-dev; \
sudo \ #
nano \ # clean up
unzip \ rm -rf /var/lib/apt/lists/*; \
libicu-dev \ #
libbz2-dev \ # configure extensions
libpng-dev \ docker-php-ext-configure gd --enable-gd \
libjpeg-dev \ --with-jpeg --with-webp --with-xpm --with-freetype; \
libmcrypt-dev \ #
libreadline-dev \ # install extensions
libfreetype6-dev \ docker-php-ext-install curl gd pdo pdo_mysql pdo_pgsql exif; \
g++ #
# set up environment
# 2. apache configs + document root a2enmod rewrite;
ENV APACHE_DOCUMENT_ROOT=/var/www/html
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf #
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf # copy files
COPY --chown=33:33 . /var/www/html
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers VOLUME /var/www/html/data
# 4. start with base php config, then add extensions
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN docker-php-ext-configure gd && docker-php-ext-install gd
RUN docker-php-ext-install \
bz2 \
intl \
iconv \
bcmath \
opcache \
calendar \
exif \
pdo_mysql
# 5. composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# 6. we need a user with the same UID/GID with host user
# so when we execute CLI commands, all the host file's ownership remains intact
# otherwise command from inside container will create root-owned files and directories
ARG uid
RUN useradd -G www-data,root -u 911 -d /home/devuser devuser
RUN mkdir -p /home/devuser/.composer && \
chown -R devuser:devuser /home/devuser && \
chown -R devuser /home/devuser/.composer/
CMD ["apache2ctl", "-D", "FOREGROUND"]

Loading…
Cancel
Save