Skip to content

Instantly share code, notes, and snippets.

@kevinvdburgt
Created May 30, 2018 13:22
Show Gist options
  • Save kevinvdburgt/e6bc6344890644e1edcfa7a4bfb83cf0 to your computer and use it in GitHub Desktop.
Save kevinvdburgt/e6bc6344890644e1edcfa7a4bfb83cf0 to your computer and use it in GitHub Desktop.
Dockerfile Laravel
FROM php:7.2.0-fpm-alpine3.7
LABEL maintainer = "Kevin van der Burgt <kevin@zdev.com>"
# Change the workdirector
WORKDIR /var/www
# Copy the vendor listing files
COPY composer.* package* /var/www/
# Copy the database files, the composer installer requires some parts to exists
COPY database /var/www/database
# Copy the php configuration
COPY php.ini /usr/local/etc/php/
# Install php dependencies
RUN apk add --update --no-cache --virtual .ext-deps \
libjpeg-turbo-dev \
libwebp-dev \
libpng-dev \
freetype-dev \
libmcrypt-dev \
autoconf \
g++ \
make \
nodejs \
python \
build-base \
autoconf \
automake
RUN docker-php-ext-configure pcntl && \
docker-php-ext-configure pdo_mysql && \
docker-php-ext-configure opcache && \
docker-php-ext-configure exif && \
docker-php-ext-configure gd \
--with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-webp-dir=/usr/include --with-freetype-dir=/usr/include && \
docker-php-ext-configure sockets && \
docker-php-ext-install pdo_mysql opcache exif gd sockets pcntl
# Install composer, install the composer dependencies and remove the composer phar
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& php composer.phar install --no-dev --no-scripts \
&& rm composer.phar
# Install npm packages
RUN npm install
# Copy the files to the container
COPY . /var/www
# Run the build process
RUN npm run prod
# Make sure the permissions are correctly set
# RUN mkdir -p /var/www/storage/logs \
# mkdir -p /var/www/storage/framework/{cache,sessions,views} \
# mkdir -p /var/www/storage/app/public \
# mkdir -p /var/www/storage/certificates/ideal
RUN chown -R www-data:www-data \
/var/www/storage \
/var/www/bootstrap/cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment