Last active
January 7, 2023 00:47
-
-
Save TomHAnderson/a0e2455ede671997038b93086c930961 to your computer and use it in GitHub Desktop.
Laravel Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.1-apache | |
# Suppress warnings from apt about lack of Dialog | |
ENV DEBIAN_FRONTEND noninteractive | |
LABEL author="apiskeletons.com" \ | |
org.label-schema.docker.dockerfile="/Dockerfile" \ | |
org.label-schema.name="PHP using Apache" \ | |
org.label-schema.url="https://apiskeletons.com/" \ | |
org.label-schema.vcs-url="https://gist.github.com/TomHAnderson/a0e2455ede671997038b93086c930961" | |
RUN apt-get update | |
RUN apt-get install --yes \ | |
apt-utils \ | |
ca-certificates \ | |
curl \ | |
default-mysql-client \ | |
dnsutils \ | |
g++ \ | |
gnupg \ | |
gosu \ | |
git \ | |
lftp \ | |
libcap2-bin \ | |
libcurl4-openssl-dev \ | |
libicu-dev \ | |
libpng-dev \ | |
libxml2-dev \ | |
libzip-dev \ | |
procps \ | |
redis \ | |
sqlite3 \ | |
unzip \ | |
vim \ | |
wget \ | |
zip \ | |
zlib1g-dev | |
RUN docker-php-ext-configure intl | |
RUN docker-php-ext-install \ | |
curl \ | |
gd \ | |
intl \ | |
mysqli \ | |
pdo_mysql \ | |
xml \ | |
zip | |
RUN pecl install redis | |
RUN docker-php-ext-enable redis | |
# Apache | |
RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load | |
RUN echo "Listen 8080" > /etc/apache2/ports.conf | |
RUN echo "<VirtualHost *:8080> \n\ | |
ServerName ${SERVER_NAME:-localhost} \n\ | |
ServerAdmin ${SERVER_ADMIN:-webmaster@localhost} \n\ | |
\n\ | |
DocumentRoot /var/www/public \n\ | |
\n\ | |
ErrorLog ${APACHE_LOG_DIR}/error.log \n\ | |
CustomLog ${APACHE_LOG_DIR}/access.log combined \n\ | |
</VirtualHost>" > /etc/apache2/sites-available/000-default.conf | |
# Composer | |
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
RUN php composer-setup.php | |
RUN php -r "unlink('composer-setup.php');" | |
RUN mv composer.phar /bin/composer | |
# Copy app files | |
WORKDIR /var/www | |
ADD . /var/www | |
RUN rm -rf vendor | |
RUN composer install --no-dev | |
# Set permissions | |
RUN touch /var/www/storage/logs/laravel.log && \ | |
rm /var/www/storage/logs/laravel.log && \ | |
touch /var/www/storage/logs/laravel.log | |
RUN chgrp -R www-data storage bootstrap/cache | |
RUN chmod -R ug+rwx storage bootstrap/cache | |
EXPOSE 8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment