Skip to content

Commit

Permalink
Add arm64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
hansottowirtz committed Jul 25, 2022
1 parent b8bffc5 commit d51216a
Show file tree
Hide file tree
Showing 6 changed files with 2,224 additions and 19 deletions.
49 changes: 39 additions & 10 deletions .github/workflows/docker-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,38 @@ jobs:
release_exists="true"
git show-ref --tags --quiet --verify -- "refs/tags/$sharp_version" || release_exists="false"
echo "::set-output name=release_exists::$release_exists"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: amazon-linux-sharp-layer:dev
- name: Copy artifacts
run: docker run -v "${{ github.workspace }}/dist":/dist amazon-linux-sharp-layer:dev
- name: Upload artifacts
# this action should be replaced with load: true in the docker_build action, see https://github.com/docker/buildx/issues/59
- name: Load Docker images
run: |
docker buildx build --load --platform linux/amd64 -t amazon-linux-sharp-layer:dev-x86_64 . &&
docker buildx build --load --platform linux/arm64 -t amazon-linux-sharp-layer:dev-aarch64 .
- name: Copy artifacts x86_64
run: docker run --platform linux/amd64 -v "${{ github.workspace }}/dist":/dist amazon-linux-sharp-layer:dev-x86_64
- name: Copy artifacts aarch64
run: docker run --platform linux/arm64 -v "${{ github.workspace }}/dist":/dist amazon-linux-sharp-layer:dev-aarch64
- name: Upload artifacts x86_64
uses: actions/upload-artifact@v2
with:
name: sharp-lambda-layer.zip
path: dist/sharp-layer.zip
name: sharp-lambda-layer.x86_64.zip
path: dist/sharp-layer.x86_64.zip
if-no-files-found: error
- name: Upload artifacts aarch64
uses: actions/upload-artifact@v2
with:
name: sharp-lambda-layer.aarch64.zip
path: dist/sharp-layer.aarch64.zip
if-no-files-found: error
- name: Create release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.vars.outputs.release_exists == 'false' }}
Expand All @@ -58,14 +76,25 @@ jobs:
tag_name: ${{ steps.vars.outputs.sharp_version }}
release_name: Version ${{ steps.vars.outputs.sharp_version }}
prerelease: ${{ contains(steps.vars.outputs.sharp_version, '-') }}
- name: Upload release asset
- name: Upload release asset x86_64
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.vars.outputs.release_exists == 'false' }}
id: upload_release_asset_x86_64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/sharp-layer.x86_64.zip
asset_name: sharp-lambda-layer.x86_64.zip
asset_content_type: application/zip
- name: Upload release asset aarch64
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.vars.outputs.release_exists == 'false' }}
id: upload_release_asset
id: upload_release_asset_aarch64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/sharp-layer.zip
asset_name: sharp-lambda-layer.zip
asset_path: dist/sharp-layer.aarch64.zip
asset_name: sharp-lambda-layer.aarch64.zip
asset_content_type: application/zip
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
FROM lambci/lambda:build-nodejs12.x
FROM amazonlinux:2-with-sources

WORKDIR /build

RUN curl --silent --location https://rpm.nodesource.com/setup_16.x | bash -

RUN yum -y install nodejs

COPY * ./

RUN npm --no-optional --no-audit --progress=false install
Expand All @@ -11,7 +15,7 @@ RUN node ./node_modules/webpack/bin/webpack.js
RUN node -e "console.log(require('sharp'))"

RUN mkdir /dist && \
echo "cp /build/dist/sharp-layer.zip /dist/sharp-layer.zip" > /entrypoint.sh && \
echo "cp /build/dist/sharp-layer.zip /dist/sharp-layer.$(uname -m).zip" > /entrypoint.sh && \
chmod +x /entrypoint.sh

ENTRYPOINT "/entrypoint.sh"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This AWS Lambda layer contains a pre-built [Sharp](https://www.npmjs.com/package

## Download

A pre-built layer zip file is available on the [Releases page](https://github.com/bubblydoo/lambda-layer-sharp/releases), alongside the size of the layer.
A pre-built layer zip file is available on the [Releases page](https://github.com/bubblydoo/lambda-layer-sharp/releases), alongside the size of the layer. Zip files for both x86_64 and arm64 are available.

## Build

Expand Down
Loading

0 comments on commit d51216a

Please sign in to comment.