From 6af6ee096afb707632a65ab05d7e59cbb40b4476 Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Sun, 21 Jun 2026 09:50:48 -0500 Subject: [PATCH] fix(start): enable persistent storage mode when --persist is set (#9) The server defaults to FLOCI_STORAGE_MODE=memory, so the --persist bind mount to /app/data was a no-op: state was never written to disk and did not survive a container restart. Set FLOCI_STORAGE_MODE=persistent (per-cloud prefixed variant for GCP and Azure) whenever --persist is provided, so emulator state is written to the mounted host directory and survives restarts. Verified end-to-end with S3 and DynamoDB across a stop --remove + start cycle. --- src/main/java/io/floci/cli/commands/StartCommand.java | 3 +++ src/main/java/io/floci/cli/commands/az/AzStartCommand.java | 3 +++ src/main/java/io/floci/cli/commands/gcp/GcpStartCommand.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/main/java/io/floci/cli/commands/StartCommand.java b/src/main/java/io/floci/cli/commands/StartCommand.java index 49ee46e..7189b0a 100644 --- a/src/main/java/io/floci/cli/commands/StartCommand.java +++ b/src/main/java/io/floci/cli/commands/StartCommand.java @@ -84,6 +84,9 @@ public class StartCommand implements Callable { args.addAll(DockerClient.dockerSocketRunArgs()); if (persistDir != null) { args.addAll(List.of("-v", persistDir + ":/app/data")); + // The server defaults to in-memory storage; enable persistent mode so + // state is actually written to the mounted directory and survives restarts. + args.addAll(List.of("-e", "FLOCI_STORAGE_MODE=persistent")); } if (services != null && !services.isBlank()) { args.addAll(List.of("-e", "FLOCI_SERVICES=" + services)); diff --git a/src/main/java/io/floci/cli/commands/az/AzStartCommand.java b/src/main/java/io/floci/cli/commands/az/AzStartCommand.java index a6ac25e..dca1a3e 100644 --- a/src/main/java/io/floci/cli/commands/az/AzStartCommand.java +++ b/src/main/java/io/floci/cli/commands/az/AzStartCommand.java @@ -79,6 +79,9 @@ public class AzStartCommand implements Callable { args.addAll(DockerClient.dockerSocketRunArgs()); if (persistDir != null) { args.addAll(List.of("-v", persistDir + ":/app/data")); + // The server defaults to in-memory storage; enable persistent mode so + // state is actually written to the mounted directory and survives restarts. + args.addAll(List.of("-e", "FLOCI_AZ_STORAGE_MODE=persistent")); } if (services != null && !services.isBlank()) { args.addAll(List.of("-e", "FLOCI_AZ_SERVICES=" + services)); diff --git a/src/main/java/io/floci/cli/commands/gcp/GcpStartCommand.java b/src/main/java/io/floci/cli/commands/gcp/GcpStartCommand.java index e8223ef..ec2038d 100644 --- a/src/main/java/io/floci/cli/commands/gcp/GcpStartCommand.java +++ b/src/main/java/io/floci/cli/commands/gcp/GcpStartCommand.java @@ -79,6 +79,9 @@ public class GcpStartCommand implements Callable { args.addAll(DockerClient.dockerSocketRunArgs()); if (persistDir != null) { args.addAll(List.of("-v", persistDir + ":/app/data")); + // The server defaults to in-memory storage; enable persistent mode so + // state is actually written to the mounted directory and survives restarts. + args.addAll(List.of("-e", "FLOCI_GCP_STORAGE_MODE=persistent")); } if (services != null && !services.isBlank()) { args.addAll(List.of("-e", "FLOCI_GCP_SERVICES=" + services));