Skip to content

Commit

Permalink
Add a check to make sure phoenix compiles before continuing (#2903)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeregrine authored Oct 13, 2023
1 parent 50cdf00 commit 827a564
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scanner/phoenix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"

"github.com/pkg/errors"
"github.com/superfly/flyctl/helpers"
"github.com/superfly/flyctl/internal/command/launch/plan"
)
Expand Down Expand Up @@ -71,11 +72,20 @@ func configurePhoenix(sourceDir string, config *ScannerConfig) (*SourceInfo, err
},
}

// We found Phoenix, so check if the Docker generator is present
cmd := exec.Command("mix", "do", "deps.get,", "compile,", "run", "-e", "\"true = Code.ensure_loaded?(Mix.Tasks.Phx.Gen.Release)\"")
// We found Phoenix, so check if the project compiles.
cmd := exec.Command("mix", "do", "deps.get,", "compile")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
return nil, errors.Wrap(err, "We've identified an Elixir Project but when attempting to compile it we ran into an error. Please check that your Elixir project builds successfully and try again.")
}

// We found Phoenix, so lets check if its a recent version.
releaseCmd := exec.Command("mix", "run", "-e", "\"true = Code.ensure_loaded?(Mix.Tasks.Phx.Gen.Release)\"")
releaseCmd.Stdout = os.Stdout
releaseCmd.Stderr = os.Stderr
err = releaseCmd.Run()
if err == nil {
s.DeployDocs = `
Your Phoenix app should be ready for deployment!.
Expand All @@ -87,7 +97,7 @@ When you're ready to deploy, use 'fly deploy'.
} else {
s.SkipDeploy = true
s.DeployDocs = `
We recommend upgrading to Phoenix 1.6.3 which includes a release configuration for Docker-based deployment.
We recommend upgrading to Phoenix 1.7.9 which includes a release configuration for Docker-based deployment.
If you do upgrade, you can run 'fly launch' again to get the required deployment setup.
Expand Down

0 comments on commit 827a564

Please sign in to comment.