Forum

Thread tagged as: Discussion

Using Docker with Runway discussion thread

On the Runway blog I've written up a basic workflow for using Docker for local development environments. This thread is for any discussion of that, or tips from anyone who is already using Docker.

I'm pretty new to Docker myself so not an expert, but I'm really enjoying using it for Runway builds.

Rachel Andrew

Rachel Andrew 394 points

  • 4 years ago

Rachel. Thank you so much for this... I wonder if I could get some advice/help on getting this to work... I thought everything was working until I tried to add images through perch assets... So I think I have image processing issues with my docker install... When I add an 80k image, everything works fine... When I go to add a 400k image, everything looks correct in the process, but once complete, there is no image in assets...

What I do get is 2 files in the resources directory... the image I'm trying to upload and then a zero byte file named _gd_tmp_WpON1T... So image processing must be failing...

I'm using the docker files you created (with php7) changing only the local parameters and the latest version of perch/perch runway.

Diagnostics reports Image processing available, phpinfo shows GD is enabled and max_file_upload at 2M so I'm at a loss as to what might be the issue...

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there anything in the logs?

For the smaller images, do the thumbnails get produced correctly? (That should be an indication if GD is working.)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Depending on the pixel dimensions and colour depth of the 400k image, you could be just running out of memory. I'd suspect 128Mb would be enough, but is that actually available? Perhaps try increasing the available and allocated memory to the PHP process.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

@Montgomery Lewis: I'd suggest asking on Stack Overflow etc. https://stackoverflow.com/questions/tagged/docker

We don't have the resources to help with local dev environments or hosting etc. as these things are really hard to troubleshoot when not actually sat at your computer! There is nothing Perch specific about these questions so a post on SO or similar is likely to get you an answer.

Duncan Revell

Duncan Revell 78 points
Registered Developer

You know in the instructions where Rachel installs libpng-dev, try following the same process for libjpeg-dev and see if that solves the issue...

Thanks, Duncan! Yeah, its something like that and I will try that...

I found this:

https://stackoverflow.com/questions/26356268/call-to-undefined-function-imagecreatefromjpeg-and-gd-enabled

and

https://github.com/nazar-pc/docker-php/blob/master/apache/Dockerfile

That made me think the GD installation was incomplete somehow.

Thanks for your help!

Monty

Shoot!

So Duncan, Is this how you would have done it?

change

RUN apt-get update -y && apt-get install -y libpng-dev curl libcurl4-openssl-dev

to

RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev curl libcurl4-openssl-dev

That didn't change things for me... the docker container rebuilds without errors, but still can't add jogs over 80k...

Duncan Revell

Duncan Revell 78 points
Registered Developer

Yes, that's what I would do.

However, I'd forgotten it works for you with smaller jpgs. Which renders that fix useless anyway.

I think I need this:

# Configure GD package for JPEG support

    docker-php-ext-configure gd \
        --with-freetype-dir=/usr/lib/x86_64-linux-gnu/ \
        --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \
        --with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \
        --with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \
    && \

ok...

I can't get Rachel's dockerfile to work with full gd support...

However, when I substitute out the dockerfile here into all Rachel's other files, image processing works beautifully!

So, Rachel, If I could help, I would, but I would like to point out I really think there's an issue around imageprocessing with the dockerfile in the blogpost... and I think it has to do with it lacking the section shown in my previous post

Here's a link to the working dockerfile: https://github.com/nazar-pc/docker-php/blob/master/apache/Dockerfile

Thanks for everyone's help, Monty

oh, and this is pretty cool:

https://getcaptain.co

Hi @Rachel Andrew,

Thanks for the write-up on Docker & Perch. I tried it out and got everything working.

I'm posting to point to a couple of minor formatting issues that might cause confusion.

In the section headed “Adding PHP extensions”, you mention: Run docker-compose up -d —build

Did you mean to instruct the tutee to run: docker-compose up -d —build ...in their terminal window?

The same line is used again after updating the Dockerfile with the libpng-dev library.

Rachel Andrew said:

On the Runway blog I've written up a basic workflow for using Docker for local development environments. This thread is for any discussion of that, or tips from anyone who is already using Docker.

I'm pretty new to Docker myself so not an expert, but I'm really enjoying using it for Runway builds.

Hi Rachel,

Thanks for this write-up. I had one question. When commiting a project to git, do you recommend commiting from the root, including all the docker-compose file etc - or is it better to just commit from the www and if you wanted to spin it up on another machine, just clone the docker repo and then clone the project inside of that?

I ran into problems where I was getting errors when using perch_content_custom when I used:

'pages' => '/some-path/*'

The error: Invalid query: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tbl.regionID' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

The solution for me was to add

command: mysqld --sql_mode=""

to the yml file here:

  db:
    image: mysql:5.7
    command: mysqld --sql_mode=""
    ports: 
      - "3306:3306"
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=docker
      - MYSQL_DATABASE=db_name

I had the problem with uploading images too. Followed the example in the official php docker repo https://hub.docker.com/r/_/php/ and ended up with

FROM php:7-apache

RUN apt-get update && apt-get install -y \
        curl \
        libcurl4-openssl-dev \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) pdo pdo_mysql curl \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd \
    && a2enmod rewrite \
    && service apache2 restart

which works so far.

Also using && instead of separate RUN statements appears to be the preferred way to go because each RUN adds a layer to the container and makes it heavier than it has to be (I don't remember where I read that :( )

I took the same approach Proko. Monty kindly sent me his working version and I modified it a little after reading the docs. It's working well at the moment.

Great! Regarding git I think unless you work with other devs and you need to have the same setup or all your environments run in docker, I'd prefer the the repo to be in www.