Running Kirby 3.5 - plainkit inside Docker

Hello, I am new to Kirby! I am trying to follow the plainkit tutorial from this playlist: https://www.youtube.com/playlist?list=PLTep5U-3mg9EfgnQ08XDRs4vSOmhw2JWz on my Mac using Docker with no success! =(

I have found some Docker images / containers inside github but most of them are 2, 3 years long. The closest I got was using: GitHub - severinlx/getKirbyDocker: dockerfile for getkirby, php:7.4-apache, composer

What do I want

  • Have my kirby files in my local machine: eg.: ./public/...
  • Run a docker-compose up and have a container with all required libs running inside the container and exposed on my http://localhost:3001
  • All the changes made inside my ./public files to reflect inside the container / browser

My Dockerfile:

## Bootstrap from PHP container
FROM php:7.4-apache

## Setting up default workdir
WORKDIR "/var/www/html"


## Add PHP Core Extensions, like GD Library, iconv, MySQLI, Gettext
RUN apt-get update -qq && apt-get upgrade -y
RUN apt-get install -y unzip
RUN apt-get install -y libfreetype6-dev
RUN apt-get install -y libjpeg62-turbo-dev
RUN apt-get install -y libmcrypt-dev
RUN apt-get install -y libpng-dev
RUN apt-get install -y zlib1g-dev
RUN apt-get install -y libxml2-dev
RUN apt-get install -y libzip-dev
RUN apt-get install -y libonig-dev
RUN apt-get install -y graphvi

RUN docker-php-ext-install mbstring \
    && docker-php-ext-configure gd \
    && docker-php-ext-install -j$(nproc) gd
    #&& docker-php-ext-install ctype
    #&& docker-php-ext-install curl

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

#kirby
# RUN composer create-project getkirby/plainkit myKirby
# RUN cp -R myKirby/. .
# RUN rm -r myKirby

#remove this, why?
RUN rm -rf /var/lib/apt/lists/*

## Enable modrewrite and SSL module
RUN a2enmod rewrite
RUN a2enmod ssl

After build the container, I am running:

docker run -p 3001:80 -v /$(pwd)/public:/var/www/html:rw -d 8a0c6b0c7fbc

It is “almost” working

  • :white_check_mark: I can access the url: http://localhost:3001 on my browser, I see the “Home” title.
  • :white_check_mark: If I change the file ./public/content/home/home.txt and reload the browser, I see the changes! Same thing with the. ./public/site/templates/default.php
  • :rotating_light: If I create a new file / folder such as ./public/content/projects/projects.txt and try to reach it on the browser (http://localhost:3001/projects) I get a Error 404
  • :rotating_light: If I try to reach the panel it on the browser (http://localhost:3001/panel) I get a Error 404

Something is not working …

:interrobang: Does anyone have a Docker solution for the Kirby 3.5 / plainkit?

Probably the .htaccess not working (or you would have to include those rules in the vhost configuration)

It was related to the Docker image / configuration. I am going to create a github repo with the Dockerfile + docker-compose.yml + instructions.

Here is the solution I found:

  1. The Dockerfile:
FROM php:7.4-apache

RUN chown -R www-data:www-data /var/www/html
RUN a2enmod rewrite

RUN apt-get update
RUN apt-get install -y nano vim curl libpng-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev libgmp-dev libldap2-dev netcat zlib1g-dev libzip-dev

# libonig-dev is the replacement of mbstring for php 7.4
RUN apt-get install -y libonig-dev

RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd
RUN docker-php-ext-install ctype
  1. The docker-compose.yml file:
version: "2.1"
services:
  kirby35_webserver:
    build: .
    restart: on-failure:5
    ports:
      - "3001:80"
    volumes:
      - ./public:/var/www/html
1 Like