From d7813d6fe6ba89e518652b934eb90d370026b78e Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 21 Apr 2026 12:36:00 +0100 Subject: [PATCH 01/10] wip: docker-compose for dev --- dev/Dockerfile.nginx | 26 ++++++++++ dev/docker-hms-init.sh | 17 +++++++ dev/docker-init.sql | 1 + dev/docker-krb5-init.sh | 35 ++++++++++++++ docker-compose.yaml | 102 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+) create mode 100644 dev/Dockerfile.nginx create mode 100755 dev/docker-hms-init.sh create mode 100644 dev/docker-init.sql create mode 100755 dev/docker-krb5-init.sh create mode 100644 docker-compose.yaml diff --git a/dev/Dockerfile.nginx b/dev/Dockerfile.nginx new file mode 100644 index 00000000..a2db4fa0 --- /dev/null +++ b/dev/Dockerfile.nginx @@ -0,0 +1,26 @@ +FROM trafex/php-nginx:3.10.0 AS build + +USER root + +RUN cd / && \ + apk add --no-cache php84-pear php84-dev gcc musl-dev make krb5-dev && \ + wget https://pecl.php.net/get/krb5-1.2.4.tgz && \ + tar zxf krb5-1.2.4.tgz && cd krb5-1.2.4 && \ + phpize84 && \ + ./configure --with-krb5kadm=S && \ + make -j8 && make install + +FROM trafex/php-nginx:3.10.0 AS final + +COPY --from=build /usr/lib/php84/modules/krb5.so /usr/lib/php84/modules/krb5.so + +USER root + +RUN apk add --no-cache php84-pdo_mysql php84-redis krb5 krb5-pkinit \ + php84-pcntl php84-posix php84-sodium php84-simplexml git && \ + echo 'extension=krb5.so' > /etc/php84/conf.d/krb5.ini && \ + echo -e '[safe]\ndirectory = *' > /.gitconfig && \ + wget https://getcomposer.org/download/2.9.7/composer.phar -O /usr/bin/composer && \ + chmod a+x /usr/bin/composer + +USER nobody diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh new file mode 100755 index 00000000..58ccdc30 --- /dev/null +++ b/dev/docker-hms-init.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +cd /hms + +composer upgrade --no-security-blocking + +php artisan make:cache-table || true +php artisan key:generate +php artisan migrate +php artisan doctrine:migration:refresh -n +php artisan hms:database:refresh-views +php artisan hms:database:refresh-procedures +php artisan permissions:defaults +php artisan meta:sync +php artisan db:seed +yes | php artisan passport:install +yes | php artisan ziggy:generate diff --git a/dev/docker-init.sql b/dev/docker-init.sql new file mode 100644 index 00000000..3adcc43e --- /dev/null +++ b/dev/docker-init.sql @@ -0,0 +1 @@ +CREATE DATABASE IF NOT EXISTS hms; diff --git a/dev/docker-krb5-init.sh b/dev/docker-krb5-init.sh new file mode 100755 index 00000000..55545588 --- /dev/null +++ b/dev/docker-krb5-init.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +sleep 5 + +# Setup kerberos keytab +export KRB5_CONFIG=/shared/krb5.conf +cat > "$KRB5_CONFIG" < Date: Tue, 21 Apr 2026 16:13:06 +0100 Subject: [PATCH 02/10] compose minitor cleanup --- docker-compose.yaml | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index d921950e..1f335a74 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,7 +5,17 @@ networks: volumes: hms-shared: - mariadb: + hms-mariadb: + +x-hms-environment: &hms-environment + DB_HOST: hms-mysql + DB_USERNAME: root + DB_PASSWORD: "" + REDIS_HOST: hms-redis + KRB_USERNAME: hms/admin + KRB_REALM: NOTTINGHACK + KRB_KEYTAB: /shared/hms.keytab + KRB5_CONFIG: /shared/krb5.conf services: hms-web: @@ -23,14 +33,7 @@ services: - ./public:/var/www/html - hms-shared:/shared environment: - DB_HOST: hms-mysql - DB_USERNAME: root - DB_PASSWORD: "" - REDIS_HOST: hms-redis - KRB_USERNAME: hms/admin - KRB_REALM: NOTTINGHACK - KRB_KEYTAB: /shared/hms.keytab - KRB5_CONFIG: /shared/krb5.conf + <<: *hms-environment hms-mysql: image: mariadb:latest @@ -39,7 +42,7 @@ services: networks: - hms volumes: - - mariadb:/var/lib/mysql:Z + - hms-mariadb:/var/lib/mysql:Z - ./dev/docker-init.sql:/docker-init.sql command: --init-file /docker-init.sql environment: @@ -70,14 +73,7 @@ services: networks: - hms environment: - DB_HOST: hms-mysql - DB_USERNAME: root - DB_PASSWORD: "" - REDIS_HOST: hms-redis - KRB_USERNAME: hms/admin - KRB_REALM: NOTTINGHACK - KRB_KEYTAB: /shared/hms.keytab - KRB5_CONFIG: /shared/krb5.conf + <<: *hms-environment volumes: - ./dev/docker-hms-init.sh:/docker-init.sh - ./:/hms @@ -95,7 +91,6 @@ services: - hms volumes: - ./dev/docker-krb5-init.sh:/docker-init.sh - - ./:/hms - hms-shared:/shared depends_on: hms-krb5: From d6fc178c45ca17d3d65b1e80b7dcd188f3c9d9d0 Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Sun, 28 Jun 2026 16:59:58 +0100 Subject: [PATCH 03/10] add phpMyAdmin --- docker-compose.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 1f335a74..63c601b8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -95,3 +95,12 @@ services: depends_on: hms-krb5: condition: service_started + + hms-pma: + image: phpmyadmin + ports: + - 8081:80 + networks: + - hms + environment: + - PMA_HOST=hms-mysql From 5cc6da4e90405a3aed69cf14c73fb6a4d050e4dd Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 16:36:24 +0100 Subject: [PATCH 04/10] add mailpit --- docker-compose.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 63c601b8..afa2fdac 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -35,6 +35,14 @@ services: environment: <<: *hms-environment + hms-mailpit: + image: ghcr.io/axllent/mailpit:v1.30.3 + networks: + - hms + ports: + - "1025:1025" + - "8025:8025" + hms-mysql: image: mariadb:latest ports: From a3c9611561a913f275a869b1eb8dbb228f32ddcd Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 16:49:50 +0100 Subject: [PATCH 05/10] Setup .env and APP_KEY --- dev/docker-hms-init.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh index 58ccdc30..f1b4504e 100755 --- a/dev/docker-hms-init.sh +++ b/dev/docker-hms-init.sh @@ -4,6 +4,11 @@ cd /hms composer upgrade --no-security-blocking +[ -f .env ] || ( + cp .env.example .env + php artisan key:generate +) + php artisan make:cache-table || true php artisan key:generate php artisan migrate From edc5a2817d919caaf07e89598b4e3cbd092b9b81 Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 17:11:07 +0100 Subject: [PATCH 06/10] mix and dev notes --- README.md | 24 +++++++++++++++++++----- dev/Dockerfile.nginx | 2 +- dev/docker-hms-init.sh | 5 +++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1252d07d..5bb0de5e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,21 @@ We use submodules, either clone them with this repo or after `git submodule update --init` -### Hosts File +### Development with docker-compose + +1. Modify `.npmrc` to include the font awesome API key +2. Make read/write to the containers `chmod a+rw -R .` +3. Start everything with `docker compose up` + +After a minute or two you should be able to access: + +* HMS at http://localhost:8080 +* phpMyAdmin at http://localhost:8081 +* mailpit at http://localhost:8025 + +### Development with Vagrant + +#### Hosts File Most of the development environment is taken care of by vagrant, you just need to `vagrant up` to load it. @@ -31,9 +45,9 @@ You can find your file in the following location: * Mac: /private/etc/hosts * Linux: /etc/hosts -### Running commands on the Virtual Machine +#### Running commands on the Virtual Machine -#### Artisan +##### Artisan To run an artisan command on the VM, (for example if you don't have PHP installed on your local machine) use the ```php-artisan``` script that you can find in the dev/ folder. @@ -41,13 +55,13 @@ Simply pass it the artisan command you want to run, e.g: ```./dev/php-artisan make:controller``` -### Vagrant re-provisioning notes +#### Vagrant re-provisioning notes When re-provisioning the box (`vagrnat up`) you must make sure that the `.env` file has `QUEUE_CONNECTION=sync` in order the to the `db:seed` to correctly populate the `mailserver` database entries. If the `mailserver.mailbox` tables it empty you can do a datebase reset and reseed with `dev/reseed.sh` -### Vagrant suspend notes +#### Vagrant suspend notes When bringing up vagrant box after a suspend or halt some of the service my not start correctly due to the shared folder, run this script to restart them diff --git a/dev/Dockerfile.nginx b/dev/Dockerfile.nginx index a2db4fa0..d8718497 100644 --- a/dev/Dockerfile.nginx +++ b/dev/Dockerfile.nginx @@ -17,7 +17,7 @@ COPY --from=build /usr/lib/php84/modules/krb5.so /usr/lib/php84/modules/krb5.so USER root RUN apk add --no-cache php84-pdo_mysql php84-redis krb5 krb5-pkinit \ - php84-pcntl php84-posix php84-sodium php84-simplexml git && \ + php84-pcntl php84-posix php84-sodium php84-simplexml git npm && \ echo 'extension=krb5.so' > /etc/php84/conf.d/krb5.ini && \ echo -e '[safe]\ndirectory = *' > /.gitconfig && \ wget https://getcomposer.org/download/2.9.7/composer.phar -O /usr/bin/composer && \ diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh index f1b4504e..d8584af0 100755 --- a/dev/docker-hms-init.sh +++ b/dev/docker-hms-init.sh @@ -1,5 +1,7 @@ #!/bin/sh +HOME=/tmp + cd /hms composer upgrade --no-security-blocking @@ -20,3 +22,6 @@ php artisan meta:sync php artisan db:seed yes | php artisan passport:install yes | php artisan ziggy:generate + +npm install +npm run dev From 5e133c776e1e59d671dc7395b5e3cee54bb6d209 Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 17:32:01 +0100 Subject: [PATCH 07/10] tidy up --- README.md | 3 ++- dev/docker-hms-init.sh | 5 +++-- docker-compose.yaml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5bb0de5e..f8ed3235 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ or after ### Development with docker-compose -1. Modify `.npmrc` to include the font awesome API key +1. Set the `FONTAWSEOME_TOKEN` in your local shell + `export FONTAWESOME_TOKEN=` 2. Make read/write to the containers `chmod a+rw -R .` 3. Start everything with `docker compose up` diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh index d8584af0..f52a760d 100755 --- a/dev/docker-hms-init.sh +++ b/dev/docker-hms-init.sh @@ -1,6 +1,7 @@ #!/bin/sh -HOME=/tmp +HOME=/tmp/hms +mkdir $HOME cd /hms @@ -8,10 +9,10 @@ composer upgrade --no-security-blocking [ -f .env ] || ( cp .env.example .env + sed -i '/MAIL_HOST/s/hmsdev/hms-mailpit/' .env php artisan key:generate ) -php artisan make:cache-table || true php artisan key:generate php artisan migrate php artisan doctrine:migration:refresh -n diff --git a/docker-compose.yaml b/docker-compose.yaml index afa2fdac..d71a86d5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,6 +16,7 @@ x-hms-environment: &hms-environment KRB_REALM: NOTTINGHACK KRB_KEYTAB: /shared/hms.keytab KRB5_CONFIG: /shared/krb5.conf + FONTAWESOME_TOKEN: ${FONTAWESOME_TOKEN} services: hms-web: From 0988bda028ba936db182beb7648fd4a55c79a0e0 Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 17:39:03 +0100 Subject: [PATCH 08/10] fix caching --- dev/docker-hms-init.sh | 4 +++- docker-compose.yaml | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh index f52a760d..709c781d 100755 --- a/dev/docker-hms-init.sh +++ b/dev/docker-hms-init.sh @@ -9,7 +9,9 @@ composer upgrade --no-security-blocking [ -f .env ] || ( cp .env.example .env - sed -i '/MAIL_HOST/s/hmsdev/hms-mailpit/' .env + sed -i '/MAIL_HOST/cMAIL_HOST=hms-mailpit/' .env + sed -i '/REDIS_HOST/cREDIS_HOST=hms-redis/' .env + sed -i '/MEMCACHED_HOST/cMEMCACHED_HOST=hms-memcached/' .env php artisan key:generate ) diff --git a/docker-compose.yaml b/docker-compose.yaml index d71a86d5..18edee77 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -62,6 +62,11 @@ services: networks: - hms + hms-memcached: + image: memcached:trixie + networks: + - hms + hms-krb5: image: gcavalcante8808/krb5-server networks: From b4cebb63a4592b16a0392fba63fa280c79b71b2b Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 17:47:22 +0100 Subject: [PATCH 09/10] persist between up/down --- dev/docker-hms-init.sh | 31 ++++++++++++++++--------------- docker-compose.yaml | 2 ++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh index 709c781d..9656bfd2 100755 --- a/dev/docker-hms-init.sh +++ b/dev/docker-hms-init.sh @@ -5,26 +5,27 @@ mkdir $HOME cd /hms -composer upgrade --no-security-blocking - +# Stuff to happen on the first run only [ -f .env ] || ( cp .env.example .env sed -i '/MAIL_HOST/cMAIL_HOST=hms-mailpit/' .env sed -i '/REDIS_HOST/cREDIS_HOST=hms-redis/' .env sed -i '/MEMCACHED_HOST/cMEMCACHED_HOST=hms-memcached/' .env php artisan key:generate -) -php artisan key:generate -php artisan migrate -php artisan doctrine:migration:refresh -n -php artisan hms:database:refresh-views -php artisan hms:database:refresh-procedures -php artisan permissions:defaults -php artisan meta:sync -php artisan db:seed -yes | php artisan passport:install -yes | php artisan ziggy:generate + composer install --no-security-blocking + + php artisan migrate + php artisan doctrine:migration:refresh -n + php artisan hms:database:refresh-views + php artisan hms:database:refresh-procedures + php artisan permissions:defaults + php artisan meta:sync + php artisan db:seed + yes | php artisan passport:install + yes | php artisan ziggy:generate + + npm ci + npm run dev +) -npm install -npm run dev diff --git a/docker-compose.yaml b/docker-compose.yaml index 18edee77..b4544d61 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,6 +6,7 @@ networks: volumes: hms-shared: hms-mariadb: + hms-krb5: x-hms-environment: &hms-environment DB_HOST: hms-mysql @@ -73,6 +74,7 @@ services: - hms volumes: - hms-shared:/shared:rw + - hms-krb5:/var/lib/krb5kdc:rw environment: KRB5_REALM: NOTTINGHACK KRB5_KDC: localhost From aacddc9d1937a393d4a8f1851818cd10b4f113de Mon Sep 17 00:00:00 2001 From: Aaron Jackson Date: Tue, 30 Jun 2026 18:55:01 +0100 Subject: [PATCH 10/10] tweaks --- README.md | 3 +++ dev/docker-hms-init.sh | 4 ++-- docker-compose.yaml | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f8ed3235..79a38f79 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ or after ### Development with docker-compose +The docker-compose stuff is not suitable for production. It probably +could be made to be production ready, but for now it's only for dev. + 1. Set the `FONTAWSEOME_TOKEN` in your local shell `export FONTAWESOME_TOKEN=` 2. Make read/write to the containers `chmod a+rw -R .` diff --git a/dev/docker-hms-init.sh b/dev/docker-hms-init.sh index 9656bfd2..e6da8d20 100755 --- a/dev/docker-hms-init.sh +++ b/dev/docker-hms-init.sh @@ -1,7 +1,7 @@ #!/bin/sh HOME=/tmp/hms -mkdir $HOME +mkdir -p $HOME cd /hms @@ -11,10 +11,10 @@ cd /hms sed -i '/MAIL_HOST/cMAIL_HOST=hms-mailpit/' .env sed -i '/REDIS_HOST/cREDIS_HOST=hms-redis/' .env sed -i '/MEMCACHED_HOST/cMEMCACHED_HOST=hms-memcached/' .env - php artisan key:generate composer install --no-security-blocking + php artisan key:generate php artisan migrate php artisan doctrine:migration:refresh -n php artisan hms:database:refresh-views diff --git a/docker-compose.yaml b/docker-compose.yaml index b4544d61..0718fcfc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -29,7 +29,6 @@ services: - "8080:8080" networks: - hms - user: nobody volumes: - ./:/var/www - ./public:/var/www/html @@ -85,7 +84,6 @@ services: image: hms-php-nginx pull_policy: never command: /docker-init.sh - user: nobody networks: - hms environment: