2025-02-26 03:04:02 +02:00
|
|
|
# Stage 1: Build stage
|
2025-11-06 21:10:53 -06:00
|
|
|
FROM php:8.4-fpm AS builder
|
2024-12-19 21:10:00 -06:00
|
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2025-01-26 20:40:44 -06:00
|
|
|
ENV APP_NAME=Investbrain
|
2025-01-26 21:38:59 -06:00
|
|
|
ENV VITE_APP_NAME=Investbrain
|
2024-12-19 21:10:00 -06:00
|
|
|
|
|
|
|
|
# Set the working directory
|
2025-01-29 22:53:32 -06:00
|
|
|
WORKDIR /var/app
|
2025-01-27 13:03:13 -06:00
|
|
|
|
2025-01-27 11:06:58 -06:00
|
|
|
# Install required packages
|
2025-01-27 11:55:18 -06:00
|
|
|
RUN apt-get update && apt-get upgrade -y \
|
2025-01-29 22:53:32 -06:00
|
|
|
&& apt-get install -y \
|
2024-12-19 21:53:50 -06:00
|
|
|
libfreetype-dev \
|
|
|
|
|
libjpeg62-turbo-dev \
|
|
|
|
|
libpng-dev \
|
|
|
|
|
zlib1g-dev \
|
|
|
|
|
libzip-dev \
|
|
|
|
|
libicu-dev \
|
2025-01-26 23:48:24 -06:00
|
|
|
libpq-dev \
|
2025-01-27 12:48:16 -06:00
|
|
|
binutils libc6-dev \
|
|
|
|
|
unzip curl git \
|
2025-01-27 11:06:58 -06:00
|
|
|
nodejs npm \
|
|
|
|
|
&& apt-get -y autoremove \
|
2025-02-26 03:04:02 +02:00
|
|
|
&& apt-get clean \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
|
|
|
|
2025-01-27 12:48:16 -06:00
|
|
|
# Install PHP extensions
|
2025-02-26 03:04:02 +02:00
|
|
|
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
2026-03-15 18:24:40 -05:00
|
|
|
&& docker-php-ext-install -j$(nproc) gd zip intl
|
2025-01-26 21:06:08 -06:00
|
|
|
|
2025-02-26 03:04:02 +02:00
|
|
|
# Copy application files
|
|
|
|
|
COPY . .
|
2025-01-29 22:53:32 -06:00
|
|
|
|
2025-01-27 11:06:58 -06:00
|
|
|
# Install Composer and Node.js Install PHP dependencies and build front end assets
|
|
|
|
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
|
|
|
|
&& composer install --no-scripts --optimize-autoloader \
|
2025-01-30 18:48:34 -06:00
|
|
|
&& npm install && npm run build \
|
|
|
|
|
&& rm -rf node_modules
|
2025-01-25 18:22:12 -06:00
|
|
|
|
2025-02-26 03:04:02 +02:00
|
|
|
# Stage 2: Production stage
|
2025-11-06 21:10:53 -06:00
|
|
|
FROM php:8.4-fpm-alpine
|
2025-02-26 03:04:02 +02:00
|
|
|
|
|
|
|
|
# Set the working directory
|
|
|
|
|
WORKDIR /var/app
|
|
|
|
|
|
2025-07-16 17:07:25 -05:00
|
|
|
ARG VERSION=dev
|
|
|
|
|
ENV VERSION=$VERSION
|
|
|
|
|
|
2025-02-26 03:04:02 +02:00
|
|
|
# Copy necessary files from the builder stage
|
|
|
|
|
COPY --from=builder /var/app /var/app
|
|
|
|
|
COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
|
|
|
|
|
COPY --from=builder /usr/local/bin/composer /usr/local/bin/composer
|
|
|
|
|
|
|
|
|
|
# Install required Alpine packages
|
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
|
nginx \
|
|
|
|
|
supervisor \
|
|
|
|
|
libpng-dev \
|
|
|
|
|
libzip-dev \
|
|
|
|
|
icu-dev \
|
|
|
|
|
postgresql-dev \
|
|
|
|
|
freetype-dev \
|
|
|
|
|
libjpeg-turbo-dev \
|
|
|
|
|
bash \
|
|
|
|
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
|
|
|
&& docker-php-ext-install -j$(nproc) \
|
2025-07-10 08:11:25 +08:00
|
|
|
gd pgsql zip pdo_mysql pdo_pgsql mysqli intl
|
2025-02-26 03:04:02 +02:00
|
|
|
|
|
|
|
|
# Remove default nginx config
|
|
|
|
|
RUN rm -rf /var/www/html \
|
|
|
|
|
&& ln -s /var/app /var/www/app
|
|
|
|
|
|
2025-10-30 22:43:26 +01:00
|
|
|
# Create required directories
|
|
|
|
|
RUN mkdir -p /var/log/supervisor /var/run/supervisor /var/run/nginx
|
2025-02-26 03:04:02 +02:00
|
|
|
|
2025-01-25 20:40:26 -06:00
|
|
|
# Copy over configs
|
2025-02-26 03:04:02 +02:00
|
|
|
COPY ./docker/nginx.conf /etc/nginx/http.d/default.conf
|
2024-12-19 21:10:00 -06:00
|
|
|
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
|
|
2025-01-30 19:16:33 -06:00
|
|
|
# Set permissions and link storage
|
|
|
|
|
RUN php artisan storage:link \
|
2025-02-26 03:04:02 +02:00
|
|
|
&& chown -R www-data:www-data . \
|
2025-01-30 19:16:33 -06:00
|
|
|
&& chmod +x ./docker/entrypoint.sh
|
2025-01-30 18:48:34 -06:00
|
|
|
|
2024-12-19 21:10:00 -06:00
|
|
|
# Serve on port 80
|
|
|
|
|
EXPOSE 80
|
|
|
|
|
|
|
|
|
|
# Set up healthcheck
|
2025-01-29 23:06:42 -06:00
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost/up || exit 1
|
2024-12-19 21:10:00 -06:00
|
|
|
|
|
|
|
|
# Run everything else
|
2025-02-26 03:04:02 +02:00
|
|
|
ENTRYPOINT ["/bin/sh", "./docker/entrypoint.sh"]
|