0

I'm setting up a new test environment for a legacy system. Wish to either build dockerfile myself or "clone" the current production server.

I am using Docker Desktop Community (v. 2.0.0.3), The system I am maintaining is a php 7.2 webapp with mysql 5.7 on Ubuntu 18.04. I have opted to do one image of ubuntu and install php and mysql through RUN commands in the dockerfile.

FROM ubuntu:18.04

LABEL author="John Doe"
LABEL maintainer="john.doe@example.com"

ENV DEBIAN_FRONTEND noninteractive

# Install basics
RUN apt-get update
RUN apt-get install -y software-properties-common && \
    add-apt-repository ppa:ondrej/php && apt-get update && \
    add-apt-repository ppa:ondrej/apache2 && apt-get update

RUN apt-get install -y --force-yes curl nano apt-utils

ENV MYSQL_ROOT_PASSWORD=my-secret-pw

RUN apt-get update
RUN apt-get -y --allow-unauthenticated install mysql-server-5.7
RUN usermod -d /var/run/mysqld/ mysql

# Install PHP 7.2
RUN apt-get install -y --allow-unauthenticated php7.2

RUN apt-get install -y --allow-unauthenticated php7.2-mysqli \ 
    php7.2-mysqlnd \ 
    php7.2-mbstring \ 
    php7.2-bz2 \ 
    php7.2-zip \ 
    php7.2-curl \ 
    php7.2-gd \ 
    php7.2-gettext \ 
    php7.2-mbstring \ 
    php7.2-mysql \ 
    php-pear \ 
    php-php-gettext \ 
    php-phpseclib \ 
    php-tcpdf \ 
    php7.2-xml \ 
    php7.2-common \ 
    php7.2-json \ 
    php7.2-readline \ 
    php7.2-opcache \ 
    php7.2-xml

# Enable apache mods.
RUN a2enmod php7.2
RUN a2enmod rewrite

# Manually set up the apache environment variables
ENV APACHE_LOG_DIR /var/log/apache2
# ENV PHP_LOG_DIR /var/log/php
# ENV MYSQL_LOG_DIR /var/log/mysql

ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
ENV MYSQL_PID_FILE /var/run/mysqld/mysqld.pid

WORKDIR /var/www/example.com/public_html/

RUN mkdir /var/log/apache2/

# Update the default apache site with the config we created.
# Conf locations
# php:  /etc/php/7.2/apache2/php.ini
# apache: /etc/apache2/apache2.conf
# mysql: /etc/mysql/mysql.cnf
# RUN cp -R * /etc/apache2 /var/www/conf/apache2
COPY conf/apache_example/apache2 /etc/apache2
# RUN cp -R * /etc/php /var/www/conf/php
COPY conf/php_example/7.2 /etc/php/7.2
# RUN cp -R * /etc/mysql /var/www/conf/mysql
COPY conf/mysql_example /etc/mysql

COPY src /var/www/example.com/public_html

# Expose apache.
EXPOSE 80
EXPOSE 8080
EXPOSE 443
EXPOSE 3306


# By default start up apache in the foreground, override with /bin/bash for interative.
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

My expectation is to be able to start the legacy system and test new and changed code locally on my machine before I upload it to the production server.

duxck
  • 171
  • 1
  • 8
  • What are the main differences you have with your current Docker file? – Gonzalo Matheu Jun 10 '19 at 12:32
  • 1
    Don't have a current Dockerfile. Trying to create one that creates an image that looks like the physical server we have here. The container fails to start when I use the configuration files from the prod server. – duxck Jun 10 '19 at 12:40
  • Do you have any configuration control on the production server (which OS version, what dependencies, in which version, etc). I mean something like Puppet, Chef or Ansible scripts. – Gonzalo Matheu Jun 10 '19 at 12:45
  • 1
    @GonzaloMatheu not that I am aware of. I have quite resently upgraded the entire project from php 5.1 to 7.2, so as far as server access I only have the root user. It is really not great setup :) Think old home server from someone who is learning linux. – duxck Jun 10 '19 at 12:48
  • My 2 cent: If you want to be as close as possible to a legacy physical server, you should consider using a vm (vmware, virtualbox....) rather than docker for your tests. You would typically spread all (micro)services (apache, mysql, php) in different containers in such a setup in docker. – Zeitounator Jun 10 '19 at 12:57
  • @Zeitounator I agree that would probably be easier. Would like to easily bundle it with the db and code though to share with other developers to quickly test new stuff. Since with a virtual box I would have to set it up on every computer. The system is currently hosted on VMWare cloud service but I can't run a second clone on that host due to costs of running it 24/7 and the way they bill for it. Isn't high use enough on for that and remake the clone has too high impact in the stability of current system. – duxck Jun 10 '19 at 13:06
  • Vagrant would get you that running in seconds. – Zeitounator Jun 10 '19 at 13:08
  • @Zeitounator I will have a look at Vagrant, never used it before. Sounds like an option though. Thank you. – duxck Jun 10 '19 at 13:20

0 Answers0