Fixed directory for apache, set user and group to 10001
Build and Push Alpine PHP Image / Build and push image (push) Successful in 55s Details
Build and Push Alpine PHP Image / Build and push apache image (push) Failing after 27s Details
Build and Push Ubuntu PHP 8.3 Image / Build and push image (push) Successful in 55s Details

This commit is contained in:
Aditya Prima 2024-09-22 20:42:18 +07:00
parent 2070857370
commit 89b6e491f7
1 changed files with 21 additions and 11 deletions

View File

@ -2,28 +2,34 @@ ARG REGISTRY_URL=git.winteraccess.id/docker
ARG PHP=8.3
FROM ${REGISTRY_URL}/php:${PHP}-alpine
LABEL maintainer "<Muhamad Aditya Prima> aprimediet@gmail.com"
LABEL maintainer="<Muhamad Aditya Prima> aprimediet@gmail.com"
# DEFINE ENV
ENV SERVER_ROOT /app
ENV SERVER_ADMIN you@example.com
ENV APP_DIR ${SERVER_ROOT}/htdocs
ENV LOG_LEVEL info
ENV PHP_MEMORY_LIMIT 256M
ENV SERVER_ROOT=/app
ENV SERVER_ADMIN=you@example.com
ENV APP_DIR=${SERVER_ROOT}/htdocs
ENV LOG_LEVEL=info
ENV PHP_MEMORY_LIMIT=256M
# SET WORKDIR
WORKDIR /tmp
# SETUP APACHE2 USER
RUN addgroup -g 10001 apache && adduser -D -u 10001 -G apache -s /bin/sh -h ${APP_DIR} apache
# INSTALL APACHE2
RUN --mount=type=cache,target=/var/cache/apk \
apk upgrade && apk add --update \
apache2 php${PHP_VERSION}-apache2
# CREATE SYMLINKS TO /app
RUN mkdir -p /app/htdocs && \
ln -s /var/log/apache2 /app/logs && \
ln -s /usr/lib/apache2 /app/modules && \
ln -s /run/apache2 /app/run
RUN mkdir -p ${APP_DIR} && \
mkdir -p ${SERVER_ROOT}/logs && \
mkdir -p ${SERVER_ROOT}/run && \
ln -s /usr/lib/apache2 ${SERVER_ROOT}/modules && \
chmod -R 755 ${SERVER_ROOT}/logs && \
chmod -R 755 ${SERVER_ROOT/run} && \
usermod -d ${SERVER_ROOT}/htdocs apache
# CONFIGURE HTTPD
RUN sed -i "s|ServerRoot /var/www|ServerRoot ${SERVER_ROOT}|" /etc/apache2/httpd.conf && \
@ -33,10 +39,14 @@ RUN sed -i "s|ServerRoot /var/www|ServerRoot ${SERVER_ROOT}|" /etc/apache2/httpd
sed -i "s|AllowOverride None|AllowOverride All|" /etc/apache2/httpd.conf && \
sed -i "s|ErrorLog .*|ErrorLog /dev/stderr \nTransferLog /dev/stdout|" /etc/apache2/httpd.conf && \
sed -i "s|CustomLog .* combined|CustomLog /dev/stdout combined|" /etc/apache2/httpd.conf && \
sed -i "s|LogLevel .*|LogLevel ${LOG_LEVEL}|" /etc/apache2/httpd.conf
sed -i "s|LogLevel .*|LogLevel ${LOG_LEVEL}|" /etc/apache2/httpd.conf && \
sed -i "s|#LoadModule rewrite_module|LoadModule rewrite_module|" /etc/apache2/httpd.conf && \
sed -i "s|#LoadModule deflate_module|LoadModule deflate_module|" /etc/apache2/httpd.conf && \
sed -i "s|#LoadModule expires_module|LoadModule expires_module|" /etc/apache2/httpd.conf
# ADD INITIALIZATION SCRIPT
ADD ./scripts/apache-entrypoint-alpine /usr/local/bin/entrypoint
RUN chmod +x /usr/local/bin/entrypoint && \
cp -vR /var/www/localhost/htdocs/* ${APP_DIR}/ && \
chown -R apache:apache ${APP_DIR}