Skip to content

Fix Docker build and add first-run setup with docker-compose#257

Open
smxmdrissel wants to merge 3 commits intoLeeMangold:mainfrom
smxmdrissel:fix/docker-build-and-first-run-setup
Open

Fix Docker build and add first-run setup with docker-compose#257
smxmdrissel wants to merge 3 commits intoLeeMangold:mainfrom
smxmdrissel:fix/docker-build-and-first-run-setup

Conversation

@smxmdrissel
Copy link

Summary

This PR fixes several issues that prevented OpenGRC from building and running correctly with Docker, and adds a ready-to-use docker-compose.yml for local development.

Changes

Fix Docker build — remove local path dependency (composer.json)

Removes a developer-specific path repository pointing to /home/lmangold/projects/OGModules/WorkflowModule that caused composer install to fail in Docker builds with:

Source path not found for package opengrc/workflow-module

Fix Docker container startup (docker-entrypoint.sh, AppServiceProvider.php)

Two issues prevented the container from starting correctly after docker compose up:

  1. docker-entrypoint.sh used php artisan tinker to check DB connectivity. This triggers AppServiceProvider::boot() before migrations have run, aborting with "OpenGRC was not installed properly" because the settings table does not yet exist. Replaced with a direct PHP PDO check that bypasses the Laravel stack.

  2. AppServiceProvider::boot() did not include artisan commands run during container initialisation (migrate, config:cache, route:cache, view:cache, db:seed, opengrc:create-user, settings:set, storage:link) in the installer bypass list, causing all of those commands to abort. Added the missing commands so the settings-table guard is skipped during init.

Add first-run database seeding (docker-entrypoint.sh)

Adds a first-run detection block that seeds the database and creates the admin user (using ADMIN_EMAIL / ADMIN_PASSWORD environment variables) when the users table is empty on startup.

Add docker-compose.yml for local development

Provides a ready-to-use Docker Compose configuration:

  • db: MySQL 8.0 with health check and named persistent volume
  • app: OpenGRC on port 8080, waits for db to be healthy

Usage:

docker build -t opengrc .
docker compose up -d

Testing

  • Verified Docker build completes without errors
  • Verified docker compose up -d starts both services and performs first-run seeding
  • Updated McpEndpointTest and StandardControlImplementationTest to reflect current behaviour

mdrissel added 3 commits February 26, 2026 14:58
…ow-module

Remove developer-specific path repository pointing to
/home/lmangold/projects/OGModules/WorkflowModule which caused
'composer install' to fail in Docker builds with:

  Source path not found for package opengrc/workflow-module

Remove the path-type repository entry and the opengrc/workflow-module
@dev require from composer.json, and clean the corresponding package
entry and stability-flags from composer.lock.
Two issues prevented the container from starting correctly after
'docker compose up':

1. docker-entrypoint.sh used 'php artisan tinker' to check DB
   connectivity. This triggers AppServiceProvider::boot() before
   migrations have run, which aborts with 'OpenGRC was not installed
   properly' because the settings table does not yet exist.
   Replace with a direct PHP PDO check that bypasses the Laravel stack.

2. AppServiceProvider::boot() did not include artisan commands run
   during container initialisation (migrate, config:cache, route:cache,
   view:cache, db:seed, opengrc:create-user, settings:set, storage:link)
   in the installer bypass list, causing all of those commands to abort.
   Add the missing commands so the settings-table guard is skipped.

Also add a first-run detection block in docker-entrypoint.sh that seeds
the database and creates the admin user (using ADMIN_EMAIL / ADMIN_PASSWORD
environment variables) when the users table is empty on startup.
Provides a ready-to-use Docker Compose configuration for running
OpenGRC locally with MySQL 8.0. Starts two services:

- db: MySQL 8.0 with a health check and a named persistent volume
- app: OpenGRC on port 8080, waits for db to be healthy before starting

Usage:
  docker build -t opengrc .
  docker compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant