Skip to content

Commit 7273db4

Browse files
committed
update README and GitHub actions
1 parent 55036d9 commit 7273db4

File tree

7 files changed

+37
-18
lines changed

7 files changed

+37
-18
lines changed

.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[target.x86_64-unknown-linux-musl]
2-
linker = "musl-gcc"
2+
linker = "x86_64-unknown-linux-musl-gcc"

.dockerignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
examples
2-
target
3-
.cargo
1+
examples

.github/workflows/pipeline.yml

+13-6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v2
19-
- name: Install dependencies
20-
run: rustup target add x86_64-unknown-linux-musl
21-
&& curl -o ./musl-1.2.2.tar.gz https://musl.libc.org/releases/musl-1.2.2.tar.gz
22-
&& tar zxf ./musl-1.2.2.tar.gz && cd musl-1.2.2/
23-
&& ./configure && sudo make install && sudo ln -s /usr/local/musl/bin/musl-gcc /usr/local/bin
19+
20+
- name: Configure AWS credentials
21+
uses: aws-actions/configure-aws-credentials@v1
22+
with:
23+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
24+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
25+
aws-region: us-east-1
26+
27+
- name: Login to Amazon ECR
28+
id: login-ecr
29+
uses: aws-actions/amazon-ecr-login@v1
30+
2431
- name: Build
25-
run: CC=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl --features vendored
32+
run: DOCKER_BUILDKIT=1 docker build -t aws-lambda-adapter:latest .

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ ADD . /app
1111
RUN source $HOME/.cargo/env && CC=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl --features vendored
1212

1313
FROM scratch AS package-stage
14-
COPY --from=build-stage /app/target/ /
14+
COPY --from=build-stage /app/target/x86_64-unknown-linux-musl/release/bootstrap /opt/bootstrap

Dockerfile.mac

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM scratch
2+
COPY target/x86_64-unknown-linux-musl/release/bootstrap /opt/bootstrap

Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ clean:
22
rm -rf target
33

44
build:
5-
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/awsguru
6-
DOCKER_BUILDKIT=1 docker build --output target .
5+
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
6+
DOCKER_BUILDKIT=1 docker build -t aws-lambda-adapter:latest .
7+
8+
build-mac:
9+
CC=x86_64-unknown-linux-musl-gcc cargo build --release --target=x86_64-unknown-linux-musl --features vendored
10+
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
11+
DOCKER_BUILDKIT=1 docker build -f Dockerfile.mac -t aws-lambda-adapter:latest .

README.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ First, install [rustup](https://rustup.rs/) if you haven't done it already. Then
2929
$ rustup target add x86_64-unknown-linux-musl
3030
```
3131

32-
And we have to install macOS cross-compiler toolchains. `messense/homebrew-macos-cross-toolchains` can be used on both Intel Mac and Apple M1.
32+
And we have to install macOS cross-compiler toolchains. `messense/homebrew-macos-cross-toolchains` can be used on both Intel chip and Apple M1 chip.
3333

3434
```shell
3535
$ brew tap messense/macos-cross-toolchains
@@ -53,14 +53,21 @@ $ CC=x86_64-unknown-linux-musl-gcc cargo build --release --target=x86_64-unknown
5353

5454
Lambda Adapter binary will be placed at `target/x86_64-unkonw-linux-musl/release/bootstrap`.
5555

56-
### Compiling on Docker
56+
Finally, run the following command to package lambda adapter into a docker image named "aws-lambda-adapter:latest".
57+
58+
```shell
59+
$ aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
60+
$ DOCKER_BUILDKIT=1 docker build -f Dockerfile.mac -t aws-lambda-adapter:latest .
61+
```
62+
63+
### Compiling with Docker
5764
On x86_64 Windows, Linux and macOS, you can run one command to compile Lambda Adapter with docker.
5865

5966
```shell
60-
make build
67+
$ make build
6168
```
6269

63-
The build output will be placed into `target` directory.
70+
Once the build completes, it creates a docker image called "aws-lambda-adapter:latest". AWS Lambda Adapter binary is packaged as '/opt/bootstrap' inside the docker image.
6471

6572
## How to use it?
6673

@@ -69,7 +76,7 @@ Below is an example Dockerfile for packaging a nodejs application.
6976

7077
```dockerfile
7178
FROM public.ecr.aws/lambda/nodejs:14
72-
COPY target/x86_64-unkonw-linux-musl/release/bootstrap /opt/bootstrap
79+
COPY --from aws-lambda-adapter:latest /opt/bootstrap
7380
ENTRYPOINT ["/opt/bootstrap"]
7481
EXPOSE 8080
7582
WORKDIR "/var/task"

0 commit comments

Comments
 (0)