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

Allow Fly to build locally #1006

Merged
merged 4 commits into from
Feb 16, 2023
Merged

Conversation

shayneczyzewski
Copy link
Contributor

@shayneczyzewski shayneczyzewski commented Feb 14, 2023

Description

Allows wasp deploy fly users to specify if server/client should be built locally (using their own Docker) by optionally passing --build-locally to launch and/or deploy. Before, it would always just run on the Fly builder. This may not be ideal if the build process requires lots of resources/time, and they cannot use the Free Builder for it.

It also fixes up the use of shared options and how those are expressed in the interfaces.

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

Update Waspc ChangeLog and version if needed

If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

@shayneczyzewski shayneczyzewski changed the title Draft: Allow Fly to build locally Allow Fly to build locally Feb 15, 2023
@shayneczyzewski shayneczyzewski marked this pull request as ready for review February 15, 2023 15:05
Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

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

2 tiny comments, LGTM otherwise!

@@ -20,6 +20,10 @@ class FlyCommand extends Command {
.option('--initial-cluster-size <initialClusterSize>', 'flyctl postgres create option', '1')
.option('--volume-size <volumeSize>', 'flyctl postgres create option', '1');
}
addLocalBuildOption(): this {
return this.option('--build-server-locally', 'force the server Docker container to build locally', false)
Copy link
Member

Choose a reason for hiding this comment

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

What happens otherwise? It always get's built remotely?
When I read "forces", it sounds like normally it might build locally or it might build remotely, but now we made sure it builds locally -> but is that correct?
We could mention default behaviour here if there is one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current implementation defaults to building remotely, which is mentioned in the docs (I can mention here too). This flag forces local. The default behavior of flyctl deploy without any flags is to build locally if Docker was running, but otherwise build remotely. I am not a big fan of that for Wasp users to help support and debug build failures, etc., so was thinking it may benefit us to make it 100% deterministic, so we just default to remote but they can override and build locally if the need arises. Does that make sense?

Copy link
Contributor Author

@shayneczyzewski shayneczyzewski Feb 16, 2023

Choose a reason for hiding this comment

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

Actually, to probably better address your point, I can make it read something like build Docker containers locally instead of remotely or something like that?

@@ -20,6 +20,10 @@ class FlyCommand extends Command {
.option('--initial-cluster-size <initialClusterSize>', 'flyctl postgres create option', '1')
.option('--volume-size <volumeSize>', 'flyctl postgres create option', '1');
}
addLocalBuildOption(): this {
return this.option('--build-server-locally', 'force the server Docker container to build locally', false)
.option('--build-client-locally', 'force the client Docker container to build locally', false);
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, how is it that we have two commands, and not just one --build-locally that would build everything locally? When might one want to build one thing locally and other thing not?

Copy link
Contributor Author

@shayneczyzewski shayneczyzewski Feb 16, 2023

Choose a reason for hiding this comment

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

Unsure, I can collapse it to one option for now and we can split if needed later on.

}
}

async function deployServer(deploymentInfo: DeploymentInfo) {
async function deployServer(deploymentInfo: DeploymentInfo, buildServerLocally: boolean) {
Copy link
Contributor

@infomiho infomiho Feb 16, 2023

Choose a reason for hiding this comment

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

Nit: I prefer prefer using objects for options vs. providing boolean params.

await deployServer(..., true)

vs.

await deployServer(..., { buildClientLocally: true })

Your code is clear to me because you are using it like this:

await deployClient(..., options.buildClientLocally);

but I'm just looking out for the future, and making this code easier to extend with additional options if we need to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, can do 👍🏻

@shayneczyzewski shayneczyzewski merged commit 868362d into main Feb 16, 2023
@shayneczyzewski shayneczyzewski deleted the shayne-allow-fly-build-locally branch February 16, 2023 15:27
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