Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Remove Builder, Replace with Docker Image #37

Merged
merged 1 commit into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ experience has shown this is the best way to build Python 3.6 shared libraries.

[@naftulikay][naftulikay] created a sample Rust build environment based on the upstream
[`lambci/lambda:build-python3.6`][lambci/lambda] image at
[`naftulikay/circleci-lambda-rust`][naftulikay/circleci-lambda-rust]. Previously,
[`naftulikay/crowbar`][naftulikay/crowbar]. Previously,
[`naftulikay/circleci-amazonlinux-rust`][naftulikay/circleci-amazonlinux-rust] was used and the aforementioned issues
were encountered. Despite CircleCI being used in the name, the image is a fairly generic Rust build environment and
should be fairly portable and resuable. For Travis CI and CircleCI examples, please look in the `examples/ci` directory.
should be fairly portable and resuable. For Travis CI and CircleCI examples, please look in the
[`examples/ci`](./examples/ci) directory.

Because you're building a dynamic library, other libraries that you're dynamically linking against need to also be in
the Lambda execution environment. By using the [`lambci/lambda:build-python3.6`][lambci/lambda] image, the build
Expand All @@ -87,11 +88,8 @@ LD_LIBRARY_PATH=/lib64:/usr/lib64:$LAMBDA_TASK_ROOT:$LAMBDA_TASK_ROOT/lib

[@naftulikay][naftulikay] wrote a fairly naïve Python script which will recursively copy linked libraries into the
deployment package under `lib/`. This ensures that any non-standard libraries will be available on the library path at
runtime. See the `examples/ci/{travis,circle}` directories for examples on how to use this.

The `builder` directory of the [crowbar git repo](https://github.com/ilianaw/rust-crowbar) contains a `Dockerfile` with
Rust set up and a build script to dump a zip file containing a stripped shared library to stdout. Documentation for
using that is available at [ilianaw/crowbar-builder on Docker Hub](https://hub.docker.com/r/ilianaw/crowbar-builder/).
runtime. See the `examples/ci/{travis,circle}` directories for examples on how to use this, and see
[naftulikay/docker-crowbar][naftulikay/crowbar] for more information.

## Contributing

Expand All @@ -111,5 +109,5 @@ please read it.
[lambda-execution-environment]: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
[naftulikay]: https://github.com/naftulikay
[naftulikay/circleci-amazonlinux-rust]: https://github.com/naftulikay/docker-circleci-amazonlinux-rust
[naftulikay/circleci-lambda-rust]: https://github.com/naftulikay/docker-circleci-lambda-rust
[naftulikay/crowbar]: https://github.com/naftulikay/docker-crowbar
[woes]: https://github.com/naftulikay/docker-circleci-lambda-rust#background
1 change: 0 additions & 1 deletion builder/.dockerignore

This file was deleted.

10 changes: 0 additions & 10 deletions builder/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions builder/README.md

This file was deleted.

18 changes: 0 additions & 18 deletions builder/build.sh

This file was deleted.

47 changes: 47 additions & 0 deletions examples/ci/circle/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/make -f

LAMBDA_FUNCTION_NAME:=YOUR_LAMBDA_NAME
CACHE_DIR:=$(HOME)/.cache/cargo
ZIP_FILE:=$(CACHE_DIR)/target/deploy/lambda.zip
# change this to your own container based on lambci/lambda:build-python3.6
DOCKER_IMAGE:=naftulikay/crowbar:latest

WORKDIR:=$(shell pwd)

USER_UID:=$(shell id -u)
USER_GID:=$(shell id -g)

IS_TTY:=$(shell test -t && echo '-t')

DOCKER_INVOKE:=docker run -i $(IS_TTY) --rm \
-e USER_UID=$(USER_UID) \
-e USER_GID=$(USER_GID) \
-v $(WORKDIR):/home/circleci/project \
-v $(CACHE_DIR)/cargo/registry:/home/circleci/.cargo/registry \
-v $(CACHE_DIR)/target:/home/circleci/project/target \
-v $(WORKDIR)/bin:/home/circleci/.local/bin \
$(DOCKER_IMAGE)

init:
@mkdir -p target/deploy

pull:
@docker pull $(DOCKER_IMAGE)

build: init
@$(DOCKER_INVOKE) .local/bin/build
@cp $(ZIP_FILE) target/deploy

test: init
@$(DOCKER_INVOKE) .local/bin/test

clean: init
@$(DOCKER_INVOKE).local/bin/clean

shell: init
@$(DOCKER_INVOKE)

deploy: build
@# update the function
aws --region us-east-1 lambda update-function-code --function-name $(LAMBDA_FUNCTION_NAME) \
--zip-file fileb://$(ZIP_FILE)
4 changes: 3 additions & 1 deletion examples/ci/circle/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ else
cargo build --lib --release --color never
fi

~/.local/bin/create-deployment -v target/release/liblambda.so target/deploy
# this is provided by naftulikay/crowbar to bundle a zip with all dependencies
# this will create target/deploy/lambda.zip
create-deployment -v target/release/liblambda.so target/deploy
153 changes: 0 additions & 153 deletions examples/ci/circle/bin/create-deployment

This file was deleted.

2 changes: 1 addition & 1 deletion examples/ci/travis/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LAMBDA_FUNCTION_NAME:=YOUR_LAMBDA_NAME
CACHE_DIR:=$(HOME)/.cache/cargo
ZIP_FILE:=$(CACHE_DIR)/target/deploy/lambda.zip
# change this to your own container based on lambci/lambda:build-python3.6
DOCKER_IMAGE:=naftulikay/circleci-lambda-rust:latest
DOCKER_IMAGE:=naftulikay/crowbar:latest

WORKDIR:=$(shell pwd)

Expand Down
4 changes: 3 additions & 1 deletion examples/ci/travis/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ else
cargo build --lib --release --color never
fi

~/.local/bin/create-deployment -v target/release/liblambda.so target/deploy
# this is provided by naftulikay/crowbar to bundle a zip with all dependencies
# this will create target/deploy/lambda.zip
create-deployment -v target/release/liblambda.so target/deploy
Loading