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 Mzoon Build path environment variable #2

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

d2weber
Copy link
Contributor

@d2weber d2weber commented Oct 1, 2021

This PR makes herokus environment variables available in the compile script (heroku config:set MZOON_BUILD_PATH=app) and builds the app specified by the path.

The detect script is still looking for a MoonZoon.toml att the root, since its not possible to use the environment variable in the detect script. Do you have an idea how to solve this? To test I created a dummy MoonZoon.toml.

The Procfile has to remain in the root with the content: web: "$MZOON_BUILD_PATH/target/release/backend"

@d2weber
Copy link
Contributor Author

d2weber commented Oct 1, 2021

For testing I used a modified branch on the MoonZoon demo repo, where everything is moved to the subfolder app, the Procfile is adjusted and a dummy MoonZoon.toml is in the root: https://github.com/d2weber/demo/tree/build_path
The environment varible is set: heroku config:set MZOON_BUILD_PATH=app

I don't understand why, but when i deploy (see https://demomoonzoon.herokuapp.com/) the frontend seems to have some problem. The build id seems to be 0, as the modules included in index.html are named /_api/pkg/frontend_0.js and the page remains blank. The output of ./mzoon build -r looks fine..

@MartinKavik
Copy link
Member

It works on the first try, I don't know what I should debug.. :) Once we can remove the dummy MoonZoon.toml and find out why it does not work for you, it's good to go I think.

@d2weber
Copy link
Contributor Author

d2weber commented Oct 2, 2021

Now i tried again and it seems to work also for me. Strange.. I don't think I changed anything, also the Heroku build cache was active in both cases. Maybe my browser cache? I don't know.

I don't have a good solution for the detect script. I don't think we should simply always detect unconditionally. I looked at some other builpacks and the only one I found which lets you specify a subdirectory is a rust buildpack. They use a RustConfig file in the root which contains environment varibles. But I don't know if you want a file like that in the root. You might prefer to move the root of the workspace one level up, so that Cargo.toml and Moonzoon.toml would be in the root.

I can think of the following alternatives:

  • Using the this buildpack, which copies the content of a specified subdirectory to the root build directory. That means that one would have to use two buildpacks.
  • Making the app directory a git submodule in the voting-solana-moonzoon repo. You could then only push that. But it would make cloning the parent repo more complicated.
  • Only pushing the subdirectory: git subtree push --prefix app heroku main

I think the latter would be the cleanest solution, because you use the repo to group different kinds of information regarding that topic. Everything for the app resides inside the app folder and it would be confusing to have any app-specific file in the root.

@d2weber
Copy link
Contributor Author

d2weber commented Oct 2, 2021

A well, another possibility might be a Dockerfile based deployment to heroku but i didn't yet think about that in more depth.

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