-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (55 loc) · 1.91 KB
/
Dockerfile
File metadata and controls
63 lines (55 loc) · 1.91 KB
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
57
58
59
60
61
62
63
FROM php:7.4.26-apache-buster
LABEL maintainer="tiago.dweb@gmail.com"
# 1. Install development packages and clean up apt cache.
RUN apt-get update && apt-get install -y \
curl \
g++ \
git \
libbz2-dev \
libfreetype6-dev \
libicu-dev \
libjpeg-dev \
libmcrypt-dev \
libpng-dev \
libreadline-dev \
libzip-dev \
libonig-dev \
sudo \
unzip \
zip && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
# 2. Apache configs + document root.
ENV SERVER_NAME=localhost
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN echo "ServerName ${SERVER_NAME}" >> /etc/apache2/apache2.conf && \
sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers
# 4. Start with base PHP config, then add extensions.
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" \
&& docker-php-ext-install \
bcmath \
bz2 \
calendar \
iconv \
intl \
mbstring \
opcache \
pdo_mysql \
zip && \
docker-php-ext-configure gd && \
docker-php-ext-install -j$(nproc) gd && \
docker-php-source delete
COPY php/override.ini "$PHP_INI_DIR/conf.d/override.ini"
# 5. Composer.
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# 6. Create new user appuser which will be running inside the container
# it will have www-data as a secondary group and will sync with the same 1000 id set inside out .env file
ARG uid=1000
RUN useradd -u ${uid} -g www-data -m -s /bin/bash appuser
USER appuser
# 7. Test if container is still working.
HEALTHCHECK --interval=60s --timeout=30s CMD nc -zv localhost 80 || exit 1