@fishawack/lab-env 4.22.1 → 4.24.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,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 4.23.0 (2023-10-24)
4
+ * [Feature] add target and target_image args to dockerfile build process to overrides can switch between full and alpine
5
+ * [Feature] added new clients
6
+ * [Feature] automatically override docker context and image name if core found in correct folder structure
7
+ * [Feature] can now override target and image env variables
8
+ * [Feature] can now specify docker context as env variable
9
+
3
10
  ### 4.22.1 (2023-08-14)
4
11
  * [Change] Bumped fishawack/lab-env-craftcms-3-php to 1.0.1
5
12
  * [Change] Bumped fishawack/lab-env-drupal-9-php to 0.6.1
@@ -6,7 +6,7 @@ module.exports.iam = require("./iam.js");
6
6
 
7
7
  module.exports.slug = (repo, client, branch) => s3Safe(`${branch}-${repo}-${client}`);
8
8
 
9
- module.exports.clients = ['fishawack', 'abbvie', 'sanofigenzyme', 'gsk', 'janssen', 'astrazeneca', 'ptc', 'jazz', 'pfizer', 'heron', 'novartis', 'training', 'merck', 'acadia', 'travere', 'roche', 'utc', 'bayer', 'alcon', 'uhc', 'chiesi', '3m', 'sarepta', 'ipsen', 'novocure', 'anthem', 'kyowakirin', 'optum', 'rally', 'menarini', 'childrensminnesota', 'gore'];
9
+ module.exports.clients = ['fishawack', 'abbvie', 'sanofigenzyme', 'gsk', 'janssen', 'astrazeneca', 'ptc', 'jazz', 'pfizer', 'heron', 'novartis', 'training', 'merck', 'acadia', 'travere', 'roche', 'utc', 'bayer', 'alcon', 'uhc', 'chiesi', '3m', 'sarepta', 'ipsen', 'novocure', 'anthem', 'kyowakirin', 'optum', 'rally', 'menarini', 'childrensminnesota', 'gore', 'axogen', 'gedeonrichter'];
10
10
 
