An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
only copy needed files into prod image
peaklabs-dev36e4979dc306
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfileindex 00c798e1b7..b1643ed015 100644--- a/docker/prod/Dockerfile+++ b/docker/prod/Dockerfile@@ -12,30 +12,27 @@ ARG POSTGRES_VERSION=15FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION} AS baseWORKDIR /var/www/html-COPY --chown=www-data:www-data composer.json composer.lock ./RUN composer install --no-dev --no-interaction --no-plugins --no-scripts --prefer-dist-+# Build stage for frontend assetsFROM node:20-alpine AS static-assets-WORKDIR /app-COPY . .-COPY --from=base --chown=www-data:www-data /var/www/html .-RUN npm ci && \- npm run build+WORKDIR /app+COPY package*.json vite.config.js tailwind.config.js postcss.config.cjs ./+COPY public ./public+COPY resources ./resources+RUN npm ci && npm run buildFROM minio/mc:${MINIO_VERSION} AS minio-client+# Final stageFROM serversideup/php:${SERVERSIDEUP_PHP_VERSION}-ARG TARGETPLATFORMARG POSTGRES_VERSIONARG CLOUDFLARED_VERSIONARG CI=true-WORKDIR /var/www/html-USER root# Install PostgreSQL repository and key@@ -43,7 +40,7 @@ RUN apk add --no-cache gnupg && \mkdir -p /usr/share/keyrings && \curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /usr/share/keyrings/postgresql.gpg-# Install only required packages that aren't already in the base image+# Install required packagesRUN apk add --no-cache \postgresql${POSTGRES_VERSION}-client \openssh-client \@@ -57,7 +54,7 @@ RUN echo "alias ll='ls -al'" >> /etc/profile && \echo "alias a='php artisan'" >> /etc/profile && \echo "alias logs='tail -f storage/logs/laravel.log'" >> /etc/profile-# Setup Cloudflared based on architecture+# Setup CloudflaredRUN mkdir -p /usr/local/bin && \if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \curl -sSL "https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-amd64" -o /usr/local/bin/cloudflared; \@@ -66,20 +63,27 @@ RUN mkdir -p /usr/local/bin && \fi && \chmod +x /usr/local/bin/cloudflared-# Configure PHP upload limits+# Configure PHPRUN echo 'upload_max_filesize=256M' > /usr/local/etc/php/conf.d/upload-limits.ini && \echo 'post_max_size=256M' >> /usr/local/etc/php/conf.d/upload-limits.ini--# Enable PHP OPcacheENV PHP_OPCACHE_ENABLE=1-# Copy application files-COPY --chown=www-data:www-data . .-COPY --from=base --chown=www-data:www-data /var/www/html .+# Copy dependencies and built assets+COPY --from=base --chown=www-data:www-data /var/www/html/vendor ./vendorCOPY --from=static-assets --chown=www-data:www-data /app/public/build ./public/build-# Add composer dump-autoload before artisan commands-RUN composer dump-autoload+# Copy all neededapplication files+COPY --chown=www-data:www-data composer.json composer.lock ./+COPY --chown=www-data:www-data app ./app+COPY --chown=www-data:www-data bootstrap ./bootstrap+COPY --chown=www-data:www-data config ./config+COPY --chown=www-data:www-data database ./database+COPY --chown=www-data:www-data lang ./lang+COPY --chown=www-data:www-data public ./public+COPY --chown=www-data:www-data routes ./routes+COPY --chown=www-data:www-data storage ./storage+COPY --chown=www-data:www-data templates ./templates+COPY --chown=www-data:www-data artisan artisan# Copy configuration filesCOPY docker/prod/nginx.conf /etc/nginx/conf.d/custom.conf@@ -91,7 +95,8 @@ RUN chmod +x /usr/bin/mc# Optimize LaravelUSER www-data-RUN php artisan route:clear && \+RUN composer dump-autoload && \+ php artisan route:clear && \php artisan view:clear && \php artisan config:clear && \php artisan route:cache && \