Skip to content

Commit

Permalink
merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 1, 2021
2 parents a8398d7 + 5ed6183 commit b51f4ad
Show file tree
Hide file tree
Showing 69 changed files with 91 additions and 228 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*

!package.json
!yarn.lock
!tsconfig.json
!lib/package.json
!scripts/*
!lib/*.json
!lib/**/*.ts
11 changes: 11 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ jobs:

- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Cache
uses: actions/cache@v2
with:
path: |
.yarn
**/node_modules
key: e2e-${{ hashFiles('yarn.lock') }}

- name: Install dependencies
run: yarn install --frozen-lockfile --check-files

- name: Download build artifact
uses: actions/download-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
upstream-branch: main
release-branch: release
release-tag: ${{ github.event.inputs.tag }}
exclude: '["lib/*", "test/*", "package.json", "yarn.lock"]'
exclude: '["lib/**/*", "test/**/*", "package.json", "yarn.lock"]'
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 10.0.6 (April 01, 2021)

- Uses Image Optimizer module of [Next.js 10.0.6](https://github.com/vercel/next.js/releases/tag/v10.0.6) ([#3](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/3))
- Bundling of the image optimizer has changed from ncc to nft ([#23](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/23), [#24](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/24))

## 10.0.5 (March 15, 2021)

**Note 1:** From now on we aligning the versioning schema with the releases of Next.js.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module.exports = {
| next\_image\_device\_sizes | Allowed device sizes that should be used for image optimization. | `list(number)` | `null` | no |
| next\_image\_domains | Allowed origin domains that can be used for fetching images. | `list(string)` | `[]` | no |
| next\_image\_image\_sizes | Allowed image sizes that should be used for image optimization. | `list(number)` | `null` | no |
| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"10.0.5"` | no |
| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"10.0.6"` | no |
| source\_bucket\_id | When your static files are deployed to a Bucket (e.g. with Terraform Next.js) the optimizer can pull the source from the bucket rather than over the internet. | `string` | `null` | no |
| tags | Tag metadata to label AWS resources that support tags. | `map(string)` | `{}` | no |

Expand Down
11 changes: 6 additions & 5 deletions buildimage.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

FROM amazon/aws-sam-cli-emulation-image-nodejs14.x

# Install yarn
RUN npm i -g yarn

WORKDIR /app

ADD tsconfig.json \
lib \
/app/
COPY . .

RUN npm i &&\
npm run build
RUN yarn --frozen-lockfile &&\
yarn build
4 changes: 4 additions & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
dist
dist.zip

# Temporary license files
third-party-licenses.txt
LICENSE
2 changes: 1 addition & 1 deletion scripts/build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ docker build -t "${IMAGE_NAME}" -f buildimage.Dockerfile .
# Copy the artifact back to the host machine
# https://stackoverflow.com/a/31316636/831465
id=$(docker create local/tf-next-image-optiomizer-build sh)
docker cp $id:/app/dist.zip ./lib/dist.zip
docker cp $id:/app/lib/dist.zip ./lib/dist.zip
docker rm -v $id
54 changes: 54 additions & 0 deletions scripts/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Creates a bundled zip file with all dependencies for AWS Lambda
*/

const path = require('path');
const fs = require('fs');
const { nodeFileTrace } = require('@vercel/nft');
const glob = require('glob');
const archiver = require('archiver');

const workspaceRoot = path.resolve(__dirname, '..');
const buildDir = path.resolve(workspaceRoot, 'lib/dist');

async function main() {
// Get all files from build dir
const buildFiles = glob.sync('**/*.js', { cwd: buildDir, absolute: true });

console.log('buildFiles', buildFiles);

const { fileList } = await nodeFileTrace(buildFiles, {
base: workspaceRoot,
processCwd: process.cwd(),
// aws-sdk is already provided in Lambda images
ignore: ['**/aws-sdk/**/*'],
});

// Create zip file
await new Promise((resolve, reject) => {
const outputFile = fs.createWriteStream(
path.resolve(workspaceRoot, 'lib/dist.zip')
);

outputFile.on('close', () => resolve());
outputFile.on('error', (error) => reject(error));

const archive = archiver('zip', {
zlib: { level: 5 }, // Optimal compression
});
archive.pipe(outputFile);

for (const file of fileList) {
// Remove lib/ and lib/dist/ prefix
const fileName = file.replace(/^lib\/(dist\/)?/, '');

archive.append(fs.createReadStream(path.join(workspaceRoot, file)), {
name: fileName,
mode: 0o666,
});
}
archive.finalize();
});
}

main();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit b51f4ad

Please sign in to comment.