Who can split the dockerfile?

hi,

i need help!:blush:
I want to split a dockerfile, so each dockerfile (that build the docker image) has only 1 service!
I know for php and apache there a newer docker images on the docker hub that i will use.

So please help me to split the dockerfile:

FROM phusion/baseimage

VOLUME /srv/myown/htdocs/cms

proposed breaks some php packages (e.g. php-intl)

RUN rm -rf /etc/apt/sources.list.d/proposed.list

phusion/baseimage is not always up to date. :frowning:

RUN apt-get update &&
apt-get dist-upgrade -y --no-install-recommends

Set Timezone

RUN echo “Europe/Berlin” > /etc/timezone
RUN dpkg-reconfigure --frontend noninteractive tzdata

Make Debian/Ubunut and Docker friends

ENV DEBIAN_FRONTEND noninteractive

install phantomjs

RUN apt-get install -y --no-install-recommends software-properties-common &&
add-apt-repository ppa:tanguy-patte/phantomjs &&
apt-get update &&
apt-get install -y --no-install-recommends phantomjs

Install Apache httpd

RUN apt-get install -y --no-install-recommends
sqlite3
apache2
libapache2-mod-php5
libv8-3.14.5
msmtp
msmtp-mta
php5
php5-sqlite
php5-cli
php5-curl
php5-gd
php5-intl
php5-mcrypt

Activate Apache mods

RUN a2enmod ssl &&
a2enmod rewrite

Activate PHP mods

RUN php5enmod mcrypt

Install php5-v8js

COPY php5-v8js_0.1.3-1_amd64.deb /tmp/php5-v8js.deb
RUN dpkg -i /tmp/php5-v8js.deb

Activate apache2 in runit

RUN mkdir -p /etc/service/apache2
COPY apache2.runit /etc/service/apache2/run
RUN chmod +x /etc/service/apache2/run

Create folder

ENV CMS_PATH /opt/myown/htdocs
ENV INSTANCE_PATH /srv/myown
RUN mkdir -p ${CMS_PATH}
RUN mkdir -p ${INSTANCE_PATH}/htdocs/cms
RUN chown -R www-data:www-data ${INSTANCE_PATH}/htdocs

Install the release/cmsrelase.tar.gz (a version from our Jenkins)

RUN curl -L $(curl -s https://api.github.com/repos/xxxxxxx/releases/latest | grep
browser_download_url | grep ‘tgz|tar.gz’ | cut -d ‘"’ -f 4) | tar -xz --strip 1 -C ${CMS_PATH}/


RUN ln -s ${CMS_PATH}/app/server/environment ${INSTANCE_PATH}/environment
RUN ln -s ${CMS_PATH} ${INSTANCE_PATH}/application

Initial

ENV APPLICATION_ENV standalone
ENV CMS_SQLITE_DB ${INSTANCE_PATH}/htdocs/cms/db.sqlite3
COPY config.php ${INSTANCE_PATH}/config.php
COPY cms.apache /etc/apache2/sites-available/000-default.conf
RUN mkdir -p /etc/my_init.d
COPY init.sh /etc/my_init.d/myown_init.sh
RUN chmod +x /etc/my_init.d/myown_init.sh
COPY msmtprc.tpl /etc/msmtprc.tpl

EXPOSE 80

PS: It doesn’t matter which program it is!
Thanks!

A Docker image encapsulates a single service, all its dependencies, configuration items and entry-point script to apply values from env variables to the configuration before the main service is started.

As far as I can see there is ONE main service, which is a php app running in apache having a sqlite database (but why phantomjs?!, screenscrapper? or just for ui-test?).

There is nothing to decompose here. Though, you could aim for “inheritance” where you break down your Dockerfile in different intermediate Dockerfiles and reference the previous intermediate image as the base for the next one. I would create a base image with everything up to apache2/php in image. This one should be build that it can be reused. Then put all specifics regargding csm, configuration and the sqlite db into it’s own image, which bases on your apach2/php image.

The granularity is a matter of taste. The question is, if a sequence of commands already results in something that allows reuse of the resulting image. If it doesn’t it is not worth building a base image from it.

Thanks :grinning:, but sorry for my bad english.:blush:

I want to “split” it because i want to use one Dockerfile for one service only and i want to use the newest one (as example php7, not php5).
So at the end i have a docker image for apache, php7, database an web-app.:sunglasses:

Like i said on the docker-hub i can download Apache2 (httpd), PHP7 as docker image with one service in it.

PS: Back to your question
 the dockerfile isn’t from me! phantomjs is used in “this tool(s)”:thinking:. And yes this is a (web-)app in php.:wink:

Seem like you didn’t understand my first post and have everything sorted out already
 Though, I still stick with “you have a SINGLE service”. What you consider services, I consider dependencies.

Seperating the database on the other hand can be done, if you start to use a database like mysql, mariadb, postgres that will actualy listen on a port.

My recommendation: start to split the Dockerfile. Gather experience, see what actualy is possible and return in case you get stuck somewhere.

I beleve this is what you want to do , or maby im mistaken.

A part of it is right or it’s going in the right direction.:wink:
In my case: PHP7, MySQL, JavaScript, Apache webserver and web application.

Well, Let me show you what you need. takes me 15-20 minutes to make the build for it.

Take a look at the source, for this project. https://github.com/eagleblade/webstack-2

I use nginx, in this project. but the concept is the same

In apache you can use mod_proxy to do the same
<FilesMatch "\.php$"> # Unix sockets require 2.4.7 or later SetHandler "proxy:unix:/path/to/app.sock|fcgi://php:9000/" </FilesMatch>
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

Keep in mind that at this time, of this post. that project is far from finished.

1 Like