Skip to content

Instantly share code, notes, and snippets.

@jhonoryza
Last active July 29, 2023 19:47
Show Gist options
  • Save jhonoryza/8bc2ce11091b63d4e3db81fc19c3f5d2 to your computer and use it in GitHub Desktop.
Save jhonoryza/8bc2ce11091b63d4e3db81fc19c3f5d2 to your computer and use it in GitHub Desktop.
coolify laravel
  • create folder .docker/apache/php.ini from root directory
memory_limit = 512M
post_max_size = 48M
upload_max_filesize = 700M
max_file_uploads = 20
  • create Dockerfile in root directory
FROM richan/laravel-apache:php-7.4-latest

COPY .docker/apache/php.ini /usr/local/etc/php/php.ini

RUN apt-get update && apt-get install -y libwebp-dev && docker-php-ext-install pcntl
RUN apt-get install -y vim

COPY . /var/www/html/

WORKDIR /var/www/html

# Install the dependency packages
RUN composer install --ignore-platform-reqs --no-interaction --no-plugins --no-scripts --prefer-dist --no-dev

# Setup laravel environment
ARG LARAVEL_ENV
ENV LARAVEL_ENV=${LARAVEL_ENV}
RUN echo $LARAVEL_ENV > .env-encoded
RUN base64 -d .env-encoded > .env

# Optimize Laravel
RUN php artisan clear-compiled
RUN php artisan storage:link
RUN php artisan config:clear
RUN php artisan route:clear
RUN php artisan view:clear
RUN php artisan key:generate

RUN chown -R www-data:www-data storage/
RUN chmod -R 0775 storage/
  • then add persistent volumes
Host Path Container Path
/root/data/public /var/www/html/storage/app/public
/root/data/logs /var/www/html/storage/logs
  • dont forget to chown host path to www-data
chown -R www-data:www-data /root/data/public
chown -R www-data:www-data /root/data/logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment