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

added simple docker docs #26

Open
wants to merge 4 commits into
base: feature/docs-restructuring
Choose a base branch
from

Conversation

databasedav
Copy link

this is all i needed for deployment so i figured i'd add it to the docs, feel free to edit however

thanks for this library :)

@databasedav
Copy link
Author

databasedav commented Oct 24, 2023

actually it probably makes sense to have a separate builder stage with a prebuilt rust image, although it looks like this would require using the crate management flow instead of the highest level python/minimal rust flow

@mityax mityax changed the base branch from master to feature/docs-restructuring October 25, 2023 15:35
@mityax
Copy link
Owner

mityax commented Oct 25, 2023

Hi, great work!

I'm planning to do some restructuring on the readme (maybe extracting stuff to the GitHub Wiki), since I feel like it's become way to long and one doesn't have a good overview anymore. So I'll merge your PR into my feature branch for this.

In the Wiki we'd also have enough space to illustrate how to use a multi-stage dockerfile – if you'd be willing to draw up an example for that, please just add it to your PR. Otherwise, I'll do it once I find the time. Please let me know whether you'd like to work on this as well, so that I know when to merge :)

Thanks for your contribution!

@databasedav
Copy link
Author

databasedav commented Nov 2, 2023

@mityax i'm down to add a multistage example as well :)

just a few questions: this would be separate from the combined python/rust version, correct? i think having a high level version that any python user can just plug into an existing dockerfile is super convenient, since their rust code would be able to continue to live entirely in the single .rs file, with anything else rust managed opaquely by rustimport. also is there an analog for the python -m rustimport build command in the rust package? (i haven't peeked at that python code yet, is it just delegating to cargo build?)

@mityax
Copy link
Owner

mityax commented Nov 2, 2023

Nice you're up for that :)

I'm not entirely sure what your concern ist, so I'll just share my imagined workflow, which I think should work fine for single .rs files as well as crates:

Builder Stage:

  1. Either make sure both stages have the same architecture (aka rust compilation target), or set the according target for the final stage directly (e.g. using ENV CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu or so)
    This pattern looks clean btw, didn't know about it
  2. rustimport build --release
    → This will build all single .rs file extensions as well as crate extensions

Final Stage:

  1. COPY --from builder /path/to/workdir/* ./*
    → Since we're copying the entire workdir, all binaries built in the builder stage are included and placed in the correct location automatically
  2. ENV RUSTIMPORT_RELEASE_MODE=true (could also be included in the single-stage dockerfile btw)

Does this answer your question? If not, please explain again what you mean, so I can provide a better answer :)

@mityax
Copy link
Owner

mityax commented Nov 2, 2023

From some tryal btw, I think it's best to use rust:bookworm as base for the builder and then installing pip & rustimport like this:

apt update && apt install -y python3-pip
rm /usr/lib/python3.*/EXTERNALLY-MANAGED  # required to install pip packages without the extra load of creating a venv 
pip install --user rustimport

This was pretty quick in my test and cargo and rust come preinstalled – after these three lines a simple test with rustimport worked out of the box :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants