@fishawack/lab-env 4.25.3 → 4.27.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/_Test/provision.js +39 -16
  3. package/_Test/s3.js +35 -0
  4. package/_Test/utilities.js +35 -1
  5. package/cli.js +0 -2
  6. package/commands/create/cmds/deprovision.js +31 -19
  7. package/commands/create/cmds/provision.js +47 -26
  8. package/commands/create/libs/prompts.js +18 -0
  9. package/commands/create/libs/utilities.js +32 -1
  10. package/commands/create/libs/vars.js +329 -1
  11. package/commands/create/services/aws/cloudfront.js +6 -13
  12. package/commands/create/services/aws/ec2.js +17 -0
  13. package/commands/create/services/aws/elasticbeanstalk.js +96 -0
  14. package/commands/create/services/aws/iam.js +123 -4
  15. package/commands/create/services/aws/index.js +98 -3
  16. package/commands/create/services/aws/misc.js +2 -0
  17. package/commands/create/services/aws/s3.js +48 -5
  18. package/commands/create/services/email.js +20 -23
  19. package/commands/create/templates/elasticbeanstalk/.ebextensions/{apache → httpd}/auto-ssl.config +18 -6
  20. package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/software.config +1 -12
  21. package/commands/create/templates/elasticbeanstalk/.ebextensions/misc/enable-https-lb.config +9 -0
  22. package/commands/create/templates/elasticbeanstalk/.ebextensions/misc/s3-env.config +41 -0
  23. package/commands/create/templates/elasticbeanstalk/.ebextensions/misc/setvars.config +8 -2
  24. package/commands/create/templates/elasticbeanstalk/.ebextensions/nginx/alb-health.config +28 -0
  25. package/commands/create/templates/elasticbeanstalk/.ebextensions/nginx/auto-ssl.config +19 -7
  26. package/commands/create/templates/elasticbeanstalk/.ebextensions/wordpress/alb-health.config +28 -0
  27. package/commands/create/templates/elasticbeanstalk/.ebextensions/wordpress/cron.config +42 -0
  28. package/commands/create/templates/elasticbeanstalk/.ebextensions/wordpress/environment.config +3 -1
  29. package/commands/create/templates/elasticbeanstalk/.ebextensions/wordpress/post-deploy.config +11 -8
  30. package/commands/create/templates/elasticbeanstalk/.ebextensions/wordpress/software.config +1 -3
  31. package/commands/create/templates/elasticbeanstalk/.elasticbeanstalk/config.yml +7 -0
  32. package/commands/create/templates/elasticbeanstalk/.platform/confighooks/postdeploy/rewrite-flush.sh +4 -0
  33. package/commands/create/templates/elasticbeanstalk/.platform/hooks/postdeploy/rewrite-flush.sh +4 -0
  34. package/commands/create/templates/elasticbeanstalk/.platform/hooks/postdeploy/s3-env.sh +7 -0
  35. package/commands/create/templates/elasticbeanstalk/.platform/hooks/predeploy/deactivate-plugins-single.sh +30 -0
  36. package/commands/create/templates/elasticbeanstalk/.platform/hooks/predeploy/deactivate-plugins.sh +55 -0
  37. package/commands/create/templates/elasticbeanstalk/.platform/httpd/conf.d/elasticbeanstalk/80/forward-https-proto.conf +3 -0
  38. package/commands/create/templates/elasticbeanstalk/.platform/httpd/conf.d/elasticbeanstalk/z-wordpress-htpasswd.conf +13 -0
  39. package/commands/create/templates/elasticbeanstalk/.platform/httpd/conf.d/security_headers-wordpress.conf +11 -0
  40. package/commands/create/templates/elasticbeanstalk/.platform/nginx/conf.d/elasticbeanstalk/health.conf +4 -0
  41. package/commands/create/templates/elasticbeanstalk/.platform/nginx/conf.d/elasticbeanstalk/htpasswd.conf +2 -0
  42. package/globals.js +13 -0
  43. package/laravel/9/docker-compose.yml +2 -2
  44. package/package.json +6 -1
  45. /package/commands/create/templates/elasticbeanstalk/.platform/httpd/conf.d/elasticbeanstalk/{443 → 80}/www-to-nonwww-redirection.conf +0 -0
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Exit out if no current folder exists as that means this is a brand new instance
6
+ if [ ! -d "/var/app/current/" ]; then
7
+ echo "New instance - skipping as no existing web dir exists"
8
+ exit 0;
9
+ fi
10
+
11
+ INSTANCE_ID=`curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null`
12
+ REGION=`curl -s http://169.254.169.254/latest/dynamic/instance-identity/document 2>/dev/null | jq -r .region`
13
+ AWSARG="--region $REGION --output json"
14
+
15
+ # Get elastic beanstalk environment name
16
+ ENVNAME=`aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" $AWSARG | jq -r '.[][] | select(.Key=="elasticbeanstalk:environment-name") | .Value'`
17
+
18
+ # Get last 25 elastic beanstalk events
19
+ EVENTS=`aws elasticbeanstalk describe-events --environment-name $ENVNAME --max-items 25 $AWSARG`
20
+
21
+ # Find create event for Batch 2 and grab the first instance modified from its message
22
+ PREEXISTING_INSTANCE_ID=''
23
+ while read i ; do
24
+ if [[ $i == *"Batch 2: Starting application deployment on instance(s)"* ]]; then
25
+ PREEXISTING_INSTANCE_ID=$(echo $i | cut -d "[" -f2 | cut -d "]" -f1 | cut -d "," -f1)
26
+ break
27
+ fi
28
+ done <<< "$(echo $EVENTS | jq -rc '.Events[].Message')"
29
+
30
+ # Exit out if current instance is not the pre-existing instance
31
+ if [ "$INSTANCE_ID" != "$PREEXISTING_INSTANCE_ID" ]; then
32
+ echo "$INSTANCE_ID doesn't match the pre-existing instance id $PREEXISTING_INSTANCE_ID - skipping check for plugins"
33
+ exit 0;
34
+ fi
35
+
36
+ # Get a list of plugins from the current dir and staging dir for comparison
37
+ PREVPLUGINS=$(cd /var/app/current/; wp plugin list --fields=name --format=json) || echo "{}"
38
+ CURRENTPLUGINS=$(cd /var/app/staging/; wp plugin list --fields=name --format=json) || echo "{}"
39
+
40
+ # Loop through current plugins and check if they still exist in the staging dir - otherwise add them to the missing list
41
+ MISSING=''
42
+ for i in `echo $PREVPLUGINS | jq -rc '.[].name'`; do
43
+ if [ $(echo $CURRENTPLUGINS | jq -rc "any(.[]; .name == \"$i\")") == "false" ]; then
44
+ MISSING="${MISSING} $i"
45
+ fi
46
+ done
47
+
48
+ # Exit out if no missing plugins
49
+ if [ -z "$MISSING" ]; then
50
+ echo "No missing plugins - skipping deactivation"
51
+ exit 0;
52
+ fi
53
+
54
+ # Deactivate missing plugins
55
+ (cd /var/app/current/; wp plugin deactivate $MISSING)
@@ -0,0 +1,3 @@
1
+ <IfModule mod_setenvif.c>
2
+ SetEnvIf X-Forwarded-Proto "^https$" HTTPS
3
+ </IfModule>
@@ -0,0 +1,13 @@
1
+ <Directory /var/www/html/wordpress>
2
+ AuthName "Restricted Content"
3
+ AuthType Basic
4
+ AuthUserFile /etc/httpd/conf.d/elasticbeanstalk/.htpasswd
5
+ Require valid-user
6
+ ErrorDocument 401 "401 Unauthorized"
7
+ </Directory>
8
+
9
+ <Directory /var/www/html/wordpress/wp-content/themes/fishawack/>
10
+ <Files "health.html">
11
+ Require all granted
12
+ </Files>
13
+ </Directory>
@@ -0,0 +1,11 @@
1
+ Header set X-Content-Type-Options "nosniff"
2
+ Header set Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';"
3
+ Header set X-Frame-Options 'sameorigin'
4
+ Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
5
+
6
+ ServerSignature Off
7
+ ServerTokens Prod
8
+
9
+ <Files "xmlrpc.php">
10
+ Require all denied
11
+ </Files>
@@ -0,0 +1,4 @@
1
+ location /health {
2
+ return 200 'ok';
3
+ add_header Content-Type text/plain;
4
+ }
@@ -0,0 +1,2 @@
1
+ auth_basic "Restricted Content";
2
+ auth_basic_user_file /etc/nginx/conf.d/elasticbeanstalk/.htpasswd;
package/globals.js CHANGED
@@ -52,6 +52,8 @@ try{
52
52
  repo = path.basename(cwd);
53
53
  }
