Skip to content

Instantly share code, notes, and snippets.

@heartshare
Forked from enieber/Dockerfile
Created August 26, 2024 06:52
Show Gist options
  • Save heartshare/828d3737ce77a1851877ce0122bceaed to your computer and use it in GitHub Desktop.
Save heartshare/828d3737ce77a1851877ce0122bceaed to your computer and use it in GitHub Desktop.
FROM node:20.15.1 as frontend_build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
RUN npm install -g terser uglifycss autoprefixer postcss sass
COPY ./mapas/src/package.json /app
COPY ./mapas/src/pnpm-*.yaml /app
COPY ./mapas/src/modules/ /app/modules
COPY ./mapas/src/plugins/ /app/plugins
COPY ./mapas/src/themes/ /app/themes
COPY ./mapas/src/node_scripts/ /app/node_scripts
RUN pnpm install --recursive
RUN pnpm run build
RUN sass themes/BaseV1/assets/css/sass/main.scss:themes/BaseV1/assets/css/main.css
FROM dunglas/frankenphp:1-php8.3.9-alpine AS base
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN apk update
FROM base as build
RUN apk add --no-cache imagemagick imagemagick-dev
RUN apk add --no-cache git
RUN apk add --no-cache curl-dev postgresql-dev freetype-dev
RUN apk add --no-cache libjpeg-turbo-dev libpng-dev libzip-dev zstd
# Install extensions
RUN docker-php-ext-install -j$(nproc) opcache
RUN docker-php-ext-install -j$(nproc) pdo_pgsql
RUN docker-php-ext-install -j$(nproc) zip
RUN apk add --no-cache libxml2-dev
RUN docker-php-ext-install -j$(nproc) xml
RUN apk add --no-cache $PHPIZE_DEPS openssl-dev
RUN docker-php-ext-install -j$(nproc) curl
# Install GD
RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install -j$(nproc) gd
# Install APCu
RUN pecl install apcu && docker-php-ext-enable apcu
# Install imagick
RUN pecl install imagick && docker-php-ext-enable imagick
# Install igbinary
RUN pecl install igbinary && docker-php-ext-enable igbinary
# Install msgpack
RUN pecl install msgpack && docker-php-ext-enable msgpack
# Install redis
RUN pecl install redis && docker-php-ext-enable redis
# Install composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php --install-dir=/usr/local/bin
RUN rm composer-setup.php
# Copy source
COPY ./composer.json /var/www/composer.json
COPY ./composer.lock /var/www/composer.lock
# Execução do composer
RUN cd /var/www && composer.phar install
# Alteração das permissões
RUN mkdir -p /var/www/var/DoctrineProxies
RUN cd /var/www
RUN ln -s ./html /var/www/public
RUN chown www-data:www-data -R /var/www/config
RUN chown www-data:www-data -R /var/www/html
RUN chown www-data:www-data -R /var/www/scripts
RUN chown www-data:www-data -R /var/www/app
RUN chown www-data:www-data -R /var/www/src/conf
RUN chown www-data:www-data -R /var/www/src/core
RUN chown www-data:www-data -R /var/www/src/modules
RUN chown www-data:www-data -R /var/www/src/plugins
RUN chown www-data:www-data -R /var/www/src/themes
RUN chown www-data:www-data -R /var/www/src/tools
RUN chown www-data:www-data -R /var/www/src/translations
RUN chown www-data:www-data -R /var/www/src/*.*
WORKDIR /var/www
FROM base AS runtime
COPY ./mapas/config /var/www/config
COPY public /var/www/html
COPY ./mapas/scripts /var/www/scripts
COPY ./mapas/src /var/www/src
COPY ./mapas/var /var/www/var
COPY ./mapas/app /var/www/app
COPY ./mapas/docker/common/config.d /var/www/config/common.d
COPY ./mapas/docker/production/config.d /var/www/config/prod.d
COPY ./mapas/docker/recreate-pending-pcache-cron.sh /recreate-pending-pcache-cron.sh
COPY ./mapas/docker/jobs-cron.sh /jobs-cron.sh
COPY ./mapas/docker/entrypoint.sh /entrypoint.sh
COPY ./mapas/version.txt /var/www/version.txt
COPY --from=build /var/www/vendor /var/www/vendor
COPY --from=frontend_build /app/modules /var/www/src/modules
COPY --from=frontend_build /app/plugins /var/www/src/plugins
COPY --from=frontend_build /app/themes /var/www/src/themes
COPY --from=frontend_build /app/node_scripts /var/www/src/node_scripts
EXPOSE 9000
CMD ["php-fpm"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment