Skip to content

Commit d51216a

Browse files
committed
Add arm64 build
1 parent b8bffc5 commit d51216a

File tree

6 files changed

+2224
-19
lines changed

6 files changed

+2224
-19
lines changed

.github/workflows/docker-workflow.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,38 @@ jobs:
3333
release_exists="true"
3434
git show-ref --tags --quiet --verify -- "refs/tags/$sharp_version" || release_exists="false"
3535
echo "::set-output name=release_exists::$release_exists"
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v2
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v2
3640
- name: Build
3741
id: docker_build
38-
uses: docker/build-push-action@v2
42+
uses: docker/build-push-action@v3
3943
with:
4044
context: .
4145
file: ./Dockerfile
46+
platforms: linux/amd64,linux/arm64
4247
tags: amazon-linux-sharp-layer:dev
43-
- name: Copy artifacts
44-
run: docker run -v "${{ github.workspace }}/dist":/dist amazon-linux-sharp-layer:dev
45-
- name: Upload artifacts
48+
# this action should be replaced with load: true in the docker_build action, see https://github.com/docker/buildx/issues/59
49+
- name: Load Docker images
50+
run: |
51+
docker buildx build --load --platform linux/amd64 -t amazon-linux-sharp-layer:dev-x86_64 . &&
52+
docker buildx build --load --platform linux/arm64 -t amazon-linux-sharp-layer:dev-aarch64 .
53+
- name: Copy artifacts x86_64
54+
run: docker run --platform linux/amd64 -v "${{ github.workspace }}/dist":/dist amazon-linux-sharp-layer:dev-x86_64
55+
- name: Copy artifacts aarch64
56+
run: docker run --platform linux/arm64 -v "${{ github.workspace }}/dist":/dist amazon-linux-sharp-layer:dev-aarch64
57+
- name: Upload artifacts x86_64
4658
uses: actions/upload-artifact@v2
4759
with:
48-
name: sharp-lambda-layer.zip
49-
path: dist/sharp-layer.zip
60+
name: sharp-lambda-layer.x86_64.zip
61+
path: dist/sharp-layer.x86_64.zip
62+
if-no-files-found: error
63+
- name: Upload artifacts aarch64
64+
uses: actions/upload-artifact@v2
65+
with:
66+
name: sharp-lambda-layer.aarch64.zip
67+
path: dist/sharp-layer.aarch64.zip
5068
if-no-files-found: error
5169
- name: Create release
5270
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.vars.outputs.release_exists == 'false' }}
@@ -58,14 +76,25 @@ jobs:
5876
tag_name: ${{ steps.vars.outputs.sharp_version }}
5977
release_name: Version ${{ steps.vars.outputs.sharp_version }}
6078
prerelease: ${{ contains(steps.vars.outputs.sharp_version, '-') }}
61-
- name: Upload release asset
79+
- name: Upload release asset x86_64
80+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.vars.outputs.release_exists == 'false' }}
81+
id: upload_release_asset_x86_64
82+
uses: actions/upload-release-asset@v1
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
with:
86+
upload_url: ${{ steps.create_release.outputs.upload_url }}
87+
asset_path: dist/sharp-layer.x86_64.zip
88+
asset_name: sharp-lambda-layer.x86_64.zip
89+
asset_content_type: application/zip
90+
- name: Upload release asset aarch64
6291
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.vars.outputs.release_exists == 'false' }}
63-
id: upload_release_asset
92+
id: upload_release_asset_aarch64
6493
uses: actions/upload-release-asset@v1
6594
env:
6695
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6796
with:
6897
upload_url: ${{ steps.create_release.outputs.upload_url }}
69-
asset_path: dist/sharp-layer.zip
70-
asset_name: sharp-lambda-layer.zip
98+
asset_path: dist/sharp-layer.aarch64.zip
99+
asset_name: sharp-lambda-layer.aarch64.zip
71100
asset_content_type: application/zip

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
FROM lambci/lambda:build-nodejs12.x
1+
FROM amazonlinux:2-with-sources
22

33
WORKDIR /build
44

5+
RUN curl --silent --location https://rpm.nodesource.com/setup_16.x | bash -
6+
7+
RUN yum -y install nodejs
8+
59
COPY * ./
610

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

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

1721
ENTRYPOINT "/entrypoint.sh"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This AWS Lambda layer contains a pre-built [Sharp](https://www.npmjs.com/package
77

88
## Download
99

10-
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.
10+
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.
1111

1212
## Build
1313

0 commit comments

Comments
 (0)