54
54
 
55
+ process.env.REPO = repo;
56
+
55
57
  const repo_safe = repo.replace(/\./g, '');
56
58
 
57
59
  try{ pkg = require(path.join(cwd, 'package.json')); } catch(e){}
@@ -146,6 +148,8 @@ process.env.FW_CORE_1_TARGET_IMAGE = process.env.FW_CORE_1_TARGET_IMAGE || (proc
146
148
  process.env.FW_CORE_1_TARGET = process.env.FW_CORE_1_TARGET || (process.env.FW_FULL ? "full" : "alpine");
147
149
  process.env.FW_CORE_1_IMAGE = process.env.FW_CORE_1_IMAGE || `fishawack/lab-env-core-1${process.env.FW_CORE_1_TARGET_IMAGE}`;
148
150
 
151
+ process.env.FW_LARAVEL_8_NGINX_IMAGE = process.env.FW_LARAVEL_8_NGINX_IMAGE || `fishawack/lab-env-laravel-8-nginx`;
152
+
149
153
  var core = `-f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml`;
150
154
 
151
155
  // Map versions of images
@@ -171,6 +175,15 @@ if(existsSync(path.join(contextOverride, 'Dockerfile'))){
171
175
  process.env.FW_CORE_1_IMAGE += `-${repo_safe}`;
172
176
  }
173
177
 
178
+ process.env.FW_LARAVEL_8_NGINX_CONTEXT = process.env.FW_LARAVEL_8_NGINX_CONTEXT || `${__dirname}/laravel/8/nginx/`;
179
+
180
+ contextOverride = path.join(cwd, '_Docker/laravel/8/nginx');
181
+ if(existsSync(path.join(contextOverride, 'Dockerfile'))){
182
+ process.env.FW_LARAVEL_8_NGINX_CONTEXT = contextOverride;
183
+ process.env.FW_LARAVEL_8_NGINX_IMAGE += `-${repo_safe}`;
184
+ process.env.FW_LARAVEL_8_NGINX_VERSION = require(`${contextOverride}/package.json`).version;
185
+ }
186
+
174
187
  if(existsSync(path.join(cwd, '.env.example')) && !existsSync(path.join(cwd, '.env'))){
175
188
  copyFileSync(path.join(cwd, '.env.example'), path.join(cwd, '.env'));
176
189
  }
@@ -14,9 +14,9 @@ services:
14
14
  - mysql:/var/lib/mysql
15
15
  nginx:
16
16
  build:
17
- context: $DIRNAME/laravel/8/nginx/
17
+ context: $FW_LARAVEL_8_NGINX_CONTEXT
18
18
  target: development
19
- image: fishawack/lab-env-laravel-8-nginx:${FW_LARAVEL_8_NGINX_VERSION:-latest}
19
+ image: $FW_LARAVEL_8_NGINX_IMAGE:${FW_LARAVEL_8_NGINX_VERSION:-latest}
20
20
  networks:
21
21
  - default
22
22
  volumes:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "4.25.3",
3
+ "version": "4.27.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
@@ -23,15 +23,20 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@aws-sdk/client-cloudfront": "^3.141.0",
26
+ "@aws-sdk/client-ec2": "^3.399.0",
27
+ "@aws-sdk/client-elastic-beanstalk": "^3.395.0",
26
28
  "@aws-sdk/client-iam": "^3.150.0",
27
29
  "@aws-sdk/client-s3": "^3.141.0",
30
+ "apache-md5": "^1.1.8",
28
31
  "axios": "^0.21.4",
29
32
  "chalk": "4.1.0",
33
+ "fs-extra": "^11.1.1",
30
34
  "generate-password": "^1.7.0",
31
35
  "get-port": "5.1.1",
32
36
  "git-branch": "^2.0.1",
33
37
  "glob": "7.1.7",
34
38
  "inquirer": "8.1.2",
39
+ "lodash": "^4.17.21",
35
40
  "nodemailer": "^6.7.8",
36
41
  "ora": "5.4.1",
37
42
  "semver": "7.3.4",