You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
5
5
RUN source $HOME/.cargo/env && rustup target add x86_64-unknown-linux-musl
6
-
RUN curl -o /etc/yum.repos.d/ngompa-musl-libc-epel-7.repo https://copr.fedorainfracloud.org/coprs/ngompa/musl-libc/repo/epel-7/ngompa-musl-libc-epel-7.repo
7
-
RUN yum install -y musl-devel musl-gcc
6
+
RUN curl -o /musl-1.2.2.tar.gz https://musl.libc.org/releases/musl-1.2.2.tar.gz \
7
+
&& tar zxf /musl-1.2.2.tar.gz && cd musl-1.2.2/ \
8
+
&& ./configure && make install && ln -s /usr/local/musl/bin/musl-gcc /usr/local/bin/x86_64-unknown-linux-musl-gcc
8
9
WORKDIR /app
9
10
ADD . /app
10
-
RUN source $HOME/.cargo/env && cargo build --release --target=x86_64-unknown-linux-musl --features vendored
Copy file name to clipboardExpand all lines: README.md
+48-6Lines changed: 48 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,22 +19,64 @@ It will start lambda runtime client after receiving 200 response from the applic
19
19
## How to build it?
20
20
21
21
AWS Lambda Adapter is written in Rust and based on [AWS Lambda Rust Runtime](https://github.com/awslabs/aws-lambda-rust-runtime).
22
-
You can use GNU Make to compile it as static linked binary and package into a docker image. We provide a [Dockerfile](Dockerfile) including all the required rust toolchain and dependencies.
23
-
You need to install [AWS CLI](https://aws.amazon.com/cli/) and [Docker](https://www.docker.com/get-started) to run the build.
22
+
AWS Lambda executes functions in x86_64 Amazon Linux Environment. We need to cross compile the adapter to that environment.
23
+
24
+
### Compiling on macOS
25
+
26
+
First, install [rustup](https://rustup.rs/) if you haven't done it already. Then, add the `x86_64-unknown-linux-musl` target:
27
+
28
+
```shell
29
+
$ rustup target add x86_64-unknown-linux-musl
30
+
```
31
+
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.
33
+
34
+
```shell
35
+
$ brew tap messense/macos-cross-toolchains
36
+
$ brew install x86_64-unknown-linux-musl
37
+
```
38
+
39
+
And we need to inform Cargo that our project uses the newly-installed linker when building for the `x86_64-unknown-linux-musl` platform.
40
+
Create a new directory called `.cargo` in your project folder and a new file called `config` inside the new folder.
On x86_64 Windows, Linux and macOS, you can run one command to compile Lambda Adapter with docker.
24
65
25
66
```shell
26
-
make build
67
+
$ make build
27
68
```
28
-
This will create a docker image called "aws-lambda-adapter:latest". In this docker image, AWS Lambda Adapter is packaged as a file "/opt/bootstrap".
69
+
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.
29
71
30
72
## How to use it?
31
73
32
-
To use it, copy the bootstrap binary from "aws-lambda-adapter:latest" to your container, and use it as ENTRYPOINT.
74
+
To use it, copy the bootstrap binary to your container, and use it as ENTRYPOINT.
33
75
Below is an example Dockerfile for packaging a nodejs application.
0 commit comments