Skip to content

Commit a1fef45

Browse files
authored
Merge pull request #4 from softprops/byo-bin
explicit bin option
2 parents f95402f + 3b9d610 commit a1fef45

13 files changed

+1113
-20
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tests/test-func/test-out.log
2+
target

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ services:
1111
- docker
1212

1313
script:
14-
make build
14+
make test

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# 0.2.0-rust-1.32.0
22

33
* Upgrade to Rust [`1.32.0`](https://blog.rust-lang.org/2019/01/17/Rust-1.32.0.html)
4+
* Add support to provide an explicit binary to package though `BIN` env variable
45

56
# 0.2.0-rust-1.31.1
67

7-
* Upgrade to Rust [`1.13.1`](https://blog.rust-lang.org/2018/12/20/Rust-1.31.1.html)
8+
* Upgrade to Rust [`1.31.1`](https://blog.rust-lang.org/2018/12/20/Rust-1.31.1.html)
89

910
# 0.2.0-rust-1.31.0
1011

1112
* Breaking change: move to now officially supported `provided` runtime
12-
* Upgrade to Rust `1.13.0`, enabling the first stable version `2018 edition` Rust.
13+
* Upgrade to Rust `1.31.0`, enabling the first stable version `2018 edition` Rust.
1314

1415
# 0.1.*
1516

Makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ REPO ?= softprops/lambda-rust
44
TAG ?= "$(REPO):$(VERSION)-rust-$(RUST_VERSION)"
55

66
publish: build
7-
docker push $(TAG)
8-
docker push $(REPO):latest
7+
@docker push $(TAG)
8+
@docker push $(REPO):latest
99

1010
build:
11-
docker build --build-arg RUST_VERSION=$(RUST_VERSION) -t $(TAG) .
12-
docker tag $(TAG) $(REPO):latest
11+
@docker build --build-arg RUST_VERSION=$(RUST_VERSION) -t $(TAG) .
12+
@docker tag $(TAG) $(REPO):latest
13+
14+
test: build
15+
@tests/test.sh

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AWS Lambda [Rust](https://www.rust-lang.org/) docker builder 🐑 🐳 🦀
1+
# AWS Lambda [Rust](https://www.rust-lang.org/) docker builder 🐑 🐳 🦀 [![Build Status](https://travis-ci.org/softprops/lambda-rust.svg?branch=master)](https://travis-ci.org/softprops/lambda-rust)
22

33
## 🤔 about
44

@@ -37,6 +37,18 @@ $ docker run --rm \
3737

3838
> 💡 The -v (volume mount) flags for `/root/.cargo/{registry,git}` are optional but when supplied, provides a much faster turn around when doing iterative development
3939
40+
If you are using Windows, the command above may need to be modified to include
41+
a `BIN` environment variable set to the name of the binary to be build and packaged
42+
43+
```sh
44+
$ docker run --rm \
45+
-e BIN={your-binary-name} \
46+
-v ${PWD}:/code \
47+
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
48+
-v ${HOME}/.cargo/git:/root/.cargo/git \
49+
softprops/lambda-rust
50+
```
51+
4052
## 🔬 local testing
4153

4254
Once you've built a Rust lambda function artifact, the `provided` runtime expects

build.sh

+19-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# build and pack a rust lambda library
33
# https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/
44

5-
set -euo pipefail
5+
set -eo pipefail
66
mkdir -p target/lambda
77
export CARGO_TARGET_DIR=$PWD/target/lambda
88
(
@@ -13,17 +13,24 @@ export CARGO_TARGET_DIR=$PWD/target/lambda
1313
. $HOME/.cargo/env
1414
cargo build ${CARGO_FLAGS:-} --release
1515
) 1>&2
16+
17+
function package() {
18+
file="$1"
19+
strip "$file"
20+
rm "$file.zip" > 2&>/dev/null || true
21+
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
22+
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
23+
mv "$file" bootstrap
24+
zip "$file.zip" bootstrap
25+
rm bootstrap
26+
}
27+
1628
cd "$CARGO_TARGET_DIR"/release
1729
(
18-
for file in $(
19-
find -maxdepth 1 -executable -type f
20-
); do
21-
strip "$file"
22-
rm "$file.zip" > 2&>/dev/null || true
23-
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
24-
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
25-
mv "$file" bootstrap
26-
zip "$file.zip" bootstrap
27-
rm bootstrap
28-
done
30+
if [ -z "$BIN" ]; then
31+
find -maxdepth 1 -executable -type f -exec package {} \;
32+
else
33+
package "$BIN"
34+
fi
35+
2936
) 1>&2

tests/test-func/.gitignore

Whitespace-only changes.

0 commit comments

Comments
 (0)