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

Fly deployment server port fix #2438

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions waspc/packages/deploy/src/providers/fly/setup/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import {
} from '../helpers/helpers.js';
import { createFlyDbCommand } from '../index.js';

const internalPortOptionRegex = /internal_port = \d+/g;
const serverAppPort = 8080;
const clientAppPort = 8043;

export async function setup(
baseName: string,
region: string,
Expand Down Expand Up @@ -109,6 +113,23 @@ Press any key to continue or Ctrl+C to cancel.`);
replaceLineInLocalToml(minMachinesOptionRegex, 'min_machines_running = 1');
}

if (!doesLocalTomlContainLine(internalPortOptionRegex)) {
await question(`\n⚠️ There was an issue setting up your server app.
We tried modifying your server fly.toml to set ${boldText(
`internal_port = ${serverAppPort}`,
)}, but couldn't find the option ${boldText(
'internal_port',
)} in the fly.toml.

This means your server app might not be accessible.

Contact the Wasp Team at our Discord server if you need help with this: https://discord.gg/rzdnErX

Press any key to continue or Ctrl+C to cancel.`);
} else {
replaceLineInLocalToml(internalPortOptionRegex, `internal_port = ${serverAppPort}`);
}

copyLocalServerTomlToProject(deploymentInfo.tomlFilePaths);

const randomString = crypto.randomBytes(32).toString('hex');
Expand All @@ -117,7 +138,7 @@ Press any key to continue or Ctrl+C to cancel.`);
`JWT_SECRET=${randomString}`,
// NOTE: Normally these would just be envars, but flyctl
// doesn't provide a way to set envars that persist to fly.toml.
'PORT=8080',
`PORT=${serverAppPort}`,
`WASP_WEB_CLIENT_URL=${deploymentInfo.clientUrl}`,
`WASP_SERVER_URL=${deploymentInfo.serverUrl}`,
];
Expand Down Expand Up @@ -154,12 +175,10 @@ async function setupClient(deploymentInfo: DeploymentInfo<SetupOptions>) {
// This creates the fly.toml file, but does not attempt to deploy.
await $`flyctl launch --no-deploy ${launchArgs}`;

const internalPortOptionRegex = /internal_port = \d+/g;

if (!doesLocalTomlContainLine(internalPortOptionRegex)) {
await question(`\n⚠️ There was an issue setting up your client app.
We tried modifying your client fly.toml to set ${boldText(
'internal_port = 8043',
`internal_port = ${clientAppPort}`,
)}, but couldn't find the option ${boldText(
'internal_port',
)} in the fly.toml.
Expand All @@ -172,7 +191,7 @@ Press any key to continue or Ctrl+C to cancel.`);
} else {
// goStatic listens on port 8043 by default, but the default fly.toml
// assumes port 8080 (or 3000, depending on flyctl version).
replaceLineInLocalToml(internalPortOptionRegex, 'internal_port = 8043');
replaceLineInLocalToml(internalPortOptionRegex, `internal_port = ${clientAppPort}`);
}

copyLocalClientTomlToProject(deploymentInfo.tomlFilePaths);
Expand Down
Loading