Compare commits

...

2 Commits

Author SHA1 Message Date
Muhamad Aditya Prima 5b7c2520ea fixed apache dockerfile 2024-12-27 15:22:50 +07:00
Muhamad Aditya Prima 595a49aa10 Fixed missing read permission on all scripts 2024-12-27 15:22:50 +07:00
8 changed files with 9 additions and 65 deletions

View File

@ -6,16 +6,21 @@ ARG PHP_VERSION=7.4
FROM quay.io/sindigilive/php:${PHP_VERSION}-builder-alpine AS builder FROM quay.io/sindigilive/php:${PHP_VERSION}-builder-alpine AS builder
ARG WITH_APACHE=false USER root
ARG WITH_APACHE=true
ARG WITH_DATABASE=false ARG WITH_DATABASE=false
ENV WITH_APACHE=${WITH_APACHE} ENV WITH_APACHE=${WITH_APACHE}
ENV WITH_DATABASE=${WITH_DATABASE} ENV WITH_DATABASE=${WITH_DATABASE}
ADD scripts/apache-entrypoint.sh /usr/local/bin/entrypoint
# Create directory, and install required php app # Create directory, and install required php app
RUN /bin/sh /tmp/setup.sh; \ RUN /bin/sh /tmp/setup.sh; \
/bin/rm -f /tmp/*.sh; \ /bin/rm -f /tmp/*.sh; \
rm -vrf /var/cache/apk/* rm -vrf /var/cache/apk/*; \
chmod +rx /usr/local/bin/entrypoint ;
FROM scratch FROM scratch
@ -44,4 +49,4 @@ WORKDIR /app/htdocs
STOPSIGNAL SIGQUIT STOPSIGNAL SIGQUIT
CMD ["/usr/local/bin/entrypoint.sh"] CMD ["/usr/local/bin/entrypoint"]

View File

@ -30,7 +30,7 @@ RUN /bin/mkdir -p /app ; \
php${PHP_VER_SHORT}-cli php${PHP_VER_SHORT}-phar \ php${PHP_VER_SHORT}-cli php${PHP_VER_SHORT}-phar \
php${PHP_VER_SHORT}-iconv php${PHP_VER_SHORT}-mbstring \ php${PHP_VER_SHORT}-iconv php${PHP_VER_SHORT}-mbstring \
php${PHP_VER_SHORT}-json ; \ php${PHP_VER_SHORT}-json ; \
/bin/chmod +x /tmp/setup.sh /usr/local/bin/composer ; /bin/chmod +rx /tmp/setup.sh /usr/local/bin/composer ;
# Create symlinks to /usr/bin/php in case it doesn't exists # Create symlinks to /usr/bin/php in case it doesn't exists
RUN ln -ns /usr/bin/php${PHP_VER_SHORT} /usr/bin/php ; exit 0 RUN ln -ns /usr/bin/php${PHP_VER_SHORT} /usr/bin/php ; exit 0

View File

@ -1,61 +0,0 @@
ARG REGISTRY_URL=docker.io/aprimediet
ARG PHP=8.3
FROM ${REGISTRY_URL}/php:${PHP}-alpine
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
# 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_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}
# CONFIGURE HTTPD
RUN sed -i "s|ServerRoot /var/www|ServerRoot ${SERVER_ROOT}|" /etc/apache2/httpd.conf && \
sed -i "s|ServerAdmin you@example.com| ServerAdmin ${SERVER_ADMIN}|" /etc/apache2/httpd.conf && \
sed -i "s|DocumentRoot \"/var/www/localhost/htdocs\"|DocumentRoot \"${APP_DIR}\"|" /etc/apache2/httpd.conf && \
sed -i "s|Directory \"/var/www/localhost/htdocs\"|Directory \"${APP_DIR}\"|" /etc/apache2/httpd.conf && \
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|#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 && \
sed -i "s|Require host .example.com|#Require host .example.com|" /etc/apache2/conf.d/info.conf && \
sed -i "s|Require ip 127|Require all granted|" /etc/apache2/conf.d/info.conf
# ADD INITIALIZATION SCRIPT
ADD ./scripts/entrypoint /usr/local/bin/entrypoint
RUN chmod +x /usr/local/bin/entrypoint && \
cp -vR /var/www/localhost/htdocs/* ${APP_DIR}/ && \
rm -vrf /var/www && \
chown -R apache:apache ${APP_DIR}
WORKDIR ${APP_DIR}
EXPOSE 80
ENTRYPOINT ["/usr/local/bin/entrypoint"]