Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to compile code in a Docker container #7

Open
rnag opened this issue Mar 23, 2022 · 2 comments
Open

Add an option to compile code in a Docker container #7

rnag opened this issue Mar 23, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rnag
Copy link
Owner

rnag commented Mar 23, 2022

The goal here is quite simple, but ideally we want to provide a way for users to compile rust code in a containerized manner, perhaps leveraging Docker and an Amazon Linux build image. If the host machine doesn't have rustup or cargo-zigbuild installed, we should by default use Docker to build and compile rust code.

The end goal would probably be to find a suitable Docker container, so if the container for example has zigbuild and zig already installed, that would be ideal; though of course if the architecture in the Docker container matches the target, then there's a chance we might not need zigbuild in such a case.

We could also take inspiration from other similar NPM libraries such as aws-lambda-go, which does also support building code in a Docker environment.

Docker Image

For the actual Docker image to use, I'm still open to suggestions as mentioned above, so ideally an image that comes with tools like cargo-zigbuild and cross already installed. I think an excellent starting point would be to look into the image that softprops/lambda-rust provides:

https://github.com/softprops/lambda-rust

@rnag rnag added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Mar 23, 2022
@rnag rnag changed the title Add option to compile code in a Docker container Add an option to compile code in a Docker container Mar 23, 2022
@multimeric
Copy link

I would say it's quite important that you do start from the Amazon Linux build image, and then perhaps use it as a base image that you install cargo into and then re-use for builds. But to be clear, it's no one's preference to use Docker. If I can get it to compile for the right glibc version using zig then that's ideal.

@rnag
Copy link
Owner Author

rnag commented Mar 24, 2022

Yes, I certainly agree. I do think the Dockerfile that softprops/lambda-rust uses is a good starting point. I'll need to run some initial tests to confirm if the build environment works without the need to cross-compile with something like zig, but my initial impression is it won't be needed. I also likewise feel that using Docker is not ideal is general, and building code with zig should be preferrable in most cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants