h-source-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[H-source-users] Some patches to get h-source run with php7 in a docker


From: Yuchen Pei
Subject: [H-source-users] Some patches to get h-source run with php7 in a docker container
Date: Mon, 06 Sep 2021 11:03:27 +1000
User-agent: mu4e 1.4.13; emacs 27.2

I was surprised to find that the server h-source actually *runs* with php7 out of the box, at least in a local docker environment. I haven't tested creating a new account, a new wiki entry etc.

I've created patches to reproduce this.

All four patches are independent, only the last patch is about php7, and the first three are tiny changes concerning mysql in docker.

Let me know what you think. Will push (any subset of) the patches to the development branch if no opposition.

Next I will try to get the staging server to work. It has a lamp environment so I won't be using docker.

From cf8584c645ca1178c027268b9fd273db6d15248a Mon Sep 17 00:00:00 2001
From: Yuchen Pei <hi@ypei.me>
Date: Thu, 26 Aug 2021 11:44:01 +1000
Subject: [PATCH 1/4] change mysql dir

---
 docker/docker-compose.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index c3f2349..9a7aa44 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -11,4 +11,4 @@ services:
       - 3306:3306
     volumes:
       - "../h-source:/app"
-      - "./mysql:/var/lib/mysql"
+      - "../mysql:/var/lib/mysql"
-- 
2.33.0

From efa352a6de4de467e645c50503257e17254f436e Mon Sep 17 00:00:00 2001
From: Yuchen Pei <hi@ypei.me>
Date: Thu, 26 Aug 2021 11:45:47 +1000
Subject: [PATCH 2/4] add mysql to gitignore

---
 .gitignore | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index e4e5f6c..c06b95f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-*~
\ No newline at end of file
+*~
+mysql/
\ No newline at end of file
-- 
2.33.0

From 6995bcca056862e52d1167d6ee7e67d73a2bdd95 Mon Sep 17 00:00:00 2001
From: Yuchen Pei <hi@ypei.me>
Date: Thu, 26 Aug 2021 11:56:07 +1000
Subject: [PATCH 3/4] updating the database creation command to be more
 "batchy"

---
 docker/readme-php5.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/docker/readme-php5.sh b/docker/readme-php5.sh
index fb62a4d..7ec58b1 100755
--- a/docker/readme-php5.sh
+++ b/docker/readme-php5.sh
@@ -8,9 +8,7 @@
 # - Apache on port 80
 #
 # Don't forget to create the database:
-#      mysql -uadmin -pXXX -h127.0.0.1
-#      > create database hnode;
-#      > ^D
+#      mysql -uadmin -pXXX -h127.0.0.1 -e "create database hnode;"
 # and populate the schema/initial data with:
 #      mysql -uadmin -pXXX -h127.0.0.1 hnode < ../h-source/tables.sql
 
-- 
2.33.0

From e5d8adfe0cda67173cae706708e0b4e7a67f5713 Mon Sep 17 00:00:00 2001
From: Yuchen Pei <hi@ypei.me>
Date: Mon, 6 Sep 2021 10:27:36 +1000
Subject: [PATCH 4/4] Adding lamp-php7 docker command.

- Tested locally. The website up and running.
- Also updated the readme script to run either php5 or php7.
---
 docker/docker-compose.yml                 | 20 +++++++++++++++-----
 docker/lamp-php7.Dockerfile               |  3 +++
 docker/{readme-php5.sh => readme-lamp.sh} | 16 +++++++++++++---
 3 files changed, 31 insertions(+), 8 deletions(-)
 create mode 100644 docker/lamp-php7.Dockerfile
 rename docker/{readme-php5.sh => readme-lamp.sh} (56%)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 9a7aa44..dcc4ed1 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,9 +1,7 @@
-# Image for LAMP based on Dockerfile in 
https://github.com/jakejarvis/docker-lamp-php5
-# WARNING: Not suitable for production environments, only for testing legacy 
php5 application.
-# (Docker image supplementary files licenced under Apache 2.0)
-
-version: "3"
 services:
+  # Image for LAMP based on Dockerfile in 
https://github.com/jakejarvis/docker-lamp-php5
+  # WARNING: Not suitable for production environments, only for testing legacy 
php5 application.
+  # (Docker image supplementary files licenced under Apache 2.0)
   lamp-php5:
     image: docker.io/jakejarvis/lamp-php5:latest
     ports:
@@ -12,3 +10,15 @@ services:
     volumes:
       - "../h-source:/app"
       - "../mysql:/var/lib/mysql"
+  # Image for LAMP based on https://github.com/mattrayner/docker-lamp
+  # (Docker image licenced under Apache 2.0)  
+  lamp-php7:
+    build:
+      dockerfile: lamp-php7.Dockerfile
+      context: .
+    ports:
+      - 8001:80
+      - 3306:3306
+    volumes:
+      - "../h-source:/app"
+      - "../mysql:/var/lib/mysql"
diff --git a/docker/lamp-php7.Dockerfile b/docker/lamp-php7.Dockerfile
new file mode 100644
index 0000000..4dc7b50
--- /dev/null
+++ b/docker/lamp-php7.Dockerfile
@@ -0,0 +1,3 @@
+FROM mattrayner/lamp:latest-1804
+
+CMD ["/run.sh"]
\ No newline at end of file
diff --git a/docker/readme-php5.sh b/docker/readme-lamp.sh
similarity index 56%
rename from docker/readme-php5.sh
rename to docker/readme-lamp.sh
index 7ec58b1..c73cbfa 100755
--- a/docker/readme-php5.sh
+++ b/docker/readme-lamp.sh
@@ -1,6 +1,13 @@
 #!/bin/bash
 #
-# INSTRUCTIONS for testing with docker-lamp-php5:
+# Spin up a docker lamp image.
+#
+# Usage:
+# ./readme-lamp.sh [php-version]
+#
+# php-version: 5 or 7 (default)
+#
+# INSTRUCTIONS for testing with docker-lamp-php{5,7}:
 #
 # After the docker container spins up,
 # the mysql password will be displayed.
@@ -12,5 +19,8 @@
 # and populate the schema/initial data with:
 #      mysql -uadmin -pXXX -h127.0.0.1 hnode < ../h-source/tables.sql
 
-docker-compose up --build lamp-php5
-
+if [ -z "$1"]; then
+    docker-compose up --build lamp-php7
+else
+    docker-compose up --build lamp-php"$1"
+fi
-- 
2.33.0


--
Best,
Yuchen

PGP Key: 47F9 D050 1E11 8879 9040  4941 2126 7E93 EF86 DFD0
          <https://ypei.me/assets/ypei-pubkey.txt>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]