167 lines
5.0 KiB
Docker
167 lines
5.0 KiB
Docker
######
|
|
# STAGE 1: GET REQUIRED PHP PACKAGES
|
|
######
|
|
|
|
FROM git.winteraccess.id/docker/composer:2.7.2-ubuntu-php8.0 AS php_build
|
|
LABEL maintainer="<Muhamad Aditya Prima> aprimediet@gmail.com"
|
|
|
|
WORKDIR /build
|
|
|
|
# ADD COMPOSER file
|
|
ADD composer* ./
|
|
|
|
# INSTALL REQUIRED PHP EXT
|
|
RUN --mount=type=cache,target=/var/cache/apt/archives \
|
|
apt -y update && apt -y upgrade && apt -y install \
|
|
php${PHP_VERSION}-curl php${PHP_VERSION}-dom php${PHP_VERSION}-xml \
|
|
php${PHP_VERSION}-gd php${PHP_VERSION}-zip
|
|
|
|
# RUN COMPOSER UPDATE FIRST
|
|
RUN --mount=type=cache,target=${COMPOSER_CACHE_DIR} \
|
|
composer update -n --prefer-dist \
|
|
--no-install --no-autoloader --no-scripts; exit 0
|
|
|
|
# RUN COMPOSER INSTALL
|
|
RUN --mount=type=cache,target=${COMPOSER_CACHE_DIR} \
|
|
composer install -n --prefer-dist \
|
|
--no-autoloader --no-scripts
|
|
|
|
###### END OF STAGE 1
|
|
|
|
|
|
######
|
|
# STAGE 2: GET REQUIRED NODEJS PACKAGES
|
|
######
|
|
|
|
FROM git.winteraccess.id/docker/nodejs:18-alpine AS static_build
|
|
LABEL maintainer="<Muhamad Aditya Prima> aprimediet@gmail.com"
|
|
|
|
WORKDIR /build
|
|
|
|
# ADD REQUIRED NODE FILES
|
|
ADD . .
|
|
|
|
# INSTALL REQUIRED NODE PACKAGES
|
|
RUN --mount=type=cache,target=${YARN_CACHE_DIR} \
|
|
yarn install --non-interactive
|
|
|
|
# BUILD ASSETS THROUGH VITE
|
|
# RUN --mount=type=cache,target=${YARN_CACHE_DIR} \
|
|
# yarn build
|
|
|
|
###### END OF STAGE 2
|
|
|
|
|
|
######
|
|
# STAGE 3: GET WKHTMLTOPDF FOR ALPINE
|
|
######
|
|
|
|
FROM ghcr.io/surnet/alpine-wkhtmltopdf:3.19.0-0.12.6-full AS wkhtmltopdf
|
|
|
|
###### END OF STAGE 3
|
|
|
|
|
|
######
|
|
# STAGE 4: Build Runtime Container
|
|
######
|
|
|
|
FROM git.winteraccess.id/docker/php:8.0-apache-alpine AS runtime
|
|
LABEL maintainer="<Muhamad Aditya Prima> aprimediet@gmail.com"
|
|
|
|
ARG BUILD_ENV=dev
|
|
|
|
# SET WORKDIR
|
|
WORKDIR /app/htdocs
|
|
|
|
# UPDATE AND UPGRADE PACKAGES FIRST
|
|
RUN apk update && apk upgrade
|
|
|
|
# INSTALL REQUIRED PHP EXT
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add \
|
|
php${PHP_VERSION}-pdo php${PHP_VERSION}-session php${PHP_VERSION}-fileinfo \
|
|
php${PHP_VERSION}-curl php${PHP_VERSION}-tokenizer php${PHP_VERSION}-dom \
|
|
php${PHP_VERSION}-gd php${PHP_VERSION}-xml php${PHP_VERSION}-xmlreader \
|
|
php${PHP_VERSION}-xmlwriter php${PHP_VERSION}-zip php${PHP_VERSION}-simplexml \
|
|
php${PHP_VERSION}-mbstring php${PHP_VERSION}-pgsql php${PHP_VERSION}-pdo_pgsql \
|
|
fcgi
|
|
|
|
# INSTALL PHP OpenSSL
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-openssl; exit 0
|
|
|
|
# Install php83-openssl from testing if main or community doesn't exists
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-openssl@testing; exit 0
|
|
|
|
# INSTALL PHP PHAR
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-phar; exit 0
|
|
|
|
# Install php83-phar from testing if main or community doesn't exists
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-phar@testing; exit 0
|
|
|
|
# Install php83-json
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-json; exit 0
|
|
|
|
# Install php83-json from testing if main or community doesn't exists
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-json@testing; exit 0
|
|
|
|
# Install php83-iconv
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-iconv; exit 0
|
|
|
|
# Install php83-iconv from testing if main or community doesn't exists
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add php${PHP_VERSION}-iconv@testing; exit 0
|
|
|
|
# INSTALL REQUIRED WKHTMLTOPDF DEPENDENCIES
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add libstdc++ libx11 libxrender libxext \
|
|
libssl1.1 ca-certificates fontconfig \
|
|
freetype ttf-droid ttf-freefont ttf-liberation
|
|
|
|
# Reconfigure apache mod
|
|
RUN 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|DocumentRoot \"/app/htdocs\"|DocumentRoot \"/app/htdocs/public\"|" /etc/apache2/httpd.conf && \
|
|
sed -i "s|Directory \"/app/htdocs\"|Directory \"/app/htdocs/public\"|" /etc/apache2/httpd.conf
|
|
|
|
# COPYING REQUIRED FILES
|
|
ADD ./deploy/docker/scripts/initialize /scripts/initialize
|
|
|
|
ADD . .
|
|
|
|
RUN chmod +x /scripts/* && \
|
|
mv ./public ./public-tmp
|
|
|
|
# COPY BUILD FILES
|
|
COPY --from=php_build /build/vendor ./vendor
|
|
COPY --from=php_build /build/composer.lock ./composer.lock
|
|
COPY --from=php_build /usr/local/bin/composer /usr/local/bin/composer
|
|
COPY --from=static_build /build/node_modules ./node_modules
|
|
# COPY --from=static_build /build/public/build ./public/build
|
|
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/wkhtmltoimage /bin/
|
|
|
|
# REMOVE BOOTSTRAP CACHE
|
|
RUN rm -rf ./bootstrap/cache/*
|
|
|
|
# CLEAR CACHE AND DEPLOY FILES
|
|
RUN rm -vrf /var/cache/apk/* && rm -rf ./deploy
|
|
|
|
# RUN DUMP AUTOLOAD && GENERATE APP_KEY
|
|
# TO ENSURE APP_KEY IS IDENTICAL BETWEEN ALL
|
|
# CONTAINERS
|
|
RUN composer dump-autoload
|
|
|
|
RUN ln -s /var/log/apache2 /app/logs && \
|
|
ln -s /usr/lib/apache2 /app/modules && \
|
|
ln -s /run/apache2 /app/run
|
|
|
|
EXPOSE 80
|
|
|
|
###### END OF STAGE 4 |