@fishawack/lab-env 1.15.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.18.0 (2022-02-28)
4
+ * [Feature] Can now pass container name to rebuild/build commands
5
+ * [Feature] Craftcms now a supported tech stack
6
+ * [Change] Laravel now installs ghostscript and imagemagick by default
7
+ * [Change] Drupal now installs ghostscript and imagemagick by default
8
+ * [Misc] No longer rename clone folders when testing lab-env itself
9
+
10
+ ### 1.17.0 (2022-01-27)
11
+ * [Feature] Drupals php image now contains imagemagick and imagick
12
+ * [Change] Drupals php image is now labelled and tagged
13
+
14
+ ### 1.16.0 (2022-01-25)
15
+ * [Feature] lab-env now checks if docker process is running. Only `origin` and `--version` commands allowed if not
16
+
3
17
  ### 1.15.0 (2022-01-17)
4
18
  * [Feature] Docker images are now pulled from docker hub if lab-env not running with devDependencies installed
5
19
  * [Feature] Added a package.json to the core package in lab-env for more streamlined docker hub publishes
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const repo = `boilerplate-craftcms`;
4
+ const opts = {encoding: 'utf8', stdio: 'inherit', cwd: `_Test/_fixtures/${repo}`};
5
+
6
+ const expect = require('chai').expect;
7
+ const execSync = require('child_process').execSync;
8
+
9
+ describe('deploy', () => {
10
+ before(function(){
11
+ this.timeout(60000 * 10);
12
+
13
+ execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
+
15
+ execSync('fw setup', opts);
16
+
17
+ execSync('fw prod', opts);
18
+ });
19
+
20
+ it(`All ${repo} tests should pass`, async () => {
21
+ expect(execSync('fw test', opts)).to.not.equal(Error);
22
+ });
23
+
24
+ after(() => {
25
+ execSync('fw nuke', opts)
26
+
27
+ execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
+ });
29
+ });
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const repo = `lab-env_boilerplate-drupal`;
3
+ const repo = `boilerplate-drupal`;
4
4
  const opts = {encoding: 'utf8', stdio: 'inherit', cwd: `_Test/_fixtures/${repo}`};
5
5
 
6
6
  const expect = require('chai').expect;
