Skip to content

Commit

Permalink
Merge pull request #4 from softprops/byo-bin
Browse files Browse the repository at this point in the history
explicit bin option
  • Loading branch information
softprops authored Feb 10, 2019
2 parents f95402f + 3b9d610 commit a1fef45
Show file tree
Hide file tree
Showing 13 changed files with 1,113 additions and 20 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/test-func/test-out.log
target
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ services:
- docker

script:
make build
make test
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# 0.2.0-rust-1.32.0

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

# 0.2.0-rust-1.31.1

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

# 0.2.0-rust-1.31.0

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

# 0.1.*

Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ REPO ?= softprops/lambda-rust
TAG ?= "$(REPO):$(VERSION)-rust-$(RUST_VERSION)"

publish: build
docker push $(TAG)
docker push $(REPO):latest
@docker push $(TAG)
@docker push $(REPO):latest

build:
docker build --build-arg RUST_VERSION=$(RUST_VERSION) -t $(TAG) .
docker tag $(TAG) $(REPO):latest
@docker build --build-arg RUST_VERSION=$(RUST_VERSION) -t $(TAG) .
@docker tag $(TAG) $(REPO):latest

test: build
@tests/test.sh
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AWS Lambda [Rust](https://www.rust-lang.org/) docker builder 🐑 🐳 🦀
# 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)

## 🤔 about

Expand Down Expand Up @@ -37,6 +37,18 @@ $ docker run --rm \

> 💡 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
If you are using Windows, the command above may need to be modified to include
a `BIN` environment variable set to the name of the binary to be build and packaged

```sh
$ docker run --rm \
-e BIN={your-binary-name} \
-v ${PWD}:/code \
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
-v ${HOME}/.cargo/git:/root/.cargo/git \
softprops/lambda-rust
```

## 🔬 local testing

Once you've built a Rust lambda function artifact, the `provided` runtime expects
Expand Down
31 changes: 19 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# build and pack a rust lambda library
# https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/

set -euo pipefail
set -eo pipefail
mkdir -p target/lambda
export CARGO_TARGET_DIR=$PWD/target/lambda
(
Expand All @@ -13,17 +13,24 @@ export CARGO_TARGET_DIR=$PWD/target/lambda
. $HOME/.cargo/env
cargo build ${CARGO_FLAGS:-} --release
) 1>&2

function package() {
file="$1"
strip "$file"
rm "$file.zip" > 2&>/dev/null || true
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
mv "$file" bootstrap
zip "$file.zip" bootstrap
rm bootstrap
}

cd "$CARGO_TARGET_DIR"/release
(
for file in $(
find -maxdepth 1 -executable -type f
); do
strip "$file"
rm "$file.zip" > 2&>/dev/null || true
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
mv "$file" bootstrap
zip "$file.zip" bootstrap
rm bootstrap
done
if [ -z "$BIN" ]; then
find -maxdepth 1 -executable -type f -exec package {} \;
else
package "$BIN"
fi

) 1>&2
Empty file added tests/test-func/.gitignore
Empty file.
Loading

0 comments on commit a1fef45

Please sign in to comment.