michaeldim / alpine-laravel-base

Alpine and Laravel Base Image
3 stars 3 forks source link

Beautiful! #1

Open Nesh108 opened 8 years ago

Nesh108 commented 8 years ago

Not really an issue but: thanks! I couldn't find any good laravel docker images, they were all bloated and just way too big.

This seems to be promising, I'll try it soon!

P.S. How do you see this: https://github.com/gliderlabs/docker-alpine as base image for your dockerfile?

michaeldim commented 8 years ago

Thanks. I'll have a look at swapping it around. I think the reason I used the sillelien base image was for the incorporated s6 process manager

Nesh108 commented 8 years ago

I tried with that one and it seemed that the last version (3.4) still doesn't have packages for php, so I went on with yours.

I compared the 2 and the minimalistic one (the docker-alpine) was 5MB lighter but yours worked better.

Also, I had to make some changes in order to get my project working properly. Here is my final dockerfile.

FROM sillelien/base-alpine:0.10

# Install packages
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
    apk-install nginx \
    bash \
    curl \
    php-cli \
    php-curl \
    php-dom \
    php-gd \
    php-fpm \
    php-json \
    php-mcrypt \
    php-mysql \
    php-pdo_mysql \
    php-phar \
    phpredis@testing \
    php-openssl

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php && \
    mv composer.phar /usr/local/bin/composer && \
    ln -s ~/.composer/vendor/bin/* /usr/local/bin/

# Clear contents of existing www directory
RUN rm -Rf /var/www/*

# Copy configuration files to root
COPY rootfs /

# Copy Laravel Projects to /var/www
ADD . /var/www

# Set working directory
WORKDIR /var/www

# Install project dependencies
RUN composer install
RUN cp .env.example .env
RUN php artisan key:generate

# Change folder permissions
RUN chown -R nginx:www-data /var

# Expose the ports for nginx
EXPOSE 80

The permissions were necessary otherwise it would just not work. I removed a couple of packages since they were not important to me (e.g. git) and ran composer install for the dependencies. This works straight out of the box if you are placing the Dockerfile in the root of your Laravel project.