@@ -10,14 +10,14 @@ describe('deploy', () => {
10
10
  before(function(){
11
11
  this.timeout(60000 * 10);
12
12
 
13
- execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate-drupal _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
13
+ execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
15
  execSync('fw setup', opts);
16
16
 
17
17
  execSync('fw prod', opts);
18
18
  });
19
19
 
20
- it('All boilerplate-drupal tests should pass', async () => {
20
+ it(`All ${repo} tests should pass`, async () => {
21
21
  expect(execSync('fw test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const repo = `lab-env_boilerplate-laravel`;
3
+ const repo = `boilerplate-laravel`;
4
4
  const opts = {encoding: 'utf8', stdio: 'inherit', cwd: `_Test/_fixtures/${repo}`};
5
5
 
6
6
  const expect = require('chai').expect;
@@ -10,14 +10,14 @@ describe('deploy', () => {
10
10
  before(function(){
11
11
  this.timeout(60000 * 10);
12
12
 
13
- execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate-laravel _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
13
+ execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
15
  execSync('fw setup', opts);
16
16
 
17
17
  execSync('fw prod', opts);
18
18
  });
19
19
 
20
- it('All boilerplate-laravel tests should pass', async () => {
20
+ it(`All ${repo} tests should pass`, async () => {
21
21
  expect(execSync('fw test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const repo = `lab-env_boilerplate-wordpress`;
3
+ const repo = `boilerplate-wordpress`;
4
4
  const opts = {encoding: 'utf8', stdio: 'inherit', cwd: `_Test/_fixtures/${repo}`};
5
5
 
6
6
  const expect = require('chai').expect;
@@ -10,14 +10,14 @@ describe('deploy', () => {
10
10
  before(function(){
11
11
  this.timeout(60000 * 10);
12
12
 
13
- execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate-wordpress _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
13
+ execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
15
  execSync('fw setup', opts);
16
16
 
17
17
  execSync('fw prod', opts);
18
18
  });
19
19
 
20
- it('All boilerplate-wordpress tests should pass', async () => {
20
+ it(`All ${repo} tests should pass`, async () => {
21
21
  expect(execSync('fw test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const repo = `lab-env_boilerplate`;
3
+ const repo = `boilerplate`;
4
4
  const opts = {encoding: 'utf8', stdio: 'inherit', cwd: `_Test/_fixtures/${repo}`};
5
5
 
6
6
  const expect = require('chai').expect;
@@ -10,14 +10,14 @@ describe('deploy', () => {
10
10
  before(function(){
11
11
  this.timeout(60000 * 10);
12
12
 
13
- execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
13
+ execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
15
  execSync('fw setup', opts);
16
16
 
17
17
  execSync('fw prod', opts);
18
18
  });
19
19
 
20
- it('All boilerplate tests should pass', async () => {
20
+ it(`All ${repo} tests should pass`, async () => {
21
21
  expect(execSync('fw test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
package/cli.js CHANGED
@@ -15,6 +15,9 @@ const { hideBin } = require('yargs/helpers');
15
15
 
16
16
  const args = hideBin(process.argv);
17
17
 
18
+ // Stop here if docker process not running and command isn't version or origin which don't require docker
19
+ if(!_.services && !(args[0] === 'origin' || args[0] === '--version')) return;
20
+
18
21
  (async () => {
19
22
  process.env.REPO = _.repo;
20
23
 
@@ -33,12 +36,16 @@ const args = hideBin(process.argv);
33
36
  if(_.platform === "laravel"){
34
37
  commands.push('artisan');
35
38
  }
39
+
40
+ if(_.platform === "craftcms"){
41
+ commands.push('craft');
42
+ }
36
43
 
37
44
  if(_.platform === "drupal"){
38
45
  commands.push('drush');
39
46
  }
40
47
 
41
- if(_.platform === "laravel" || _.platform === "drupal"){
48
+ if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms"){
42
49
  commands.push('composer', 'php');
43
50
  }
44
51
 
@@ -12,4 +12,4 @@ module.exports = [
12
12
  });
13
13
  },
14
14
  argv => _.up(() => execSync(`${_.docker} ${_.exec} php bash -lc "php artisan ${argv.command.join(' ')}"`, _.opts))
15
- ];
15
+ ];
package/commands/check.js CHANGED
@@ -15,8 +15,8 @@ module.exports = [
15
15
  argv => {
16
16
  execSync(`${_.docker} ${_.run}c "check-dependencies ${argv.v ? '' : '&>/dev/null'} && echo -e '\\033[0;32mNpm deps OK\\033[0m' || { echo -e '\\033[0;31mNpm deps missing or outdated\\033[0m'; }"`, _.opts);
17
17
 
18
- if(_.platform === "laravel" || _.platform === "drupal"){
18
+ if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms" ){
19
19
  execSync(`${_.docker} ${_.method} php bash -lc "composer install --dry-run ${argv.v ? '' : '2>&1'} | grep -q 'Nothing to install, update or remove' && echo -e '\\033[0;32mComposer deps OK\\033[0m' || echo -e '\\033[0;31mComposer deps missing or outdated\\033[0m'"`, _.opts);
20
20
  }
21
21
  }
22
- ];
22
+ ];
package/commands/clean.js CHANGED
@@ -9,8 +9,8 @@ module.exports = [
9
9
  argv => {
10
10
  execSync(`${_.docker} ${_.run}c "git clean -xfd node_modules/ 2>/dev/null || true"`, _.opts);
11
11
 
12
- if(_.platform === "laravel" || _.platform === "drupal"){
12
+ if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms"){
13
13
  execSync(`${_.docker} ${_.method} php bash -lc "git clean -xfd vendor/ 2>/dev/null || true"`, _.opts);
14
14
  }
15
15
  }
16
- ];
16
+ ];
@@ -0,0 +1,15 @@
1
+ const _ = require('../globals.js');
2
+
3
+ const execSync = require('child_process').execSync;
4
+
5
+ module.exports = [
6
+ ['craft [command...]', 'craft'],
7
+ 'run craft command',
8
+ yargs => {
9
+ yargs.positional('command', {
10
+ describe: 'command to run',
11
+ default: ''
12
+ });
13
+ },
14
+ argv => _.up(() => execSync(`${_.docker} ${_.exec} php bash -lc "php craft ${argv.command.join(' ')}"`, _.opts))
15
+ ];
@@ -3,8 +3,13 @@ const _ = require('../../globals.js');
3
3
  const execSync = require('child_process').execSync;
4
4
 
5
5
  module.exports = [
6
- 'build',
6
+ 'build [image]',
7
7
  false,
8
- yargs => {},
9
- argv => execSync(`${_.docker} build`, _.opts)
8
+ yargs => {
9
+ yargs.positional('image', {
10
+ describe: 'image to build',
11
+ default: ''
12
+ });
13
+ },
14
+ argv => execSync(`${_.docker} build ${argv.image}`, _.opts)
10
15
  ];
@@ -3,8 +3,13 @@ const _ = require('../../globals.js');
3
3
  const execSync = require('child_process').execSync;
4
4
 
5
5
  module.exports = [
6
- 'rebuild',
6
+ 'rebuild [image]',
7
7
  false,
8
- yargs => {},
9
- argv => execSync(`${_.docker} build --no-cache`, _.opts)
8
+ yargs => {
9
+ yargs.positional('image', {
10
+ describe: 'image to rebuild',
11
+ default: ''
12
+ });
13
+ },
14
+ argv => execSync(`${_.docker} build ${argv.image} --no-cache`, _.opts)
10
15
  ];
@@ -9,7 +9,7 @@ module.exports = [
9
9
  'node_modules'
10
10
  ];
11
11
 
12
- if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
12
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal" || _.platform === "craftcms"){
13
13
  volumes.push(
14
14
  'mysql'
15
15
  );
@@ -27,7 +27,7 @@ module.exports = [
27
27
  );
28
28
  }
29
29
 
30
- if(_.platform === "laravel" || _.platform === "drupal"){
30
+ if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms"){
31
31
  volumes.push(
32
32
  'vendor'
33
33
  );
@@ -35,4 +35,4 @@ module.exports = [
35
35
 
36
36
  console.log(`${volumes.map(d => `${_.repo_safe}_${d}`).join('\n')}`);
37
37
  }
38
- ];
38
+ ];
@@ -9,8 +9,8 @@ module.exports = [
9
9
  argv => {
10
10
  execSync(`${_.docker} ${_.run}c "rm package-lock.json; git clean -xfd node_modules/ 2>/dev/null || true; npm install"`, _.opts);
11
11
 
12
- if(_.platform === "laravel" || _.platform === "drupal"){
12
+ if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms"){
13
13
  execSync(`${_.docker} ${_.method} php bash -lc "rm composer.lock; git clean -xfd vendor/ 2>/dev/null || true; composer install"`, _.opts)
14
14
  }
15
15
  }
16
- ];
16
+ ];
package/commands/setup.js CHANGED
@@ -7,10 +7,10 @@ module.exports = [
7
7
  'runs the initial setup',
8
8
  yargs => {},
9
9
  argv => {
10
- if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
10
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal" || _.platform === "craftcms"){
11
11
  _.up(() => execSync(`source ${__dirname}/../intercept.sh && /bin/bash ./_Scripts/setup.sh`, _.opts));
12
12
  } else {
13
13
  execSync(`${_.docker} ${_.run}c "npm run setup"`, _.opts);
14
14
  }
15
15
  }
16
- ];
16
+ ];
package/commands/start.js CHANGED
@@ -14,7 +14,7 @@ module.exports = [
14
14
  argv => {
15
15
  _.ports.get();
16
16
 
17
- if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
17
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal" || _.platform === "craftcms"){
18
18
  _.up(() => execSync(`${_.docker} ${_.exec} core bash -lc "npm start -- -- ${argv.flags.join(' ')}" 2>/dev/null`, _.opts));
19
19
  } else {
20
20
  execSync(`${_.docker} ${_.run}c "npm start -- -- ${argv.flags.join(' ')}" 2>/dev/null`, _.opts);
@@ -0,0 +1,44 @@
1
+ services:
2
+ mysql:
3
+ image: mysql:5.7
4
+ networks:
5
+ - default
6
+ environment:
7
+ - MYSQL_ROOT_PASSWORD=password
8
+ - MYSQL_DATABASE=${DB_DATABASE}
9
+ - MYSQL_USER=${DB_USER}
10
+ - MYSQL_PASSWORD=${DB_PASSWORD}
11
+ ports:
12
+ - "${PORT_DB:-3306}:3306"
13
+ volumes:
14
+ - mysql:/var/lib/mysql
15
+ nginx:
16
+ image: nginx:1.19
17
+ networks:
18
+ - default
19
+ volumes:
20
+ - $CWD/:/app
21
+ - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
22
+ ports:
23
+ - "${PORT_WEB:-8000}:80"
24
+ php:
25
+ build:
26
+ context: ./php/
27
+ dockerfile: Dockerfile
28
+ image: lab-env/craftcms/3/php:0.0.1
29
+ init: true
30
+ working_dir: /app
31
+ networks:
32
+ - default
33
+ volumes:
34
+ - $CWD/:/app
35
+ - ./php/custom.conf:/opt/bitnami/php/etc/custom.conf
36
+ - vendor:/app/vendor
37
+ networks:
38
+ default:
39
+ driver: "bridge"
40
+ volumes:
41
+ vendor:
42
+ driver: "local"
43
+ mysql:
44
+ driver: "local"
@@ -0,0 +1,37 @@
1
+ server {
2
+ listen 80 default_server;
3
+ listen [::]:80 default_server;
4
+ root /app/web;
5
+
6
+ add_header X-Frame-Options "SAMEORIGIN";
7
+ add_header X-XSS-Protection "1; mode=block";
8
+ add_header X-Content-Type-Options "nosniff";
9
+
10
+ index index.php;
11
+
12
+ charset utf-8;
13
+
14
+ location / {
15
+ try_files $uri $uri/ /index.php?$query_string;
16
+ }
17
+
18
+ location = /favicon.ico { access_log off; log_not_found off; }
19
+ location = /robots.txt { access_log off; log_not_found off; }
20
+
21
+ error_page 404 /index.php;
22
+
23
+ location ~ \.php$ {
24
+ fastcgi_pass php:9000;
25
+ include fastcgi_params;
26
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
27
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
28
+ }
29
+
30
+ location ~ \.(bmp|cur|gif|ico|jpe?g|png|svgz?|webp|pdf|dzi)$ {
31
+ add_header Access-Control-Allow-Origin *;
32
+ }
33
+
34
+ location ~ /\.(?!well-known).* {
35
+ deny all;
36
+ }
37
+ }
@@ -0,0 +1,17 @@
1
+ FROM chialab/php:7.4-fpm
2
+
3
+ MAINTAINER Mike Mellor
4
+
5
+ # Install mysql client
6
+ RUN apt-get update && \
7
+ apt-get install -y mariadb-client
8
+
9
+ # Install Imagemagick
10
+ RUN apt-get install -y libmagickwand-dev --no-install-recommends
11
+
12
+ # PHP Imagick ext
13
+ RUN pecl install imagick && docker-php-ext-enable imagick
14
+
15
+ # Cleanup apt-get install folders
16
+ RUN apt-get clean && \
17
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -0,0 +1,9 @@
1
+ [www]
2
+ user = www-data
3
+ group = www-data
4
+
5
+ listen.owner = www-data
6
+ listen.group = www-data
7
+ listen.mode = 0660
8
+
9
+ extension=oauth.so
@@ -33,6 +33,7 @@ services:
33
33
  build:
34
34
  context: ./php/
35
35
  dockerfile: Dockerfile
36
+ image: lab-env/drupal/9/php:0.0.2
36
37
  init: true
37
38
  working_dir: /app
38
39
  networks:
@@ -42,6 +43,7 @@ services:
42
43
  volumes:
43
44
  - $CWD/:/app
44
45
  - ./php/custom.ini:/usr/local/etc/php/conf.d/custom.ini
46
+ - ./php/policy.xml:/etc/ImageMagick-6/policy.xml
45
47
  - $CWD/themes:/app/web/themes
46
48
  - $CWD/modules:/app/web/modules
47
49
  - $CWD/sites:/app/web/sites
@@ -6,6 +6,15 @@ MAINTAINER Mike Mellor
6
6
  RUN apt-get update && \
7
7
  apt-get install -y mariadb-client
8
8
 
9
+ # Install Imagemagick
10
+ RUN apt-get install -y libmagickwand-dev --no-install-recommends
11
+
12
+ # PHP Imagick ext
13
+ RUN pecl install imagick && docker-php-ext-enable imagick
14
+
15
+ # Install ghostscript
16
+ RUN apt-get install -y ghostscript
17
+
9
18
  # Cleanup apt-get install folders
10
19
  RUN apt-get clean && \
11
20
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -0,0 +1,99 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE policymap [
3
+ <!ELEMENT policymap (policy)*>
4
+ <!ATTLIST policymap xmlns CDATA #FIXED ''>
5
+ <!ELEMENT policy EMPTY>
6
+ <!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
7
+ name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
8
+ stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
9
+ ]>
10
+ <!--
11
+ Configure ImageMagick policies.
12
+
13
+ Domains include system, delegate, coder, filter, path, or resource.
14
+
15
+ Rights include none, read, write, execute and all. Use | to combine them,
16
+ for example: "read | write" to permit read from, or write to, a path.
17
+
18
+ Use a glob expression as a pattern.
19
+
20
+ Suppose we do not want users to process MPEG video images:
21
+
22
+ <policy domain="delegate" rights="none" pattern="mpeg:decode" />
23
+
24
+ Here we do not want users reading images from HTTP:
25
+
26
+ <policy domain="coder" rights="none" pattern="HTTP" />
27
+
28
+ The /repository file system is restricted to read only. We use a glob
29
+ expression to match all paths that start with /repository:
30
+
31
+ <policy domain="path" rights="read" pattern="/repository/*" />
32
+
33
+ Lets prevent users from executing any image filters:
34
+
35
+ <policy domain="filter" rights="none" pattern="*" />
36
+
37
+ Any large image is cached to disk rather than memory:
38
+
39
+ <policy domain="resource" name="area" value="1GP"/>
40
+
41
+ Use the default system font unless overwridden by the application:
42
+
43
+ <policy domain="system" name="font" value="/usr/share/fonts/favorite.ttf"/>
44
+
45
+ Define arguments for the memory, map, area, width, height and disk resources
46
+ with SI prefixes (.e.g 100MB). In addition, resource policies are maximums
47
+ for each instance of ImageMagick (e.g. policy memory limit 1GB, -limit 2GB
48
+ exceeds policy maximum so memory limit is 1GB).
49
+
50
+ Rules are processed in order. Here we want to restrict ImageMagick to only
51
+ read or write a small subset of proven web-safe image types:
52
+
53
+ <policy domain="delegate" rights="none" pattern="*" />
54
+ <policy domain="filter" rights="none" pattern="*" />
55
+ <policy domain="coder" rights="none" pattern="*" />
56
+ <policy domain="coder" rights="read|write" pattern="{GIF,JPEG,PNG,WEBP}" />
57
+ -->
58
+ <policymap>
59
+ <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
60
+ <policy domain="resource" name="memory" value="256MiB"/>
61
+ <policy domain="resource" name="map" value="512MiB"/>
62
+ <policy domain="resource" name="width" value="16KP"/>
63
+ <policy domain="resource" name="height" value="16KP"/>
64
+ <!-- <policy domain="resource" name="list-length" value="128"/> -->
65
+ <policy domain="resource" name="area" value="128MP"/>
66
+ <policy domain="resource" name="disk" value="1GiB"/>
67
+ <!-- <policy domain="resource" name="file" value="768"/> -->
68
+ <!-- <policy domain="resource" name="thread" value="4"/> -->
69
+ <!-- <policy domain="resource" name="throttle" value="0"/> -->
70
+ <!-- <policy domain="resource" name="time" value="3600"/> -->
71
+ <!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
72
+ <!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
73
+ <!-- <policy domain="path" rights="none" pattern="@*" /> -->
74
+ <!-- <policy domain="cache" name="memory-map" value="anonymous"/> -->
75
+ <!-- <policy domain="cache" name="synchronize" value="True"/> -->
76
+ <!-- <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/> -->
77
+ <!-- <policy domain="system" name="max-memory-request" value="256MiB"/> -->
78
+ <!-- <policy domain="system" name="shred" value="2"/> -->
79
+ <!-- <policy domain="system" name="precision" value="6"/> -->
80
+ <!-- <policy domain="system" name="font" value="/path/to/font.ttf"/> -->
81
+ <!-- <policy domain="system" name="pixel-cache-memory" value="anonymous"/> -->
82
+ <!-- <policy domain="system" name="shred" value="2"/> -->
83
+ <!-- <policy domain="system" name="precision" value="6"/> -->
84
+ <!-- not needed due to the need to use explicitly by mvg: -->
85
+ <!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
86
+ <!-- use curl -->
87
+ <policy domain="delegate" rights="none" pattern="URL" />
88
+ <policy domain="delegate" rights="none" pattern="HTTPS" />
89
+ <policy domain="delegate" rights="none" pattern="HTTP" />
90
+ <!-- in order to avoid to get image with password text -->
91
+ <policy domain="path" rights="none" pattern="@*"/>
92
+ <!-- disable ghostscript format types -->
93
+ <!-- <policy domain="coder" rights="none" pattern="PS" />
94
+ <policy domain="coder" rights="none" pattern="PS2" />
95
+ <policy domain="coder" rights="none" pattern="PS3" />
96
+ <policy domain="coder" rights="none" pattern="EPS" />
97
+ <policy domain="coder" rights="none" pattern="PDF" />
98
+ <policy domain="coder" rights="none" pattern="XPS" /> -->
99
+ </policymap>
package/globals.js CHANGED
@@ -37,6 +37,8 @@ if(composer && composer.require && composer.require['laravel/framework']){
37
37
  platform = 'laravel';
38
38
  } else if(composer && composer.require && composer.require['drupal/core-recommended']){
39
39
  platform = 'drupal';
40
+ } else if(composer && composer.require && composer.require['craftcms/cms']){
41
+ platform = 'craftcms';
40
42
  } else if(wordpress) {
41
43
  platform = 'wordpress';
42
44
  } else {
@@ -78,17 +80,28 @@ if(platform === 'laravel'){
78
80
  }
79
81
 
80
82
  docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/drupal/9/docker-compose.yml ${core} -p ${repo}`;
83
+ } else if(platform === "craftcms"){
84
+ if(!existsSync(path.join(process.cwd(), '.env'))){
85
+ copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
86
+ }
87
+
88
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/craftcms/3/docker-compose.yml ${core} -p ${repo}`;
81
89
  } else {
82
90
  docker = `docker-compose ${core} -p ${repo}`;
83
91
  }
84
92
 
85
- services = execSync(`${docker} ps --services --filter "status=running"`, {encoding: 'utf8'});
86
- running = services.trim().length;
87
- exec = `exec ${process.env.CI_BUILD_ID ? '-T' : ''}`;
88
- method = running ? exec : 'run --rm --service-ports';
89
- run = `${method} core bash -l`;
93
+ try{
94
+ services = execSync(`${docker} ps --services --filter "status=running" 2>/dev/null`, {encoding: 'utf8'});
95
+ running = services.trim().length;
96
+ exec = `exec ${process.env.CI_BUILD_ID ? '-T' : ''}`;
97
+ method = running ? exec : 'run --rm --service-ports';
98
+ run = `${method} core bash -l`;
99
+ } catch(e){
100
+ console.log("Docker does not appear to be running...");
101
+ }
90
102
 
91
103
  module.exports = {
104
+ services,
92
105
  platform,
93
106
  repo,
94
107
  repo_safe: repo.replace(/\./g, ''),
@@ -105,7 +118,7 @@ module.exports = {
105
118
  process.env.PORT = await getPort({port: getPort.makeRange(3000, 3100)});
106
119
  process.env.PORT_OPT = +process.env.PORT + 1;
107
120
 
108
- if(platform === "laravel" || platform === "wordpress" || platform === "drupal"){
121
+ if(platform === "laravel" || platform === "wordpress" || platform === "drupal" || platform === "craftcms"){
109
122
  process.env.PORT_WEB = await getPort({port: getPort.makeRange(8000, 8100)});
110
123
  process.env.PORT_DB = await getPort({port: getPort.makeRange(3306, 3406)});
111
124
  }
@@ -117,7 +130,7 @@ module.exports = {
117
130
  process.env.PORT = ports.PORT;
118
131
  process.env.PORT_OPT = ports.PORT_OPT;
119
132
 
120
- if(platform === "laravel" || platform === "wordpress" || platform === "drupal"){
133
+ if(platform === "laravel" || platform === "wordpress" || platform === "drupal" || platform === "craftcms"){
121
134
  process.env.PORT_WEB = ports.PORT_WEB;
122
135
  process.env.PORT_DB = ports.PORT_DB;
123
136
  }
@@ -148,4 +161,4 @@ module.exports = {
148
161
  if(!running) execSync(`lab-env down`, opts);
149
162
  }
150
163
  }
151
- };
164
+ };
package/intercept.sh CHANGED
@@ -16,6 +16,10 @@ artisan(){
16
16
  command lab-env artisan "$@"
17
17
  }
18
18
 
19
+ craft(){
20
+ command lab-env craft "$@"
21
+ }
22
+
19
23
  php(){
20
24
  command lab-env php "$@"
21
25
  }
@@ -36,7 +40,8 @@ export -f npm;
36
40
  export -f composer;
37
41
  export -f drush;
38
42
  export -f artisan;
43
+ export -f craft;
39
44
  export -f php;
40
45
  export -f chown;
41
46
  export -f chmod;
42
- export -f sed;
47
+ export -f sed;
@@ -22,7 +22,10 @@ services:
22
22
  ports:
23
23
  - "${PORT_WEB:-8000}:80"
24
24
  php:
25
- image: chialab/php:7.3-fpm
25
+ build:
26
+ context: ./php/
27
+ dockerfile: Dockerfile
28
+ image: lab-env/laravel/8/php:0.0.1
26
29
  init: true
27
30
  working_dir: /app
28
31
  networks:
@@ -30,6 +33,7 @@ services:
30
33
  volumes:
31
34
  - $CWD/:/app
32
35
  - ./php/custom.conf:/opt/bitnami/php/etc/custom.conf
36
+ - ./php/policy.xml:/etc/ImageMagick-6/policy.xml
33
37
  - vendor:/app/vendor
34
38
  redis:
35
39
  image: redis:alpine
@@ -46,4 +50,4 @@ volumes:
46
50
  mysql:
47
51
  driver: "local"
48
52
  redis:
49
- driver: "local"
53
+ driver: "local"
@@ -0,0 +1,17 @@
1
+ FROM chialab/php:7.4-fpm
2
+
3
+ MAINTAINER Mike Mellor
4
+
5
+ # Install Imagemagick
6
+ RUN apt-get update && \
7
+ apt-get install -y libmagickwand-dev --no-install-recommends
8
+
9
+ # PHP Imagick ext
10
+ RUN pecl install imagick && docker-php-ext-enable imagick
11
+
12
+ # Install ghostscript
13
+ RUN apt-get install -y ghostscript
14
+
15
+ # Cleanup apt-get install folders
16
+ RUN apt-get clean && \
17
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -5,3 +5,5 @@ group = www-data
5
5
  listen.owner = www-data
6
6
  listen.group = www-data
7
7
  listen.mode = 0660
8
+
9
+ extension=oauth.so
@@ -0,0 +1,99 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE policymap [
3
+ <!ELEMENT policymap (policy)*>
4
+ <!ATTLIST policymap xmlns CDATA #FIXED ''>
5
+ <!ELEMENT policy EMPTY>
6
+ <!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
7
+ name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
8
+ stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
9
+ ]>
10
+ <!--
11
+ Configure ImageMagick policies.
12
+
13
+ Domains include system, delegate, coder, filter, path, or resource.
14
+
15
+ Rights include none, read, write, execute and all. Use | to combine them,
16
+ for example: "read | write" to permit read from, or write to, a path.
17
+
18
+ Use a glob expression as a pattern.
19
+
20
+ Suppose we do not want users to process MPEG video images:
21
+
22
+ <policy domain="delegate" rights="none" pattern="mpeg:decode" />
23
+
24
+ Here we do not want users reading images from HTTP:
25
+
26
+ <policy domain="coder" rights="none" pattern="HTTP" />
27
+
28
+ The /repository file system is restricted to read only. We use a glob
29
+ expression to match all paths that start with /repository:
30
+
31
+ <policy domain="path" rights="read" pattern="/repository/*" />
32
+
33
+ Lets prevent users from executing any image filters:
34
+
35
+ <policy domain="filter" rights="none" pattern="*" />
36
+
37
+ Any large image is cached to disk rather than memory:
38
+
39
+ <policy domain="resource" name="area" value="1GP"/>
40
+
41
+ Use the default system font unless overwridden by the application:
42
+
43
+ <policy domain="system" name="font" value="/usr/share/fonts/favorite.ttf"/>
44
+
45
+ Define arguments for the memory, map, area, width, height and disk resources
46
+ with SI prefixes (.e.g 100MB). In addition, resource policies are maximums
47
+ for each instance of ImageMagick (e.g. policy memory limit 1GB, -limit 2GB
48
+ exceeds policy maximum so memory limit is 1GB).
49
+
50
+ Rules are processed in order. Here we want to restrict ImageMagick to only
51
+ read or write a small subset of proven web-safe image types:
52
+
53
+ <policy domain="delegate" rights="none" pattern="*" />
54
+ <policy domain="filter" rights="none" pattern="*" />
55
+ <policy domain="coder" rights="none" pattern="*" />
56
+ <policy domain="coder" rights="read|write" pattern="{GIF,JPEG,PNG,WEBP}" />
57
+ -->
58
+ <policymap>
59
+ <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
60
+ <policy domain="resource" name="memory" value="256MiB"/>
61
+ <policy domain="resource" name="map" value="512MiB"/>
62
+ <policy domain="resource" name="width" value="16KP"/>
63
+ <policy domain="resource" name="height" value="16KP"/>
64
+ <!-- <policy domain="resource" name="list-length" value="128"/> -->
65
+ <policy domain="resource" name="area" value="128MP"/>
66
+ <policy domain="resource" name="disk" value="1GiB"/>
67
+ <!-- <policy domain="resource" name="file" value="768"/> -->
68
+ <!-- <policy domain="resource" name="thread" value="4"/> -->
69
+ <!-- <policy domain="resource" name="throttle" value="0"/> -->
70
+ <!-- <policy domain="resource" name="time" value="3600"/> -->
71
+ <!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
72
+ <!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
73
+ <!-- <policy domain="path" rights="none" pattern="@*" /> -->
74
+ <!-- <policy domain="cache" name="memory-map" value="anonymous"/> -->
75
+ <!-- <policy domain="cache" name="synchronize" value="True"/> -->
76
+ <!-- <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/> -->
77
+ <!-- <policy domain="system" name="max-memory-request" value="256MiB"/> -->
78
+ <!-- <policy domain="system" name="shred" value="2"/> -->
79
+ <!-- <policy domain="system" name="precision" value="6"/> -->
80
+ <!-- <policy domain="system" name="font" value="/path/to/font.ttf"/> -->
81
+ <!-- <policy domain="system" name="pixel-cache-memory" value="anonymous"/> -->
82
+ <!-- <policy domain="system" name="shred" value="2"/> -->
83
+ <!-- <policy domain="system" name="precision" value="6"/> -->
84
+ <!-- not needed due to the need to use explicitly by mvg: -->
85
+ <!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
86
+ <!-- use curl -->
87
+ <policy domain="delegate" rights="none" pattern="URL" />
88
+ <policy domain="delegate" rights="none" pattern="HTTPS" />
89
+ <policy domain="delegate" rights="none" pattern="HTTP" />
90
+ <!-- in order to avoid to get image with password text -->
91
+ <policy domain="path" rights="none" pattern="@*"/>
92
+ <!-- disable ghostscript format types -->
93
+ <!-- <policy domain="coder" rights="none" pattern="PS" />
94
+ <policy domain="coder" rights="none" pattern="PS2" />
95
+ <policy domain="coder" rights="none" pattern="PS3" />
96
+ <policy domain="coder" rights="none" pattern="EPS" />
97
+ <policy domain="coder" rights="none" pattern="PDF" />
98
+ <policy domain="coder" rights="none" pattern="XPS" /> -->
99
+ </policymap>
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "1.15.0",
3
+ "version": "1.18.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
7
- "test": "rm -rf _Test/_fixtures && mocha _Test/*.js --timeout 120s --bail",
7
+ "test": "rm -rf _Test/_fixtures && mkdir _Test/_fixtures && mocha _Test/*.js --timeout 120s --bail",
8
8
  "preversion": "npm test",
9
9
  "postversion": "git push && git push --tags && npm publish",
10
10
  "postpublish": "git checkout development && git merge master && git push"