]> BookStack Code Mirror - system-cli/commitdiff
Added a docker environment for stable dev
authorDan Brown <redacted>
Tue, 28 Mar 2023 15:00:34 +0000 (16:00 +0100)
committerDan Brown <redacted>
Tue, 28 Mar 2023 15:00:34 +0000 (16:00 +0100)
Dockerfile [new file with mode: 0644]
docker-compose.yml [new file with mode: 0644]
phpunit.xml [new file with mode: 0644]
readme.md

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..cd441d3
--- /dev/null
@@ -0,0 +1,14 @@
+FROM ubuntu:22.04
+
+# Install system depedancies
+ARG DEBIAN_FRONTEND=noninteractive
+RUN set -xe && \
+    apt-get update -yqq && \
+    apt-get install -yqq curl git mysql-client php8.1-cli php8.1-common php8.1-curl php8.1-mbstring \
+                         php8.1-xml php8.1-zip php8.1-gd php8.1-bcmath php8.1-mysql php8.1-xdebug
+
+# Install composer to a custom location
+RUN mkdir /scripts && \
+    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
+
+CMD ["/bin/bash"]
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644 (file)
index 0000000..a2054b5
--- /dev/null
@@ -0,0 +1,16 @@
+version: "3.8"
+
+services:
+  app:
+    build: .
+    volumes:
+      - ./:/cli
+    depends_on:
+      - db
+  db:
+    image: mysql:8.0
+    environment:
+      MYSQL_ROOT_PASSWORD: password
+      MYSQL_DATABASE: bookstack
+      MYSQL_USER: bookstack
+      MYSQL_PASSWORD: bookstack
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644 (file)
index 0000000..7b41a4f
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
+         bootstrap="vendor/autoload.php"
+         colors="true">
+    <testsuites>
+        <testsuite name="Tests">
+            <directory suffix="Test.php">./tests</directory>
+        </testsuite>
+    </testsuites>
+    <coverage processUncoveredFiles="true">
+        <include>
+            <directory suffix=".php">./app</directory>
+        </include>
+    </coverage>
+    <php>
+        <env name="APP_ENV" value="testing"/>
+    </php>
+</phpunit>
index 650a47f2dd455e2e5a1d2207f4ecffb59f43c4ba..186222f167c3564cc9a18f1572d7d1535849e036 100644 (file)
--- a/readme.md
+++ b/readme.md
@@ -8,7 +8,7 @@ A simple command line interface for managing instances of BookStack. Provides th
 - **Update** - Update an existing BookStack installation to the latest version.
 
 This CLI is intended to be platform abstract, intended for plain installs that follow our scripts/manual instructions.
-This is intended to work independently from BookStack itself, so it can be used even if a BookStack instance is not available or broken, although it could be distributed with and called upon by the core BookStack codebase.
+This is intended to work independently of BookStack itself, so it can be used even if a BookStack instance is not available or broken, although it could be distributed with and called upon by the core BookStack codebase.
 
 ### Development
 
@@ -25,7 +25,24 @@ This can be done by running the compile file:
 php compile.php
 ```
 
+#### Docker Environment
+
+A docker-compose setup exists to create a clean, contained environment, which is important for this project since the
+CLI checks and interacts with many system-level elements.
+
+```bash
+# Enter the environment
+docker compose run -w /cli app
+
+# From there you'll be dropped into a bash shell within the project directory.
+# You could proceed to install dependencies via composer via:
+composer install
+
+# Then you can run tests via:
+vendor/bin/phpunit
+```
+
 ### Contributing
 
 I welcome issues and PRs but keep in mind that I'd like to keep the feature-set narrow to limit support/maintenance burden.
-Therefore I likely won't leave issues open long, or merge PRs, for requests to add new features or for changes that increase the scope of what this script already supports.
\ No newline at end of file
+Therefore, I likely won't leave issues open long, or merge PRs, for requests to add new features or for changes that increase the scope of what this script already supports.
\ No newline at end of file