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

Feature/adds development container #32

Merged

Conversation

jasonwashburn
Copy link

This PR adds config and scripts for a devcontainer running on the rust/bullseye variant. The WASI-SDK and Spin versions used at build time, can be modified by changing args passed to Dockerfile in devcontainer.json.

Compilation of cPython and spin-python-sdk are performed in a post creation command script since they rely on the repository being available (not the case during build time when using on GitHub codespaces)

I've tested it successfully as is on both GitHub Codespaces, and on an x86 linux host, but it could probably use a little more testing in other configs, ie: on windows, or maybe with different versions of wasi-sdk / spin version, though I don't know the currently compatibility story there, so maybe not relevant.

Known issues:

  • Doesn't currently work on newer (m1, m2) MacOS hosts due to glibc2 issues with spin installer on aarch64 bullseye. (believe related to spin/168 and similar to bartholomew/150
  • Based on previous experience locally, I also expect to have trouble with compiling cPython on newer MacOS hosts as well once past the spin installer

Opening up draft PR to facilitate discussion and collect feedback on experience, or thoughts on improvements to the config, extensions, included python tooling etc.

@jasonwashburn
Copy link
Author

jasonwashburn commented Apr 29, 2023

It seems there's an issue with trying to switch the variant to buster. When you do so, the spin install script fails for a missing version of glibc (See output below). Looks to be related to fermyon/spin#168 and fermyon/bartholomew#150 as well, not necessarily an issue with the python sdk or the devcontainer, other than maybe don't use buster.

Confirmed same error when using spin versions 0.9.0 thru canary, which can be changed by passing into the command below as a build arg --build-arg SPIN_VERSION=v0.9.0

reproducible by building the devcontainer manually:
docker build --build-arg VARIANT=buster .devcontainer/.

Step 10/10 : RUN cd /tmp     && curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash -s -- -v $SPIN_VERSION     && sudo mv spin /usr/local/bin/     && cd -
 ---> Running in 54c0fee46bb9
Step 1: Downloading: https://github.com/fermyon/spin/releases/download/canary/spin-canary-linux-amd64.tar.gz
Done...

Step 2: Decompressing: spin-canary-linux-amd64.tar.gz
crt.pem
spin.sig
README.md
LICENSE
spin
./spin: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./spin)
./spin: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.29' not found (required by ./spin)
The command '/bin/sh -c cd /tmp     && curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash -s -- -v $SPIN_VERSION     && sudo mv spin /usr/local/bin/     && cd -' returned a non-zero code: 1

@jasonwashburn jasonwashburn force-pushed the feature/adds-development-container branch from 9b15d58 to 040fb6f Compare May 8, 2023 23:46
@mikkelhegn
Copy link
Member

Does installing the build dependencies, like described here: https://developer.fermyon.com/spin/install#building-spin-from-source help?

@jasonwashburn
Copy link
Author

jasonwashburn commented Jun 15, 2023

I hadn't tried it, but I suspect it probably would since it should link against the correct glibc. Wasn't sure of the best way to go on it. Since it's being used for development, my initial thought was to just duplicate the environment that the main spin repo is build in, to keep things the same. Though, it wouldn't be linked, so there's just a much a chance of getting out of sync, so maybe building from scratch based on the selected variant and spin version. 🤔

easy enough to try out either way, I'll see if I can knock that out in the next day or so

@jasonwashburn jasonwashburn force-pushed the feature/adds-development-container branch from 040fb6f to 5a3b352 Compare July 8, 2023 12:48
@jasonwashburn jasonwashburn force-pushed the feature/adds-development-container branch from ade4c50 to b26d827 Compare July 27, 2023 01:57
@jasonwashburn
Copy link
Author

jasonwashburn commented Aug 15, 2023

hmm...I thought I had responded to the previous question already but apparently I did not...Long story short, switching to building spin from source didn't fix the issue, I started running into the same glibc error messages from the wasi sdk as well.

After taking another look at my original goal for building a devcontainer, to get a dev environment with dependencies up and running quickly and reproducibly, I've decided to limit the devcontainer install/build to just the prerequisite installed dependencies listed in the README to get a user right up to the point where they can run the build scripts (build-python.sh and make), following the instructions in the README, rather than automating the full build during container startup. I think this will work better with future changes that require changes to the build system, cpython versions etc.

@jasonwashburn jasonwashburn force-pushed the feature/adds-development-container branch from 6cc2b85 to dbb4278 Compare August 16, 2023 00:30
@jasonwashburn jasonwashburn marked this pull request as ready for review August 16, 2023 00:32
@jasonwashburn
Copy link
Author

Alright, I think I have it in a good place. Tested it on Ubuntu, Ubuntu in WSL , and on Github Codespaces by pulling the repo from scratch, building the devcontainer in vscode and then following the instructions in the readme to build the plugin, then test it with the example hello world app. I made an update to the readme about needing to do a git submodule update before trying to run the build-python.sh.

.devcontainer/Dockerfile Show resolved Hide resolved
.devcontainer/postCreateCommands.sh Outdated Show resolved Hide resolved
README.md Outdated
### Instructions

First, build CPython for wasm32-wasi.
First, perform a git submodule update to update the cpython submodule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this and the CPython build be part of the container creation?

Copy link
Author

@jasonwashburn jasonwashburn Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could actually do a couple of things here. I flipped back and forth a couple of times on it previously. It all comes down to the usual workflow...if there is rarely a need to rebuild cpython or make changes to the branch etc, then it probably makes sense to move it into the dockerfile and take advantage of image caching...the build is already long enough to be a "walk away for a bit" build the first time, so I'm not adverse to just including the python compile as well.

Ultimately I made the decision to leave it this way after looking at how the development steps are listed in the README...ie: install these dependencies (stuff I put in dockerfile) and then steps begin with "run this script" which I left up to the user.

I'll defer to you guys at Fermyon though as far as which way would be a better developer experience given the normal workflow and tasks that are often performed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on discord, I switch the devcontainer to use an artifact compiled version of wasi cpython, so running these commands is no longer necessary when using it. Added notes to the affected steps in the README.

@jasonwashburn jasonwashburn force-pushed the feature/adds-development-container branch from ae224b8 to baf43e8 Compare September 12, 2023 11:52
@mikkelhegn mikkelhegn self-requested a review September 13, 2023 08:18
Copy link
Member

@mikkelhegn mikkelhegn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikkelhegn
Copy link
Member

Thanks @jasonwashburn. One last thing is to to make sure your commits are signed before we can merge them.

@jasonwashburn jasonwashburn force-pushed the feature/adds-development-container branch from baf43e8 to f6dab68 Compare September 13, 2023 11:03
@jasonwashburn
Copy link
Author

I'm sure you guys are busy, just checking back to make sure there's not something additional you'd like to me to do with this?

@itowlson itowlson merged commit 43727d4 into fermyon:main Oct 8, 2023
@itowlson
Copy link
Contributor

itowlson commented Oct 8, 2023

Sorry about that @jasonwashburn, I'm not sure what happened there! I've merged it now - thanks for putting this together!

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.

3 participants