feat: add bottomless replication

This commit is contained in:
Oliver Geneser
2025-09-14 11:30:21 +02:00
parent 307916a49a
commit 53a11b81d6
10 changed files with 7153 additions and 11 deletions

View File

@@ -31,7 +31,11 @@ const getLibsqlImage = (arch: string): string => {
export type LibsqlNested = InferResultType<
"libsql",
{ mounts: true; environment: { with: { project: true } } }
{
mounts: true;
environment: { with: { project: true } };
bottomlessReplicationDestination: true;
}
>;
export const buildLibsql = async (libsql: LibsqlNested) => {
const {
@@ -53,6 +57,8 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
mounts,
serverId,
enableNamespaces,
enableBottomlessReplication,
bottomlessReplicationDestination,
} = libsql;
let finalDockerImage = dockerImage;
@@ -66,10 +72,20 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
"utf-8",
).toString("base64");
const defaultLibsqlEnv = `SQLD_NODE="${sqldNode}"\nSQLD_HTTP_AUTH="basic:${basicAuth}"${
let defaultLibsqlEnv = `SQLD_NODE="${sqldNode}"\nSQLD_HTTP_AUTH="basic:${basicAuth}"${
env ? `\n${env}` : ""
}${sqldNode === "replica" ? `\nSQLD_PRIMARY_URL="${sqldPrimaryUrl}"` : ""}`;
// Add bottomless replication environment variables if destination is configured
if (enableBottomlessReplication && bottomlessReplicationDestination) {
defaultLibsqlEnv += `\nLIBSQL_BOTTOMLESS_DATABASE_ID="${appName}"`;
defaultLibsqlEnv += `\nLIBSQL_BOTTOMLESS_BUCKET="${bottomlessReplicationDestination.bucket}"`;
defaultLibsqlEnv += `\nLIBSQL_BOTTOMLESS_ENDPOINT="${bottomlessReplicationDestination.endpoint}"`;
defaultLibsqlEnv += `\nLIBSQL_BOTTOMLESS_AWS_SECRET_ACCESS_KEY="${bottomlessReplicationDestination.secretAccessKey}"`;
defaultLibsqlEnv += `\nLIBSQL_BOTTOMLESS_AWS_ACCESS_KEY_ID="${bottomlessReplicationDestination.accessKey}"`;
defaultLibsqlEnv += `\nLIBSQL_BOTTOMLESS_AWS_DEFAULT_REGION="${bottomlessReplicationDestination.region}"`;
}
const {
HealthCheck,
RestartPolicy,
@@ -103,6 +119,9 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
if (enableNamespaces) {
finalCommand += " --enable-namespaces";
}
if (enableBottomlessReplication) {
finalCommand += " --enable-bottomless-replication";
}
const settings: CreateServiceOptions = {
Name: appName,