@fishawack/lab-env 4.34.0 → 4.35.1

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/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "core/1"]
2
+ path = core/1
3
+ url = git@bitbucket.org:fishawackdigital/lab-env-core-1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  ## Changelog
2
2
 
3
+ ### 4.35.1 (2024-10-02)
4
+
5
+ #### Build Updates
6
+
7
+ * added setup script that inits submodules ([cdb1415](https://bitbucket.org/fishawackdigital/lab-env/commits/cdb14156ae73ef188d804ce84a5900f74d964e55))
8
+ * Bumped lab-env-core-1 ([9fbdae6](https://bitbucket.org/fishawackdigital/lab-env/commits/9fbdae666f9c70ca82ca891c1027413415b8caac))
9
+ * commit and open pull request against aws-runner on publish" ([174cb20](https://bitbucket.org/fishawackdigital/lab-env/commits/174cb2031dac53121e11c237cd3ddf54d93b6744))
10
+ * escape quote in include check ([658f4ba](https://bitbucket.org/fishawackdigital/lab-env/commits/658f4ba6dadd217ce07486f1165a2a312892f7df))
11
+ * exit early if semantic release doesnt publish anything ([99c7b9f](https://bitbucket.org/fishawackdigital/lab-env/commits/99c7b9fb13b55713fb4f522e08d98c778376fc9b))
12
+ * installed core/1 as a submodule ([f40ad71](https://bitbucket.org/fishawackdigital/lab-env/commits/f40ad711acab83c29b30c3817c0731a956f44abb))
13
+ * publish on more commit types ([4b8ac27](https://bitbucket.org/fishawackdigital/lab-env/commits/4b8ac2725d1a218c516682ec727ce869ddde1237))
14
+ * remove core/1 from repo ([35e96ce](https://bitbucket.org/fishawackdigital/lab-env/commits/35e96ce7ea4723cdf5b144ce28f219b0ce4ca040))
15
+ * use setup script instead of ci directly ([4e2464c](https://bitbucket.org/fishawackdigital/lab-env/commits/4e2464c6d0fd545a2fe4d91821ff56715a6816d6))
16
+
17
+ ### 4.35.0 (2024-09-26)
18
+
19
+ #### Features
20
+
21
+ * added new mtpa client ([dce9679](https://bitbucket.org/fishawackdigital/lab-env/commits/dce96797ebdfd722b8094bca01d38866fd762a54))
22
+ * re-provisioned static sites now ensure all cloudfront functions are set ([5ac017b](https://bitbucket.org/fishawackdigital/lab-env/commits/5ac017bb727bb80cffe545973fd6ffb61d17217b))
23
+ * support provisioning adonis envs ([4d73174](https://bitbucket.org/fishawackdigital/lab-env/commits/4d731746ea6227c0241eb32d1c9002734800d31e))
24
+
25
+ #### Bug Fixes
26
+
27
+ * **adonis:** added port and log level to adonis provision command ([b5940b8](https://bitbucket.org/fishawackdigital/lab-env/commits/b5940b844b801cb9c7f2684b61bb6ba684237860))
28
+ * dont create FW_DIR directories as they already exist in the image ([aa3c646](https://bitbucket.org/fishawackdigital/lab-env/commits/aa3c646014ca31f14c99138963e8922a47b19ac7))
29
+ * egnyte check now correctly returns fail or pass result ([8e232ed](https://bitbucket.org/fishawackdigital/lab-env/commits/8e232edd658080ed83e5bb4699518fe741fd91be))
30
+ * enforce lowercase repo names and start and end with digit or letter ([03c473e](https://bitbucket.org/fishawackdigital/lab-env/commits/03c473e1d569bce1792ef98ab23d68e84ba18c5f))
31
+ * remove response cloudfront function on deprov ([8343740](https://bitbucket.org/fishawackdigital/lab-env/commits/83437405b7d7cb98f78ecbad8ea52becf0128cab))
32
+ * set custom error response on re-provision command ([c162e4a](https://bitbucket.org/fishawackdigital/lab-env/commits/c162e4a016ced36586eb828cea6be1d5ede925fa))
33
+ * set FW_DIR to aws runner home and test mail ([b085d9e](https://bitbucket.org/fishawackdigital/lab-env/commits/b085d9ee2a474095131b182134358b3180e03818))
34
+ * static sites now attach response function with security headers ([28e192d](https://bitbucket.org/fishawackdigital/lab-env/commits/28e192d6fbc5ccf64560b1be15aa5e2b527ba345))
35
+ * use consistent bitbucket pipeline as standard projects ([8b19b1c](https://bitbucket.org/fishawackdigital/lab-env/commits/8b19b1cf224b1ae7606f1d43b1ca4a17f9c88ebf))
36
+ * use slug and nameSafe to response cloudfront response ([28e30eb](https://bitbucket.org/fishawackdigital/lab-env/commits/28e30ebb35df8bbd96300f090f4deeffce5d13a0))
37
+
3
38
  ### 4.34.0 (2024-08-21)
4
39
  * [Feature] enable pipelines by default when running new command
5
40
  * [Bug] limit elasticsearch memory size so it doesnt attempt to take up all the space
@@ -644,4 +679,4 @@
644
679
  * [Docs] Added readme and changelog to repo
645
680
 
646
681
  ### 0.0.1 (2021-01-11)
647
- * [Misc] Initial release
682
+ * [Misc] Initial release
@@ -0,0 +1,97 @@
1
+ definitions:
2
+ services:
3
+ docker:
4
+ image: docker:dind
5
+ memory: 12288
6
+
7
+ pipelines:
8
+ default:
9
+ - step:
10
+ image: fishawack/aws-runner
11
+ runs-on:
12
+ - self.hosted
13
+ - linux
14
+ - production
15
+ size: 4x
16
+ script:
17
+ # Set global repository CI flags
18
+ - export BRANCH=$BITBUCKET_BRANCH REPO=$BITBUCKET_REPO_SLUG
19
+ # Set FW DIR to project repo as that's the only location that's mountable
20
+ - export FW_DIR=/home/aws-runner
21
+ # Fetch secure AWS credentials from workspace variables
22
+ - echo $AWS_CREDENTIALS | base64 -d > $FW_DIR/.aws/credentials
23
+ # Fetch secure Egnyte credentials from workspace variables
24
+ - echo $EGNYTE_CREDENTIALS | base64 -d > $FW_DIR/targets/ftp-fishawack.egnyte.com.json
25
+ # Fetch secure Mail credentials from workspace variables
26
+ - jq --argjson JSON "$(echo $MAIL_CREDENTIALS | base64 -d)" '. += $JSON' $FW_DIR/targets/misc.json > $FW_DIR/targets/_misc.json
27
+ # Copy new merged misc to final location
28
+ - cp $FW_DIR/targets/_misc.json $FW_DIR/targets/misc.json
29
+ # Enable FULL docker images
30
+ - export FW_FULL=1
31
+ # Own the git dir as aws-runner so that a non-root user id can be mapped to each container
32
+ - chown -R aws-runner:aws-runner . /build
33
+ # Write ssh config to aws-runner so any bitbucket pipeline keys can be used by the user
34
+ - cat ~/.ssh/config >> $FW_DIR/.ssh/config
35
+ # Copy ssh dir to project dir so lab-env has access to keys
36
+ - su aws-runner -c 'cp /build/*/ssh/* $FW_DIR/.ssh/'
37
+ # Start ssh agent and add all (if any) keys
38
+ - eval `ssh-agent` && ssh-add || true
39
+ # Own the .tmp folder as aws-runner so that a non-root user id can be mapped to each container
40
+ - chown -R aws-runner:aws-runner /tmp
41
+ # Install
42
+ - su aws-runner -c 'npm run setup'
43
+ # Test
44
+ - su aws-runner -c 'npm test'
45
+ services:
46
+ - docker
47
+ branches:
48
+ master:
49
+ - step:
50
+ image: fishawack/aws-runner
51
+ runs-on:
52
+ - self.hosted
53
+ - linux
54
+ - production
55
+ size: 4x
56
+ script:
57
+ # Install release deps
58
+ - npm install -g semantic-release@24 @semantic-release/changelog@6 @semantic-release/git@10 conventional-changelog-conventionalcommits@8
59
+ # Release version via node so can exit out when no release made
60
+ - |
61
+ node -e "const spawn = require('child_process').spawn('semantic-release', ['--repositoryUrl', 'https://$GIT_CREDENTIALS@bitbucket.org/$BITBUCKET_REPO_FULL_NAME'], { env: { ...process.env, FORCE_COLOR: true } }); spawn.stderr.on('data', d => process.stderr.write(d.toString())); spawn.stdout.on('data', d => {process.stdout.write(d.toString()); if(d.toString().includes('There are no relevant changes, so no new version is released.') || d.toString().includes('therefore a new version won\'t be published.')){process.exit(1);}})" || exit 0
62
+ # Sync development after publish
63
+ - git fetch origin "+refs/heads/*:refs/remotes/origin/*" && git checkout -b development origin/development && git merge master && git push origin development
64
+ # Commit and create pull request for new version on aws-runner repo
65
+ - git config --global user.email "digital@fishawack.com"
66
+ - git config --global user.name "Digital Fishawack"
67
+ - git clone https://$GIT_CREDENTIALS@bitbucket.org/fishawackdigital/aws-runner
68
+ - cd aws-runner
69
+ - git checkout -b "$BITBUCKET_REPO_SLUG-$BITBUCKET_COMMIT" origin/development
70
+ - sed -i -e "s/\(@fishawack\/lab-env@\).*/\1$(git ls-remote --tags --refs --sort="v:refname" https://$GIT_CREDENTIALS@bitbucket.org/$BITBUCKET_REPO_FULL_NAME | tail -n1 | sed 's/.*\///')/g" Dockerfile
71
+ - git add .
72
+ - |
73
+ git commit --allow-empty -m "build: Bumped $BITBUCKET_REPO_SLUG"
74
+ - git push origin "$BITBUCKET_REPO_SLUG-$BITBUCKET_COMMIT"
75
+ - |
76
+ curl https://api.bitbucket.org/2.0/repositories/fishawackdigital/aws-runner/pullrequests \
77
+ -u $GIT_CREDENTIALS \
78
+ --header 'Content-Type: application/json' \
79
+ --data "{
80
+ \"title\": \"Bumped $BITBUCKET_REPO_SLUG\",
81
+ \"destination\": {
82
+ \"branch\": {
83
+ \"name\": \"development\"
84
+ }
85
+ },
86
+ \"source\": {
87
+ \"branch\": {
88
+ \"name\": \"$BITBUCKET_REPO_SLUG-$BITBUCKET_COMMIT\"
89
+ }
90
+ },
91
+ \"reviewers\": [
92
+ {
93
+ \"uuid\": \"{2518e4c3-fc1d-4653-b355-c00be099ce6c}\"
94
+ }
95
+ ],
96
+ \"close_source_branch\": true
97
+ }"
@@ -35,7 +35,7 @@ module.exports = [
35
35
  name = `${template.prefix}-${name}`;
36
36
  }
37
37
 
38
- if(/^[a-zA-Z0-9-_.]+$/.test(name)){
38
+ if(/^[a-z0-9][a-z0-9-_.]+[a-z0-9]$/.test(name)){
39
39
  // Create Remote Repositories
40
40
  if(!await bitbucket.exists(name)){
41
41
  if(await bitbucket.exists(template.name)){
@@ -49,7 +49,7 @@ module.exports = [
49
49
  }
50
50
  }
51
51
  } else {
52
- console.log(utilities.colorize(`Repo name can contain only letters, digits, '_', '-' and '.'`, 'helper'));
52
+ console.log(utilities.colorize(`Repo names must contain only lowercase letters, decimal digits, dashes, and underscores, and must begin & end with a lowercase letter or decimal digit.`, 'helper'));
53
53
  }
54
54
  }
55
55
  ];
@@ -263,6 +263,36 @@ module.exports.eb = {
263
263
  { OptionName: 'SESSION_SECURE_COOKIE', Value: "true", Namespace: 'aws:elasticbeanstalk:application:environment' },
264
264
  ]
265
265
  },
266
+ adonis: {
267
+ shared: [
268
+ {
269
+ OptionName: 'NODE_ENV',
270
+ Value: 'production',
271
+ Namespace: 'aws:elasticbeanstalk:application:environment'
272
+ },
273
+ {
274
+ OptionName: 'APP_KEY',
275
+ Value: `base64:${Buffer.from(generator.generate({ length: 32, numbers: true, symbols: true })).toString('base64')}`,
276
+ Namespace: 'aws:elasticbeanstalk:application:environment'
277
+ },
278
+ {
279
+ OptionName: 'APP_URL',
280
+ Value: 'https://<%= DOMAIN_LINK %>',
281
+ Namespace: 'aws:elasticbeanstalk:application:environment'
282
+ },
283
+ { OptionName: 'SESSION_DRIVER', Value: "cookie", Namespace: 'aws:elasticbeanstalk:application:environment' },
284
+ { OptionName: 'AWS_BUCKET', Value: "<%= s3Slug %>", Namespace: 'aws:elasticbeanstalk:application:environment' },
285
+ { OptionName: 'AWS_DEFAULT_REGION', Value: "<%= AWS_REGION %>", Namespace: 'aws:elasticbeanstalk:application:environment' },
286
+ { OptionName: 'AWS_ACCESS_KEY_ID', Value: "<%= AccessKeyId %>", Namespace: 'aws:elasticbeanstalk:application:environment' },
287
+ { OptionName: 'AWS_SECRET_ACCESS_KEY', Value: "<%= SecretAccessKey %>", Namespace: 'aws:elasticbeanstalk:application:environment' },
288
+ { OptionName: 'FILESYSTEM_DISK', Value: "s3", Namespace: 'aws:elasticbeanstalk:application:environment' },
289
+ { OptionName: 'FILESYSTEM_DISK_PUBLIC', Value: "s3-public", Namespace: 'aws:elasticbeanstalk:application:environment' },
290
+ { OptionName: 'PORT', Value: "3333", Namespace: 'aws:elasticbeanstalk:application:environment' },
291
+ { OptionName: 'LOG_LEVEL', Value: "info", Namespace: 'aws:elasticbeanstalk:application:environment' },
292
+ ],
293
+ low: [],
294
+ high: []
295
+ },
266
296
  drupal: {
267
297
  shared: [],
268
298
  low: [],
@@ -428,6 +458,13 @@ module.exports.eb = {
428
458
  low: [],
429
459
  high: [],
430
460
  },
461
+ adonis: {
462
+ platform: "nginx",
463
+ language: "node",
464
+ shared: [],
465
+ low: [],
466
+ high: [],
467
+ },
431
468
  drupal: {
432
469
  platform: "httpd",
433
470
  language: "php",
@@ -461,4 +498,54 @@ module.exports.eb = {
461
498
  config(){
462
499
  return template(fs.readFileSync(`${__dirname}/../templates/elasticbeanstalk/.elasticbeanstalk/config.yml`, {encoding: 'utf8'}))(process.env);
463
500
  }
464
- };
501
+ };
502
+
503
+ // Cloudfront distribution config
504
+ module.exports.cloudfront = (name, region, FunctionARNResponse, FunctionARNRequest, OAI) => ({
505
+ DistributionConfig: {
506
+ Enabled: true,
507
+ CallerReference: name,
508
+ Comment: `lab-env provisioned CloudFront distribution for project ${name}`,
509
+ CustomErrorResponses: {
510
+ Items: [
511
+ {
512
+ ErrorCachingMinTTL: 0,
513
+ ErrorCode: 404,
514
+ ResponseCode: 200,
515
+ ResponsePagePath: '/index.html'
516
+ }
517
+ ],
518
+ Quantity: 1
519
+ },
520
+ DefaultCacheBehavior: {
521
+ Compress: true,
522
+ TargetOriginId: `${name}.s3.${region}.amazonaws.com`,
523
+ ViewerProtocolPolicy: 'redirect-to-https',
524
+ CachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6', // Built in, Managed AWS Policy - Cache Optimized
525
+ FunctionAssociations: {
526
+ Items: [
527
+ {
528
+ EventType: 'viewer-response',
529
+ FunctionARN: FunctionARNResponse
530
+ }
531
+ ].concat(FunctionARNRequest ? {
532
+ EventType: 'viewer-request',
533
+ FunctionARN: FunctionARNRequest
534
+ } : []),
535
+ Quantity: 2
536
+ }
537
+ },
538
+ Origins: {
539
+ Items: [
540
+ {
541
+ DomainName: `${name}.s3.${region}.amazonaws.com`,
542
+ Id: `${name}.s3.${region}.amazonaws.com`,
543
+ S3OriginConfig: {
544
+ OriginAccessIdentity: `origin-access-identity/cloudfront/${OAI.CloudFrontOriginAccessIdentity.Id}`
545
+ }
546
+ }
547
+ ],
548
+ Quantity: 1
549
+ }
550
+ },
551
+ });
@@ -1,9 +1,11 @@
1
1
  const { CloudFrontClient, CreateDistributionWithTagsCommand, CreateCloudFrontOriginAccessIdentityCommand, DeleteDistributionCommand , DeleteCloudFrontOriginAccessIdentityCommand, GetDistributionCommand, UpdateDistributionCommand, GetCloudFrontOriginAccessIdentityCommand, CreateFunctionCommand, GetFunctionCommand, UpdateFunctionCommand, PublishFunctionCommand, DeleteFunctionCommand, DescribeFunctionCommand } = require("@aws-sdk/client-cloudfront");
2
2
  const fs = require('fs');
3
+ const { merge } = require('lodash');
3
4
  const { Spinner, poll } = require('../../libs/utilities');
5
+ const { cloudfront } = require('../../libs/vars');
4
6
  const { createClient } = require('./misc.js');
5
7
 
6
- module.exports.createCloudFrontDistribution = async (name, account, tags = [], FunctionARN = null, region = 'us-east-1') => {
8
+ module.exports.createCloudFrontDistribution = async (name, account, tags = [], FunctionARNRequest = null, FunctionARNResponse = null, region = 'us-east-1') => {
7
9
  const client = createClient(CloudFrontClient, account, region);
8
10
 
9
11
  let OAI = await Spinner.prototype.simple(`Creating CloudFront OAI`, () => {
@@ -24,49 +26,7 @@ module.exports.createCloudFrontDistribution = async (name, account, tags = [], F
24
26
  return client.send(
25
27
  new CreateDistributionWithTagsCommand({
26
28
  DistributionConfigWithTags: {
27
- DistributionConfig: {
28
- Enabled: true,
29
- CallerReference: name,
30
- Comment: `lab-env provisioned CloudFront distribution for project ${name}`,
31
- CustomErrorResponses: {
32
- Items: [
33
- {
34
- ErrorCachingMinTTL: 0,
35
- ErrorCode: 404,
36
- ResponseCode: 200,
37
- ResponsePagePath: '/index.html'
38
- }
39
- ],
40
- Quantity: 1
41
- },
42
- DefaultCacheBehavior: {
43
- Compress: true,
44
- TargetOriginId: `${name}.s3.${region}.amazonaws.com`,
45
- ViewerProtocolPolicy: 'redirect-to-https',
46
- CachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6', // Built in, Managed AWS Policy - Cache Optimized
47
- FunctionAssociations: FunctionARN && {
48
- Items: [
49
- {
50
- EventType: 'viewer-request',
51
- FunctionARN
52
- }
53
- ],
54
- Quantity: 1
55
- }
56
- },
57
- Origins: {
58
- Items: [
59
- {
60
- DomainName: `${name}.s3.${region}.amazonaws.com`,
61
- Id: `${name}.s3.${region}.amazonaws.com`,
62
- S3OriginConfig: {
63
- OriginAccessIdentity: `origin-access-identity/cloudfront/${OAI.CloudFrontOriginAccessIdentity.Id}`
64
- }
65
- }
66
- ],
67
- Quantity: 1
68
- }
69
- },
29
+ ...cloudfront(name, region, FunctionARNResponse, FunctionARNRequest, OAI),
70
30
  Tags: {
71
31
  Items: [{Key: 'client', Value: account}].concat(tags)
72
32
  }
@@ -86,6 +46,18 @@ module.exports.createCloudFrontDistribution = async (name, account, tags = [], F
86
46
  new GetDistributionCommand({ Id })
87
47
  );
88
48
  });
49
+
50
+ res = await Spinner.prototype.simple(`Ensuring CloudFront functions are applied to CloudFront distribution`, () => {
51
+ return client.send(
52
+ new UpdateDistributionCommand({
53
+ ...merge(
54
+ res.Distribution,
55
+ cloudfront(name, region, FunctionARNResponse, FunctionARNRequest, OAI)
56
+ ),
57
+ IfMatch: res.ETag
58
+ })
59
+ );
60
+ });
89
61
  }
90
62
 
91
63
  return res;
@@ -17,7 +17,7 @@ module.exports.createElasticBeanstalkApplication = async (name, account) => {
17
17
  return res;
18
18
  }
19
19
 
20
- module.exports.createElasticBeanstalkEnvironment = async (name, account, ApplicationName, OptionSettings, CNAMEPrefix, tags = []) => {
20
+ module.exports.createElasticBeanstalkEnvironment = async (name, account, {language}, ApplicationName, OptionSettings, CNAMEPrefix, tags = []) => {
21
21
  const client = createClient(ElasticBeanstalkClient, account);
22
22
 
23
23
  const solutions = await Spinner.prototype.simple(`Retrieving available solution stacks`, () => {
@@ -31,7 +31,9 @@ module.exports.createElasticBeanstalkEnvironment = async (name, account, Applica
31
31
  new CreateEnvironmentCommand({
32
32
  ApplicationName,
33
33
  EnvironmentName: name,
34
- SolutionStackName: solutions.SolutionStacks.filter(d => d.includes('PHP 8.1') && d.includes('Amazon Linux 2 '))[0],
34
+ SolutionStackName: solutions.SolutionStacks.filter(d => {
35
+ return language === "node" ? d.includes('Node.js 20') : d.includes('PHP 8.1') && d.includes('Amazon Linux 2 ')
36
+ })[0],
35
37
  OptionSettings,
36
38
  CNAMEPrefix,
37
39
  Tags: [{Key: 'client', Value: account}].concat(tags)
@@ -12,14 +12,30 @@ module.exports.ec2 = require("./ec2.js");
12
12
 
13
13
  module.exports.slug = (repo, client, branch, service = "s3") => nameSafe(`${branch}-${repo}-${client}`, service);
14
14
 
15
- 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', 'relievantmedsystems', 'gilead', 'alexion', 'insulet', 'danone'];
15
+ 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', 'relievantmedsystems', 'gilead', 'alexion', 'insulet', 'danone', 'mtpa'];
16
16
 
17
- module.exports.static = async (name, account, tags = [], credentials = []) => {
17
+ module.exports.static = async (name, account, tags = [], credentials = [], repo, branch) => {
18
18
  let s3 = await module.exports.s3.createS3Bucket(name, account, tags);
19
19
 
20
- let cloudfrontFunction = await module.exports.cloudfront.createCloudFrontFunction(name, account, credentials.length ? 'aws-cloudfront-auth' : 'aws-cloudfront-simple', {credentials: credentials.map(d => `Basic ${Buffer.from(`${d.username}:${d.password}`).toString('base64')}`)});
21
-
22
- let cloudfront = await module.exports.cloudfront.createCloudFrontDistribution(name, account, tags, cloudfrontFunction.FunctionSummary.FunctionMetadata.FunctionARN);
20
+ let cloudfront = await module.exports.cloudfront.createCloudFrontDistribution(
21
+ name,
22
+ account,
23
+ tags,
24
+ (await module.exports.cloudfront.createCloudFrontFunction(
25
+ name,
26
+ account,
27
+ credentials.length ? 'aws-cloudfront-auth' : 'aws-cloudfront-simple',
28
+ {
29
+ credentials: credentials.map(d => `Basic ${Buffer.from(`${d.username}:${d.password}`).toString('base64')}`)
30
+ }
31
+ )).FunctionSummary.FunctionMetadata.FunctionARN,
32
+ (await module.exports.cloudfront.createCloudFrontFunction(
33
+ module.exports.slug(`${repo}-response`, account, branch),
34
+ account,
35
+ 'aws-cloudfront-response',
36
+ {}
37
+ )).FunctionSummary.FunctionMetadata.FunctionARN
38
+ );
23
39
 
24
40
  await module.exports.s3.setS3BucketPolicy(name, account, cloudfront.Distribution.DistributionConfig.Origins.Items[0].S3OriginConfig.OriginAccessIdentity.split('origin-access-identity/cloudfront/')[1]);
25
41
 
@@ -40,6 +56,8 @@ module.exports.staticTerminate = async (name, account, repo, branch, id) => {
40
56
  try { await module.exports.cloudfront.removeCloudFrontDistribution(id, account); } catch(e) {}
41
57
 
42
58
  try { await module.exports.cloudfront.removeCloudFrontFunction(name, account); } catch(e) {}
59
+
60
+ try { await module.exports.cloudfront.removeCloudFrontFunction(module.exports.slug(`${repo}-response`, account, branch), account); } catch(e) {}
43
61
  }
44
62
 
45
63
  module.exports.fullstack = async (name, account, tags = [], credentials = [], repo, branch, framework, availability) => {
@@ -75,7 +93,7 @@ module.exports.fullstack = async (name, account, tags = [], credentials = [], re
75
93
  });
76
94
  }
77
95
 
78
- const environment = await module.exports.elasticbeanstalk.createElasticBeanstalkEnvironment(name, account, repo, OptionSettings, CNAMEPrefix, tags);
96
+ const environment = await module.exports.elasticbeanstalk.createElasticBeanstalkEnvironment(name, account, {framework, availability, platform, language}, repo, OptionSettings, CNAMEPrefix, tags);
79
97
 
80
98
  const configurations = eb.merge("configurations", {framework, availability, platform, language});
81
99
 
@@ -3,14 +3,8 @@ const { ftppass, creds } = require('../libs/vars');
3
3
  const { exec } = require("child_process");
4
4
 
5
5
  module.exports.check = async () => {
6
- try {
7
- await module.exports.request(creds.egnyte.username, creds.egnyte.password, creds.egnyte.host);
6
+ return await module.exports.request(creds.egnyte.username, creds.egnyte.password, creds.egnyte.host) &&
8
7
  await module.exports.request(ftppass['ftp-fishawack.egnyte.com'].username, ftppass['ftp-fishawack.egnyte.com'].password, 'ftp-fishawack.egnyte.com');
9
-
10
- return true;
11
- } catch(error) {
12
- return false;
13
- }
14
8
  };
15
9
 
16
10
  module.exports.request = async (username, password, host) => {
@@ -0,0 +1,6 @@
1
+ container_commands:
2
+ 10-db-import:
3
+ command: echo 'leader only'
4
+ leader_only: true
5
+ 20-clear-cache:
6
+ command: ls
@@ -0,0 +1,5 @@
1
+ option_settings:
2
+ aws:elasticbeanstalk:application:environment
3
+ PORT: 5000
4
+ aws:elasticbeanstalk:environment:proxy:
5
+ ProxyServer: nginx
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "4.34.0",
3
+ "version": "4.35.1",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
7
- "test": "rm -rf _Test/_fixtures/boilerplate*; CI_BUILD_ID=true mocha _Test/*.js --timeout 12000s --bail",
8
- "preversion": "npm test",
9
- "postversion": "git push && git push --tags && npm publish",
10
- "postpublish": "git checkout development && git merge master && git push"
7
+ "setup": "npm ci && git submodule init && git submodule update",
8
+ "test": "rm -rf _Test/_fixtures/boilerplate*; CI_BUILD_ID=true mocha _Test/*.js --timeout 12000s --bail"
11
9
  },
12
10
  "repository": {
13
11
  "type": "git",
@@ -51,5 +49,88 @@
51
49
  "engines": {
52
50
  "npm": ">=8",
53
51
  "node": ">=18"
52
+ },
53
+ "release": {
54
+ "plugins": [
55
+ [
56
+ "@semantic-release/commit-analyzer",
57
+ {
58
+ "preset": "conventionalcommits",
59
+ "releaseRules": [
60
+ {
61
+ "type": "build",
62
+ "release": "patch"
63
+ },
64
+ {
65
+ "type": "perf",
66
+ "release": "patch"
67
+ },
68
+ {
69
+ "type": "ci",
70
+ "release": "patch"
71
+ },
72
+ {
73
+ "type": "refactor",
74
+ "release": "patch"
75
+ },
76
+ {
77
+ "type": "style",
78
+ "release": "patch"
79
+ }
80
+ ]
81
+ }
82
+ ],
83
+ [
84
+ "@semantic-release/release-notes-generator",
85
+ {
86
+ "preset": "conventionalcommits",
87
+ "writerOpts": {
88
+ "headerPartial": "### {{version}} ({{date}})\n",
89
+ "mainTemplate": "{{> header}}\n{{#each commitGroups}}\n\n{{#if title}}\n#### {{title}}\n\n{{/if}}\n{{#each commits}}\n{{> commit root=@root}}\n{{/each}}\n{{/each}}"
90
+ },
91
+ "presetConfig": {
92
+ "commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commits/{{hash}}",
93
+ "types": [
94
+ {
95
+ "type": "feat",
96
+ "section": "Features"
97
+ },
98
+ {
99
+ "type": "fix",
100
+ "section": "Bug Fixes"
101
+ },
102
+ {
103
+ "type": "build",
104
+ "section": "Build Updates"
105
+ },
106
+ {
107
+ "type": "perf",
108
+ "section": "Performance Improvements"
109
+ },
110
+ {
111
+ "type": "ci",
112
+ "section": "CI/CD updates"
113
+ },
114
+ {
115
+ "type": "refactor",
116
+ "section": "Code Refactors"
117
+ },
118
+ {
119
+ "type": "style",
120
+ "section": "Style Updates"
121
+ }
122
+ ]
123
+ }
124
+ }
125
+ ],
126
+ [
127
+ "@semantic-release/changelog",
128
+ {
129
+ "changelogTitle": "## Changelog"
130
+ }
131
+ ],
132
+ "@semantic-release/npm",
133
+ "@semantic-release/git"
134
+ ]
54
135
  }
55
136
  }
package/.gitlab-ci.yml DELETED
@@ -1,26 +0,0 @@
1
- stages:
2
- - test
3
-
4
- test:
5
- stage: test
6
- resource_group: test
7
- coverage: '/Code coverage: \d+\.\d+/'
8
- variables:
9
- FW_FULL: 1
10
- before_script:
11
- # Remove all projects currently on runner
12
- - find "/home/gitlab-runner/builds/" ! \( -type d \) -not -path "/*/0/${CI_PROJECT_PATH}/*" -not -path "/*/0/${CI_PROJECT_PATH}.tmp/*" -exec rm -rf {} +
13
- # Remove all empty files now the folders are cleaned out
14
- - find "/home/gitlab-runner/builds/" -type d -empty -delete
15
- script:
16
- # Install
17
- - npm ci
18
- # # Test
19
- - npm test
20
- after_script:
21
- # Clean docker
22
- - docker volume rm $(docker volume ls -q) || true
23
- artifacts:
24
- expire_in: 2 hrs
25
- paths:
26
- - coverage/
@@ -1,52 +0,0 @@
1
- ## Changelog
2
-
3
- ### 1.4.1 (2024-07-17)
4
- * [fix] set global var for git across file system so git avail in mounted volumes i.e node_modules
5
-
6
- ### 1.4.0 (2024-06-04)
7
- * [feat] bumped node from 18 to 20
8
-
9
- ### 1.3.3 (2024-02-09)
10
- * [fix] symlink wine64 now htat wine is the default global command but electron expects wine64
11
-
12
- ### 1.3.2 (2024-01-24)
13
- * [fix] install latest eb cli and use node images python rather than pyenv
14
-
15
- ### 1.3.1 (2024-01-22)
16
- * [fix] rebuild of image to get the latest chromium version to fix new puppeteer headless mode
17
-
18
- ### 1.3.0 (2023-03-17)
19
- * [feat] node user is now added to www-data group for easier file permission management
20
- * [fix] disable npm message about update being available
21
-
22
- ### 1.2.2 (2023-02-25)
23
- * [fix] set BRANCH and CI_COMMIT_REF_NAME env variables in container
24
- * [fix] installed git-branch to fetch the current branch for deployment targets
25
- * [refactor] moved global node module symlinking to alpine image for future use
26
-
27
- ### 1.2.1 (2023-02-25)
28
- * [fix] install eb cli into root of image rather than root user directory
29
- * [perf] dont recurse and dont change group of node_modules to speed up command
30
- * [refactor] set node git flag without switching user directly in dockerfile
31
-
32
- ### 1.1.4 (2023-02-23)
33
- * [Fix] Installed missing are-you-es5 global npm module
34
- * [Fix] Installed missing check-dependencies global npm module
35
-
36
- ### 1.1.3 (2023-02-23)
37
- * [Fix] Switch to ENV for $PATH updates to avoid shell profile loading issues
38
- * [Fix] Moved chromium to alpine image as its needed for svg tasks and testing
39
-
40
- ### 1.1.2 (2023-02-22)
41
- * [Fix] cd into $PWD after su command or we'll start in users home directory
42
-
43
- ### 1.1.1 (2023-02-22)
44
- * [Fix] Use -l login flag for su command for both non interactive and interactive shells
45
- * [Fix] Switch $PATH writes to .profile so they are executed on non interactive shells
46
-
47
- ### 1.1.0 (2023-02-22)
48
- * [Feature] Watertight now baked into image so not needed in package.json of projects
49
- * [Fix] lftp installed in alpine image as it's needed for content tasks
50
-
51
- ### 1.0.0 (2023-02-21)
52
- * [Misc] initial commit
package/core/1/Dockerfile DELETED
@@ -1,110 +0,0 @@
1
- #####
2
- # Alpine image
3
- #####
4
-
5
- FROM node:20.6 AS alpine
6
-
7
- LABEL org.opencontainers.image.authors="Mike Mellor <mike.mellor@avalerehealth.com>"
8
-
9
- ARG TARGETARCH
10
-
11
- WORKDIR /app
12
-
13
- EXPOSE 3000
14
- EXPOSE 3001
15
-
16
- # Get latest apt-get
17
- RUN apt-get update
18
-
19
- # Update npm to latest
20
- RUN npm install -g npm@latest
21
-
22
- # Install dart sass vm (arch switch)
23
- RUN curl -L -o /sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.57.1/dart-sass-1.57.1-linux-$(if [ "$TARGETARCH" = "arm64" ]; then echo 'arm64'; else echo 'x64'; fi).tar.gz
24
- RUN tar -xf /sass.tar.gz -C /
25
- ENV PATH="${PATH}:/dart-sass/"
26
- RUN rm -rf /sass.tar.gz
27
-
28
- # Set safe directory to remove intel errors when running git rev-parse
29
- RUN su node -c "git config --global --add safe.directory /app"
30
-
31
- # Also set global git flag for allowing access across filesystems for mounted node_modules dir
32
- ENV GIT_DISCOVERY_ACROSS_FILESYSTEM=1
33
-
34
- # Disable npm message about updates being available
35
- RUN su node -c "npm config set update-notifier false"
36
-
37
- # Add node user to www-data group
38
- RUN usermod -a -G www-data node
39
-
40
- # Install lftp
41
- RUN apt-get install -y lftp
42
-
43
- # Install chromium
44
- RUN apt-get install -y chromium fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends
45
- # Stop Puppeteer downloading browsers during npm install
46
- ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
47
- ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
48
-
49
- # Install package.json checker
50
- RUN npm install check-dependencies -g
51
-
52
- # Install node_modules checker
53
- RUN npm install are-you-es5 -g
54
-
55
- # Install git branch fetcher
56
- RUN npm install git-branch -g
57
-
58
- # Link root global node_modules to ~/.node_modules
59
- RUN ln -s /usr/local/lib/node_modules/ /home/node/.node_modules
60
-
61
- # Cleanup apt-get install folders
62
- RUN apt-get clean && \
63
- rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
64
-
65
- COPY entrypoint.sh /bin/entrypoint.sh
66
- RUN chmod +x /bin/entrypoint.sh
67
- ENTRYPOINT ["/bin/entrypoint.sh"]
68
-
69
- #####
70
- # Full image
71
- #####
72
-
73
- FROM alpine AS full
74
-
75
- # Get latest apt-get
76
- RUN apt-get update
77
-
78
- # Install ghostscript
79
- RUN apt-get install -y ghostscript
80
-
81
- # Install zip
82
- RUN apt-get install zip
83
-
84
- # Install AWS Elastic Beanstalk cli
85
- ENV PATH="${PATH}:/.ebcli-virtual-env/executables"
86
- RUN apt-get -y install python-is-python3 python3-pip && \
87
- pip install virtualenv --break-system-packages && \
88
- git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git ~/aws-eb && \
89
- python ~/aws-eb/scripts/ebcli_installer.py --location / && \
90
- rm -rf ~/aws-eb
91
-
92
- # Install AWS-CLI@2 (arch switch)
93
- RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-$(if [ "$TARGETARCH" = "arm64" ]; then echo 'aarch64'; else echo 'x86_64'; fi).zip" -o "awscliv2.zip"
94
- RUN unzip awscliv2.zip
95
- RUN ./aws/install
96
- RUN rm -rf ./aws && rm -rf awscliv2.zip
97
-
98
- # Update electron globally
99
- RUN npm install -g electron-packager@latest
100
-
101
- # Install wine64
102
- RUN apt-get install -y wine64 && \
103
- ln -s /usr/bin/wine /usr/bin/wine64
104
-
105
- # Install watertight
106
- RUN --mount=type=ssh npm install -g git+ssh://git@bitbucket.org/fishawackdigital/watertight-node-auto.git#v6.0.0
107
-
108
- # Cleanup apt-get install folders
109
- RUN apt-get clean && \
110
- rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -1,36 +0,0 @@
1
- services:
2
- core:
3
- build:
4
- context: $FW_CORE_1_CONTEXT
5
- target: $FW_CORE_1_TARGET
6
- ssh:
7
- - default
8
- args:
9
- target: $FW_CORE_1_TARGET
10
- target_image: $FW_CORE_1_TARGET_IMAGE
11
- image: $FW_CORE_1_IMAGE:${FW_CORE_1_VERSION:-latest}
12
- init: true
13
- tty: true
14
- volumes:
15
- - $CWD/:/app
16
- - $FW_DIR/targets:/home/node/targets
17
- - $FW_DIR/.ssh:/home/node/.ssh
18
- - $FW_DIR/.aws:/home/node/.aws
19
- - node_modules:/app/node_modules
20
- ports:
21
- - ${PORT:-3000}:${PORT:-3000}
22
- - ${PORT_OPT:-3001}:${PORT_OPT:-3001}
23
- environment:
24
- - REPO=${REPO:-}
25
- - PORT=${PORT:-3000}
26
- - PORT_OPT=${PORT_OPT:-3001}
27
- - PORT_WEB=${PORT_WEB:-8000}
28
- - PORT_DB=${PORT_DB:-3306}
29
- - USER_UID=${USER_UID:-0}
30
- - USER_GID=${USER_GID:-0}
31
- - FW_ROOT=${FW_ROOT:-}
32
- - BRANCH=${BRANCH:-}
33
- - CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME:-}
34
- volumes:
35
- node_modules:
36
- driver: "local"
@@ -1,21 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Setting $FW_ROOT will bypass the user switch to node
4
- if [ -z "$FW_ROOT" ]; then
5
- # Set node user id to match host users id so no permission issues outside of docker
6
- usermod -u $USER_UID node &>/dev/null
7
-
8
- # Own the node_modules folder otherwise it'll be owned by root/previous node id which will prevent writing
9
- chown node /app/node_modules
10
-
11
- # Default arguments will always be bash -l, if nothing follows this just start an non login interactive shell
12
- if [ -z "${@:3}" ]; then
13
- exec su node
14
- # Otherwise pipe the command after the bash -lc into the non login non interactive shell as a command to exec
15
- else
16
- exec su node -c "${@:3}"
17
- fi
18
- else
19
- echo "Accessing as root"
20
- exec "$@"
21
- fi
@@ -1,11 +0,0 @@
1
- {
2
- "name": "core",
3
- "version": "1.4.1",
4
- "description": "lab-env docker config for the @fishawack/core/1 npm module",
5
- "scripts": {
6
- "preversion": "docker login",
7
- "postversion": "docker buildx build --ssh default --platform linux/amd64,linux/arm64 -t fishawack/lab-env-core-1:$npm_package_version -t fishawack/lab-env-core-1:latest --push . && docker buildx build --ssh default --target alpine --platform linux/amd64,linux/arm64 -t fishawack/lab-env-core-1-alpine:$npm_package_version -t fishawack/lab-env-core-1-alpine:latest --push . && git add . && git commit -m \"build: Bumped fishawack/lab-env-core-1 to $npm_package_version\""
8
- },
9
- "author": "Mike Mellor",
10
- "license": "ISC"
11
- }