11
11
  module.exports.static = async (name, account, tags = [], credentials = []) => {
12
12
  let s3 = await module.exports.s3.createS3Bucket(name, account, tags);
@@ -2,11 +2,14 @@ version: "3.8"
2
2
  services:
3
3
  core:
4
4
  build:
5
- context: $DIRNAME/core/1/
6
- target: ${FW_CORE_1_TARGET:-alpine}
5
+ context: $FW_CORE_1_CONTEXT
6
+ target: $FW_CORE_1_TARGET
7
7
  ssh:
8
8
  - default
9
- image: ${FW_CORE_1_IMAGE:-fishawack/lab-env-core-1-alpine}:${FW_CORE_1_VERSION:-latest}
9
+ args:
10
+ target: $FW_CORE_1_TARGET
11
+ target_image: $FW_CORE_1_TARGET_IMAGE
12
+ image: $FW_CORE_1_IMAGE:${FW_CORE_1_VERSION:-latest}
10
13
  init: true
11
14
  tty: true
12
15
  volumes:
package/globals.js CHANGED
@@ -12,6 +12,8 @@ process.env.DIRNAME = __dirname;
12
12
  process.env.USER_UID=execSync("id -u", {encoding: 'utf8', stdio: 'pipe'}).trim();
13
13
  process.env.USER_GID=execSync("id -g", {encoding: 'utf8', stdio: 'pipe'}).trim();
14
14
 
15
+ const cwd = process.cwd();
16
+
15
17
  const isDirectory = source => lstatSync(source).isDirectory();
16
18
  const getDirectories = source => readdirSync(source).map(name => path.join(source, name)).filter(isDirectory);
17
19
 
@@ -45,18 +47,18 @@ try{
45
47
  }
46
48
 
47
49
  try{
48
- repo = execSync('basename "$(git rev-parse --show-toplevel)"', {encoding: 'utf8', stdio: 'pipe'}).trim() || path.basename(process.cwd());
50
+ repo = execSync('basename "$(git rev-parse --show-toplevel)"', {encoding: 'utf8', stdio: 'pipe'}).trim() || path.basename(cwd);
49
51
  } catch(e){
50
- repo = path.basename(process.cwd());
52
+ repo = path.basename(cwd);
51
53
  }
52
54
 
53
55
  const repo_safe = repo.replace(/\./g, '');
54
56
 
55
- try{ pkg = require(path.join(process.cwd(), 'package.json')); } catch(e){}
57
+ try{ pkg = require(path.join(cwd, 'package.json')); } catch(e){}
56
58
 
57
- try{ composer = require(path.join(process.cwd(), 'composer.json')); } catch(e){}
59
+ try{ composer = require(path.join(cwd, 'composer.json')); } catch(e){}
58
60
 
59
- try{ wordpress = existsSync(path.join(process.cwd(), 'wp-content/')); } catch(e){}
61
+ try{ wordpress = existsSync(path.join(cwd, 'wp-content/')); } catch(e){}
60
62
 
61
63
  if(composer && composer.require && composer.require['laravel/framework']){
62
64
  platform = 'laravel';
@@ -109,7 +111,7 @@ if(composer && composer.require && composer.require['laravel/framework']){
109
111
  } else {
110
112
  // Check for old wordpress repo stucture and show warning
111
113
  try{
112
- if(existsSync(path.join(process.cwd(), 'themes/'))){
114
+ if(existsSync(path.join(cwd, 'themes/'))){
113
115
  console.log(`This wordpress repo needs migrating to the new repo structure: \n${utilities.colorize(`https://demo.fishawack.solutions/Lab/Doc/#lab-env-migrating-200`, 'title')}`)
114
116
  process.exit(1);
115
117
  }
@@ -140,10 +142,9 @@ if(process.env.FW_NEXT){
140
142
  }
141
143
 
142
144
  // Map full image or alpine
143
- if(process.env.FW_FULL){
144
- process.env.FW_CORE_1_IMAGE = "fishawack/lab-env-core-1";
145
- process.env.FW_CORE_1_TARGET = "full";
146
- }
145
+ process.env.FW_CORE_1_TARGET_IMAGE = process.env.FW_CORE_1_TARGET_IMAGE || (process.env.FW_FULL ? "" : "-alpine");
146
+ process.env.FW_CORE_1_TARGET = process.env.FW_CORE_1_TARGET || (process.env.FW_FULL ? "full" : "alpine");
147
+ process.env.FW_CORE_1_IMAGE = process.env.FW_CORE_1_IMAGE || `fishawack/lab-env-core-1${process.env.FW_CORE_1_TARGET_IMAGE}`;
147
148
 
148
149
  var core = `-f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml`;
149
150
 
@@ -161,22 +162,31 @@ process.env.FW_WORDPRESS_0_VERSION = process.env.FW_WORDPRESS_0_VERSION || requi
161
162
  process.env.FW_WORDPRESS_1_PHP_VERSION = process.env.FW_WORDPRESS_1_PHP_VERSION || require('./wordpress/1/php/package.json').version;
162
163
  process.env.FW_WORDPRESS_1_APACHE_VERSION = process.env.FW_WORDPRESS_1_APACHE_VERSION || require('./wordpress/1/apache/package.json').version;
163
164
 
164
- if(existsSync(path.join(process.cwd(), '.env.example')) && !existsSync(path.join(process.cwd(), '.env'))){
165
- copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
165
+ // Map docker contexts
166
+ process.env.FW_CORE_1_CONTEXT = process.env.FW_CORE_1_CONTEXT || `${__dirname}/core/1/`;
167
+
168
+ let contextOverride = path.join(cwd, '_Docker/core/1/');
169
+ if(existsSync(path.join(contextOverride, 'Dockerfile'))){
170
+ process.env.FW_CORE_1_CONTEXT = contextOverride;
171
+ process.env.FW_CORE_1_IMAGE += `-${repo_safe}`;
172
+ }
173
+
174
+ if(existsSync(path.join(cwd, '.env.example')) && !existsSync(path.join(cwd, '.env'))){
175
+ copyFileSync(path.join(cwd, '.env.example'), path.join(cwd, '.env'));
166
176
  }
167
177
 
168
178
  if(platform === 'laravel'){
169
179
  let container = `-f ${__dirname}/laravel/${process.env.VERSION_LARAVEL}/docker-compose.yml`;
170
180
 
171
- docker = `docker compose --env-file ${path.join(process.cwd(), '.env')} ${container} ${core} -p ${repo_safe}`;
181
+ docker = `docker compose --env-file ${path.join(cwd, '.env')} ${container} ${core} -p ${repo_safe}`;
172
182
  } else if(platform === 'wordpress'){
173
- docker = `docker compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/wordpress/${process.env.VERSION_WORDPRESS}/docker-compose.yml ${core} -p ${repo_safe}`;
183
+ docker = `docker compose --env-file ${path.join(cwd, '.env')} -f ${__dirname}/wordpress/${process.env.VERSION_WORDPRESS}/docker-compose.yml ${core} -p ${repo_safe}`;
174
184
  } else if(platform === "drupal"){
175
185
  let container = `-f ${__dirname}/drupal/9/docker-compose.yml`;
176
186
 
177
- docker = `docker compose --env-file ${path.join(process.cwd(), '.env')} ${container} ${core} -p ${repo_safe}`;
187
+ docker = `docker compose --env-file ${path.join(cwd, '.env')} ${container} ${core} -p ${repo_safe}`;
178
188
  } else if(platform === "craftcms"){
179
- docker = `docker compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/craftcms/3/docker-compose.yml ${core} -p ${repo_safe}`;
189
+ docker = `docker compose --env-file ${path.join(cwd, '.env')} -f ${__dirname}/craftcms/3/docker-compose.yml ${core} -p ${repo_safe}`;
180
190
  } else {
181
191
  docker = `docker compose ${core} -p ${repo_safe}`;
182
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "4.22.1",
3
+ "version": "4.24.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {