From 5dd93efad064a8cb560da712f499313b3c7799f3 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Thu, 22 Sep 2022 21:26:49 -0700 Subject: [PATCH 01/19] Initial port of Vagrant to Docker --- Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27367fc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:14.04 + +COPY . /vagrant + +WORKDIR /vagrant + +ENTRYPOINT [ "/bin/bash", "tests/vagrant/init.sh" ] \ No newline at end of file From c4a1453e6990dd8046f54137a3fcbf0925de4613 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Thu, 22 Sep 2022 23:00:34 -0700 Subject: [PATCH 02/19] Cal switched to HTTPS --- tests/02_http_codes.t | 2 +- tests/02_http_methods.t | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/02_http_codes.t b/tests/02_http_codes.t index 9717eee..9b523ed 100644 --- a/tests/02_http_codes.t +++ b/tests/02_http_codes.t @@ -91,7 +91,7 @@ foreach ($codes as $row){ - $ret = http_get("http://www.iamcal.com/misc/test/code.php?code={$row[0]}&msg=".urlencode($row[1])); + $ret = http_get("https://www.iamcal.com/misc/test/code.php?code={$row[0]}&msg=".urlencode($row[1])); $test = "{$row[0]}: {$row[1]}"; if (isset($row[2])) $test .= " {$row[2]}"; diff --git a/tests/02_http_methods.t b/tests/02_http_methods.t index 13ce7bf..9da59ab 100644 --- a/tests/02_http_methods.t +++ b/tests/02_http_methods.t @@ -25,17 +25,17 @@ } - $ret = http_get("http://www.iamcal.com/misc/test/method.php"); + $ret = http_get("https://www.iamcal.com/misc/test/method.php"); test_http_method($ret, 'GET', 0, 0); - $ret = http_get("http://www.iamcal.com/misc/test/method.php?a=1&b=2"); + $ret = http_get("https://www.iamcal.com/misc/test/method.php?a=1&b=2"); test_http_method($ret, 'GET', 2, 0); - $ret = http_head("http://www.iamcal.com/misc/test/method.php"); + $ret = http_head("https://www.iamcal.com/misc/test/method.php"); test_http_method($ret, 'HEAD', 0, 0); - $ret = http_post("http://www.iamcal.com/misc/test/method.php", array()); + $ret = http_post("https://www.iamcal.com/misc/test/method.php", array()); test_http_method($ret, 'POST', 0, 0); - $ret = http_post("http://www.iamcal.com/misc/test/method.php?a=1", array('b' => 2, 'c' => 3)); + $ret = http_post("https://www.iamcal.com/misc/test/method.php?a=1", array('b' => 2, 'c' => 3)); test_http_method($ret, 'POST', 1, 2); From d1c4e6ea1d5af8f2e4d5fe4c7b8ec09fd5bc8a86 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 14:37:21 -0700 Subject: [PATCH 03/19] Hacked together a mostly-working docker container --- Dockerfile | 37 ++++++++++++++++++++++++++++++++++--- README.md | 17 +++++++++++++++++ tests/docker/entrypoint.sh | 6 ++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 tests/docker/entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 27367fc..ddf966e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,38 @@ FROM ubuntu:14.04 -COPY . /vagrant +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y php5-cli git php5-mcrypt php5-curl apache2 libapache2-mod-php5 mysql-server php5-mysql memcached php5-memcache php5-mcrypt && \ + apt-get autoremove && \ + apt-get clean && apt-get autoclean -WORKDIR /vagrant +RUN php5enmod mcrypt -ENTRYPOINT [ "/bin/bash", "tests/vagrant/init.sh" ] \ No newline at end of file +COPY . /mnt/flamework +WORKDIR /mnt/flamework + +RUN rm -rf /var/www/html +RUN ln -fs /mnt/flamework/www /var/www/html + +RUN chown www-data www/templates_c +RUN chmod 755 www/templates_c +RUN cp www/include/config.php.example www/include/config.php +RUN cat tests/travis/config.php >> www/include/config.php + +RUN /etc/init.d/mysql start && \ + mysql -e 'CREATE DATABASE flamework;' && \ + mysql -Dflamework < schema/db_main.schema + +#RUN apt-get install -y php-pear +#RUN pear channel-discover pear.phpunit.de +#RUN pear install phpunit/PHP_CodeCoverage + +RUN apt-get install -y make +#RUN pecl install xdebug +#RUN echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT [ "/bin/bash", "tests/docker/entrypoint.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index 2355149..da3010b 100644 --- a/README.md +++ b/README.md @@ -99,3 +99,20 @@ If you don't want to mess with your local development environment, you can run t vagrant ssh cd /vagrant make test + +## Docker + +Similarly, Docker is an option for both local development and test running, but is not suitable for production use (really, REALLY don't use it that way). To build and run: + + docker build -t flamework . + docker run -ti -p80:8081 -p443:4331 --name=flamework --rm flamework + +Your local flamework copy should now be listening on ports `8081` and `4331` Docker randomly chose. Use `docker ps` to see them. To run tests, you can do: + + docker exec -ti flamework make test + +And to tail the error logs: + + docker exec -ti flamework tail -F /var/log/apache2/error.log + +When killing the container using either `CTRL+C` or `docker stop flamework`, the container will be removed and all data will be reset next run. This is useful for running tests. \ No newline at end of file diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh new file mode 100644 index 0000000..af82c91 --- /dev/null +++ b/tests/docker/entrypoint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +/etc/init.d/mysql start +/etc/init.d/memcached start + +exec apachectl -D FOREGROUND \ No newline at end of file From 0d584824bceb6818c21016e1a7de2dc1545eee2c Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 14:51:22 -0700 Subject: [PATCH 04/19] Small Docker copy changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da3010b..ca60756 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Similarly, Docker is an option for both local development and test running, but docker build -t flamework . docker run -ti -p80:8081 -p443:4331 --name=flamework --rm flamework -Your local flamework copy should now be listening on ports `8081` and `4331` Docker randomly chose. Use `docker ps` to see them. To run tests, you can do: +Your local flamework copy should now be listening on ports `8081` and `4331`. Use `docker ps` to verify them. Once the container is running, to run tests you can do: docker exec -ti flamework make test From 7f568ddf0e3a679af5824cc36a00c97d4a8feb93 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 14:51:41 -0700 Subject: [PATCH 05/19] Move DB initialization out of Docker build time and into run time --- Dockerfile | 4 ---- tests/docker/entrypoint.sh | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ddf966e..a6ba3f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,10 +20,6 @@ RUN chmod 755 www/templates_c RUN cp www/include/config.php.example www/include/config.php RUN cat tests/travis/config.php >> www/include/config.php -RUN /etc/init.d/mysql start && \ - mysql -e 'CREATE DATABASE flamework;' && \ - mysql -Dflamework < schema/db_main.schema - #RUN apt-get install -y php-pear #RUN pear channel-discover pear.phpunit.de #RUN pear install phpunit/PHP_CodeCoverage diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh index af82c91..aa59dd4 100644 --- a/tests/docker/entrypoint.sh +++ b/tests/docker/entrypoint.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -/etc/init.d/mysql start /etc/init.d/memcached start +/etc/init.d/mysql start +mysql -e 'CREATE DATABASE IF NOT EXISTS flamework;' +mysql -Dflamework < schema/db_main.schema + exec apachectl -D FOREGROUND \ No newline at end of file From 851e371df5d76272383c3c45a8cecaa85bb069d9 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 15:07:11 -0700 Subject: [PATCH 06/19] Make a make target for docker build-and-run because why not? --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 8baafee..6f36182 100644 --- a/Makefile +++ b/Makefile @@ -30,3 +30,7 @@ cover: rm -rf ./coverage -make test php -q ./tests/coverage.php + +docker: + docker build -t flamework . + docker run -ti -p80\:8081 -p443\:4331 --name=flamework --rm flamework From 6439212c1aa0bfd68eee39e05fc311723a5b5e04 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 15:11:49 -0700 Subject: [PATCH 07/19] Tell us more about what we're doing --- tests/docker/entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh index aa59dd4..7568711 100644 --- a/tests/docker/entrypoint.sh +++ b/tests/docker/entrypoint.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eux + /etc/init.d/memcached start /etc/init.d/mysql start From 03e9b27e509d8c3c26dd139090ba2a43f8575d56 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 20:52:37 -0700 Subject: [PATCH 08/19] You mosy certainly do not --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca60756..0f4f5fb 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ And some random odds and ends: ## Tests -If you have `make` and and recent `perl` installed (you almost certainly do), you can run the tests using: +If you have `make` and and recent `perl` installed (you almost certainly do, or if not see [Vagrant](#vagrant) and [Docker](#docker) sections below), you can run the tests using: make test From 8372bf8cc6bdfd7a7dfc0fdccf88933ed96a99bd Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 21:37:41 -0700 Subject: [PATCH 09/19] There are some todos --- Dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a6ba3f2..ab3be0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,16 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get autoremove && \ apt-get clean && apt-get autoclean -RUN php5enmod mcrypt - +RUN php5enmod mcrypt && \ + a2enmod rewrite + +# TODO: This whole section needs we-work. For example: +# This needs to be a volume mount so code can be edited and loaded live +# but we also need to be able to set up a default config +# TODO: Different config when docker vs travis? +# TODO: Looks like we need a new VirtualHost apache config that sets the +# right Directory AllowOverride and other configs. Or how to do another +# approach for that? COPY . /mnt/flamework WORKDIR /mnt/flamework @@ -20,11 +28,13 @@ RUN chmod 755 www/templates_c RUN cp www/include/config.php.example www/include/config.php RUN cat tests/travis/config.php >> www/include/config.php +# TODO: PHPUnit via Pear is dead. Also, conditionally install only when running tests? #RUN apt-get install -y php-pear #RUN pear channel-discover pear.phpunit.de #RUN pear install phpunit/PHP_CodeCoverage RUN apt-get install -y make +# TODO: Only install when running tests? #RUN pecl install xdebug #RUN echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini From b14b235246fbff1ebc00bd00fd385b67dbe808ad Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Fri, 23 Sep 2022 21:53:47 -0700 Subject: [PATCH 10/19] More Docker notes --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f4f5fb..28d3e7b 100644 --- a/README.md +++ b/README.md @@ -102,12 +102,14 @@ If you don't want to mess with your local development environment, you can run t ## Docker -Similarly, Docker is an option for both local development and test running, but is not suitable for production use (really, REALLY don't use it that way). To build and run: +Similarly, Docker is an option for both local development and test running, but is not suitable for production use (really, REALLY don't use it for prod -- we (intentionally) do not have this configured securely). To build and run: docker build -t flamework . docker run -ti -p80:8081 -p443:4331 --name=flamework --rm flamework -Your local flamework copy should now be listening on ports `8081` and `4331`. Use `docker ps` to verify them. Once the container is running, to run tests you can do: +Your local flamework copy should now be listening on ports `8081` and `4331`. Use `docker ps` to verify them. You'll need to edit include/config.php as usual. + +Once the container is running, to run tests you can do: docker exec -ti flamework make test From cbf619c7eda29fe5210ab5c30ac1b1ad45e1e61f Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sat, 24 Sep 2022 09:53:06 -0700 Subject: [PATCH 11/19] Flamework-specific apache config in the docker container --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ab3be0e..c880ea0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,12 +14,13 @@ RUN php5enmod mcrypt && \ # This needs to be a volume mount so code can be edited and loaded live # but we also need to be able to set up a default config # TODO: Different config when docker vs travis? -# TODO: Looks like we need a new VirtualHost apache config that sets the -# right Directory AllowOverride and other configs. Or how to do another -# approach for that? COPY . /mnt/flamework WORKDIR /mnt/flamework +RUN ln -fs /mnt/flamework/tests/docker/001-flamework.conf /etc/apache2/sites-available/ +RUN a2ensite 001-flamework +RUN a2dissite 000-default + RUN rm -rf /var/www/html RUN ln -fs /mnt/flamework/www /var/www/html From b12bfce16d52ecfd08b3579ed99339cfe8cd9383 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sun, 25 Sep 2022 11:27:04 -0700 Subject: [PATCH 12/19] Starting on volume mounting --- Dockerfile | 2 ++ Makefile | 2 +- README.md | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c880ea0..2212ce4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,6 +39,8 @@ RUN apt-get install -y make #RUN pecl install xdebug #RUN echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini +VOLUME ["/mnt/flamework"] + EXPOSE 80 EXPOSE 443 diff --git a/Makefile b/Makefile index 6f36182..72fb4d5 100644 --- a/Makefile +++ b/Makefile @@ -33,4 +33,4 @@ cover: docker: docker build -t flamework . - docker run -ti -p80\:8081 -p443\:4331 --name=flamework --rm flamework + docker run -ti -p80\:8081 -p443\:4331 -v ~/dev/flamework\:/mnt/flamework --name=flamework --rm flamework diff --git a/README.md b/README.md index 28d3e7b..796319f 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ If you don't want to mess with your local development environment, you can run t Similarly, Docker is an option for both local development and test running, but is not suitable for production use (really, REALLY don't use it for prod -- we (intentionally) do not have this configured securely). To build and run: docker build -t flamework . - docker run -ti -p80:8081 -p443:4331 --name=flamework --rm flamework + docker run -ti -p80:8081 -p443:4331 -v ~/dev/flamework:/mnt/flamework --name=flamework --rm flamework Your local flamework copy should now be listening on ports `8081` and `4331`. Use `docker ps` to verify them. You'll need to edit include/config.php as usual. From efe0a5f052f8e6441d986fe80d6a2c3666eebd5d Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sun, 25 Sep 2022 15:37:34 -0700 Subject: [PATCH 13/19] Comments on the dockerfile --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2212ce4..8fcb3cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM ubuntu:14.04 +# Install the packages we need RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ apt-get upgrade -y && \ @@ -7,9 +8,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get autoremove && \ apt-get clean && apt-get autoclean +# Turn on the mcrypt php module and the rewrite apache module RUN php5enmod mcrypt && \ a2enmod rewrite +# Configure our paths for where we'll serve source-code from # TODO: This whole section needs we-work. For example: # This needs to be a volume mount so code can be edited and loaded live # but we also need to be able to set up a default config @@ -24,8 +27,11 @@ RUN a2dissite 000-default RUN rm -rf /var/www/html RUN ln -fs /mnt/flamework/www /var/www/html +# Templates need to be writable by the web server RUN chown www-data www/templates_c RUN chmod 755 www/templates_c + +# Put a config that we know will work in place RUN cp www/include/config.php.example www/include/config.php RUN cat tests/travis/config.php >> www/include/config.php @@ -39,9 +45,12 @@ RUN apt-get install -y make #RUN pecl install xdebug #RUN echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini +# Allow mounting of source code from external to the container VOLUME ["/mnt/flamework"] +# Listen on the HTTP and HTTPS ports EXPOSE 80 EXPOSE 443 +# When the container is run, this script will start mysql and apache ENTRYPOINT [ "/bin/bash", "tests/docker/entrypoint.sh" ] \ No newline at end of file From c417be2211468635fbf0e2478e304b2a90ac46e8 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sun, 25 Sep 2022 15:37:50 -0700 Subject: [PATCH 14/19] A mostly working apache config --- tests/docker/001-flamework.conf | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/docker/001-flamework.conf diff --git a/tests/docker/001-flamework.conf b/tests/docker/001-flamework.conf new file mode 100644 index 0000000..0e44ace --- /dev/null +++ b/tests/docker/001-flamework.conf @@ -0,0 +1,45 @@ + + DocumentRoot /var/www/html + + + Options +Indexes +FollowSymLinks -MultiViews + AllowOverride All + Order allow,deny + allow from all + require all granted + + + ErrorLog ${APACHE_LOG_DIR}/error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog ${APACHE_LOG_DIR}/access.log combined + + RewriteEngine on + #RewriteLog ${APACHE_LOG_DIR}/rewrite.log + #RewriteLogLevel 3 + + DirectoryIndex index.php + + + + DocumentRoot /var/www/html + + + Options +Indexes -MultiViews + AllowOverride All + Order allow,deny + allow from all + require all granted + + + ErrorLog ${APACHE_LOG_DIR}/error.log + LogLevel warn + CustomLog ${APACHE_LOG_DIR}/access.log combined + + RewriteEngine on + + DirectoryIndex index.php + \ No newline at end of file From e4b8aafbad7a6308ba7ac4fa1c4624b66a92484a Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Tue, 27 Sep 2022 21:53:44 -0700 Subject: [PATCH 15/19] Most web setup is now done from the volume, at runtime --- Dockerfile | 23 +++++------------------ tests/docker/entrypoint.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8fcb3cf..3b3dcfc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,36 +12,22 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ RUN php5enmod mcrypt && \ a2enmod rewrite -# Configure our paths for where we'll serve source-code from -# TODO: This whole section needs we-work. For example: -# This needs to be a volume mount so code can be edited and loaded live -# but we also need to be able to set up a default config -# TODO: Different config when docker vs travis? -COPY . /mnt/flamework +# Configure our path for where we'll serve source-code from WORKDIR /mnt/flamework - -RUN ln -fs /mnt/flamework/tests/docker/001-flamework.conf /etc/apache2/sites-available/ +COPY tests/docker/001-flamework.conf /etc/apache2/sites-available/ RUN a2ensite 001-flamework RUN a2dissite 000-default RUN rm -rf /var/www/html RUN ln -fs /mnt/flamework/www /var/www/html -# Templates need to be writable by the web server -RUN chown www-data www/templates_c -RUN chmod 755 www/templates_c - -# Put a config that we know will work in place -RUN cp www/include/config.php.example www/include/config.php -RUN cat tests/travis/config.php >> www/include/config.php - # TODO: PHPUnit via Pear is dead. Also, conditionally install only when running tests? #RUN apt-get install -y php-pear #RUN pear channel-discover pear.phpunit.de #RUN pear install phpunit/PHP_CodeCoverage -RUN apt-get install -y make # TODO: Only install when running tests? +#RUN apt-get install -y make #RUN pecl install xdebug #RUN echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini @@ -52,5 +38,6 @@ VOLUME ["/mnt/flamework"] EXPOSE 80 EXPOSE 443 -# When the container is run, this script will start mysql and apache +# When the container is run, this script will start mysql and apache, +# and put a sample config in place if necessary ENTRYPOINT [ "/bin/bash", "tests/docker/entrypoint.sh" ] \ No newline at end of file diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh index 7568711..c643748 100644 --- a/tests/docker/entrypoint.sh +++ b/tests/docker/entrypoint.sh @@ -1,11 +1,26 @@ #!/usr/bin/env bash +# We want to halt on errors and also print out what we're doing set -eux +# Start memcached /etc/init.d/memcached start +# Start mysql and create the database if it doesn't exist /etc/init.d/mysql start mysql -e 'CREATE DATABASE IF NOT EXISTS flamework;' mysql -Dflamework < schema/db_main.schema +# Put the example configuration in place if it doesn't exist +cd /mnt/flamework +if [[ ! -e www/include/config.php ]]; then + cp www/include/config.php.example www/include/config.php + perl -i -pe "s/'pass'\t=> 'root',/'pass'\t=> '',/g" www/include/config.php +fi + +# Templates need to be writable by the web server +chown www-data www/templates_c +chmod 755 www/templates_c + +# Start apache in the foreground so that the container stays running exec apachectl -D FOREGROUND \ No newline at end of file From 2eda1bc7c445d7c287e79e075300571566e26cf3 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Tue, 27 Sep 2022 22:25:35 -0700 Subject: [PATCH 16/19] Kind of fix ssl --- Dockerfile | 7 +++++-- tests/docker/001-flamework.conf | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b3dcfc..2db5060 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,12 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get autoremove && \ apt-get clean && apt-get autoclean -# Turn on the mcrypt php module and the rewrite apache module +# Turn on the mcrypt php module and the rewrite\ssl apache modules RUN php5enmod mcrypt && \ - a2enmod rewrite + a2enmod rewrite && \ + a2enmod ssl + +# TODO: Proper ssl certs via letsencrypt or something # Configure our path for where we'll serve source-code from WORKDIR /mnt/flamework diff --git a/tests/docker/001-flamework.conf b/tests/docker/001-flamework.conf index 0e44ace..0e5a813 100644 --- a/tests/docker/001-flamework.conf +++ b/tests/docker/001-flamework.conf @@ -40,6 +40,10 @@ CustomLog ${APACHE_LOG_DIR}/access.log combined RewriteEngine on - + DirectoryIndex index.php + + SSLEngine on + SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem + SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key \ No newline at end of file From 12ca68a2af04383c7dd90b6ce3b5bf4ff7fb1d36 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sun, 2 Oct 2022 18:28:17 -0700 Subject: [PATCH 17/19] Make mysql's data mountable externally --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2db5060..c4730c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,9 @@ RUN ln -fs /mnt/flamework/www /var/www/html # Allow mounting of source code from external to the container VOLUME ["/mnt/flamework"] +# Optional persistence of the mysql data +VOLUME ["/var/lib/mysql"] + # Listen on the HTTP and HTTPS ports EXPOSE 80 EXPOSE 443 From 8c4798ba80a8578c7bcf8680cf9ef14e0f822dcd Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Sun, 2 Oct 2022 18:29:06 -0700 Subject: [PATCH 18/19] More notes on how Docker works --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 796319f..a75d759 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Similarly, Docker is an option for both local development and test running, but docker build -t flamework . docker run -ti -p80:8081 -p443:4331 -v ~/dev/flamework:/mnt/flamework --name=flamework --rm flamework -Your local flamework copy should now be listening on ports `8081` and `4331`. Use `docker ps` to verify them. You'll need to edit include/config.php as usual. +Your local flamework copy should now be listening on ports `8081` and `4331`. Use `docker ps` to verify them. You'll need to edit include/config.php as usual. Since you mounted your local dev flamework directory into the container, any code changes you make should be reflected immediately. Once the container is running, to run tests you can do: From 903a059169d1293ae483a014164dbbc7b55fbb01 Mon Sep 17 00:00:00 2001 From: Myles Grant Date: Tue, 4 Oct 2022 14:28:12 -0700 Subject: [PATCH 19/19] shell scripts need to be forced to have LF EOL or WSL freaks out --- .gitattributes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 176a458..cdacba4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -* text=auto +*.sh text eol=lf +* text=auto \ No newline at end of file