Skip to content

Commit

Permalink
chore(backend): add postgres mount for container (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Aug 21, 2024
1 parent 8f43c6b commit 58ef34a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
19 changes: 8 additions & 11 deletions rivet-toolchain/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub struct BackendCommandOpts {
pub env: HashMap<String, String>,
pub cwd: PathBuf,
pub ports: Vec<(u16, u16)>,
pub tty: bool,
}

#[derive(PartialEq, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -68,7 +67,7 @@ pub async fn build_opengb_command(opts: BackendCommandOpts) -> GlobalResult<Comm
// Make sure the file is properly flushed, and doesn't get deleted
// after the NamedTempFile goes out of scope
env_file.flush()?;
let (env_file, env_file_path) = env_file.keep()?;
let (_env_file, env_file_path) = env_file.keep()?;

let mut cmd = shell_cmd("docker");
cmd.arg("run");
Expand All @@ -78,20 +77,18 @@ pub async fn build_opengb_command(opts: BackendCommandOpts) -> GlobalResult<Comm
cmd.arg("--init");
cmd.arg("--env-file").arg(env_file_path);
cmd.arg("--add-host=host.docker.internal:host-gateway");
cmd.arg("--publish=6420:6420");
// Mount the project
cmd.arg(format!("--volume={}:/backend", opts.cwd.display()));
// Mount Postgres volume for bundled Postgres server
cmd.arg("--volume=opengb_postgres:/var/lib/postgresql/data");
cmd.arg("--workdir=/backend");
cmd.arg(image_tag);
cmd.arg("--project");
cmd.arg(opts.config_path);

if opts.tty {
cmd.arg("--tty");
}

for (host_port, container_port) in opts.ports {
cmd.arg(format!("--publish={}:{}", host_port, container_port));
}
cmd.arg(image_tag);

cmd.arg("--project");
cmd.arg(opts.config_path);

cmd.args(&opts.args);
Ok(cmd)
Expand Down
1 change: 0 additions & 1 deletion rivet-toolchain/src/tasks/backend_dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl super::Task for Task {
env: cmd_env,
cwd: input.cwd.into(),
ports: vec![(input.port, input.port)],
tty: true,
},
)
.await?;
Expand Down
1 change: 0 additions & 1 deletion rivet-toolchain/src/tasks/backend_sdk_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl super::Task for Task {
env: cmd_env,
cwd: input.cwd.into(),
ports: vec![],
tty: false,
},
)
.await?;
Expand Down
2 changes: 0 additions & 2 deletions rivet-toolchain/src/tasks/deploy/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub async fn deploy(ctx: &Ctx, task: TaskCtx, opts: DeployOpts) -> GlobalResult<
env: cmd_env,
cwd: project_path.clone(),
ports: vec![],
tty: false,
},
)
.await?;
Expand Down Expand Up @@ -89,7 +88,6 @@ pub async fn deploy(ctx: &Ctx, task: TaskCtx, opts: DeployOpts) -> GlobalResult<
env: migrate_env,
cwd: project_path.clone(),
ports: vec![],
tty: false,
},
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_ffi.sh → scripts/build_cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ echo "ARM macOS: target/aarch64-apple-darwin/release/"
echo "x86 Linux: target/x86_64-unknown-linux-gnu/debug/"
echo "x86 Windows: target/x86_64-pc-windows-gnu/debug/"
echo "x86 macOS: target/x86_64-apple-darwin/debug/"
echo "ARM macOS: target/aarch64-apple-darwin/debug/"
echo "ARM macOS: target/aarch64-apple-darwin/debug/"

0 comments on commit 58ef34a

Please sign in to comment.