Light, fluffy, and always free - The AWS Local Emulator alternative
docs: document the standalone floci-aws binary (#6114)
Hector Ventura7b9e877f7a14
diff --git a/README.md b/README.mdindex 70d418cbbe..724c243eaf 100644--- a/README.md+++ b/README.md@@ -55,6 +55,9 @@ The fastest way to run Floci is with the official [CLI](https://github.com/flocifloci start```+No Docker? Each [release](https://github.com/floci-io/floci/releases) also ships a standalone `floci-aws`+binary for Linux, macOS and Windows; see [Native binary](https://floci.io/docs/getting-started/installation/#native-binary).+Export the AWS environment variables:```bashdiff --git a/docs/configuration/docker-images.md b/docs/configuration/docker-images.mdindex 9afdb3b8ac..e9c1366b23 100644--- a/docs/configuration/docker-images.md+++ b/docs/configuration/docker-images.md@@ -109,7 +109,7 @@ Use `cosign verify`, not `cosign verify-attestation`. The latter targets cosign'If the standard ARM64 image exits with `CPU features [FP, ASIMD, CRC32, LSE] not supported`, use the `-baseline` release tag. The baseline image is compiled with GraalVM `-march=armv8-a`, so it does not require LSE. For example, use `floci/floci:latest-baseline` or pin `floci/floci:x.y.z-baseline`.-The baseline variant currently covers the Docker image only. The standalone `floci-linux-arm64` binary remains tracked in [#1114](https://github.com/floci-io/floci/issues/1114).+The same build is published as the standalone binary `floci-aws-linux-arm64-baseline`; see [Native binary](../getting-started/installation.md#native-binary).## Reusable Image Publishingdiff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.mdindex 6d126f0735..52a6343107 100644--- a/docs/getting-started/installation.md+++ b/docs/getting-started/installation.md@@ -51,6 +51,120 @@ services:Standard and compat have identical startup time (~24 ms) and memory footprint (~13 MiB). On Raspberry Pi 4-class ARM64 CPUs that lack LSE, use `floci/floci:latest-baseline` (or a pinned `x.y.z-baseline` release).+## Native binary++Every release attaches a standalone executable for each platform to its+[GitHub release](https://github.com/floci-io/floci/releases), so Floci runs with no Docker at all. The+Linux binaries are the same native builds the image ships; the macOS and Windows ones are built on+their own runners and are not in any image.++| Platform | Asset |+|---|---|+| Linux x86_64 | `floci-aws-linux-amd64` |+| Linux arm64 | `floci-aws-linux-arm64` |+| Linux arm64 without LSE (Raspberry Pi 4 and older) | `floci-aws-linux-arm64-baseline` |+| macOS Apple Silicon | `floci-aws-darwin-arm64` |+| macOS Intel | `floci-aws-darwin-amd64` |+| Windows x86_64 | `floci-aws-windows-amd64.exe` |++```bash+VERSION=x.y.z # the release to install+ASSET=floci-aws-linux-amd64+curl -fsSLO "https://github.com/floci-io/floci/releases/download/$VERSION/$ASSET"+curl -fsSLO "https://github.com/floci-io/floci/releases/download/$VERSION/sha256sums.txt"+sha256sum --ignore-missing -c sha256sums.txt # shasum -a 256 --ignore-missing -c on macOS+mkdir -p ~/.local/bin+install -m 755 "$ASSET" ~/.local/bin/floci-aws+~/.local/bin/floci-aws+```++Add `~/.local/bin` to your `PATH` to start it as plain `floci-aws`.++The binary is named `floci-aws` because `floci` is the [CLI](https://github.com/floci-io/floci-cli).++### Verifying a download++Each asset has a keyless [cosign](https://docs.sigstore.dev/) bundle and a GitHub build-provenance attestation:++```bash+curl -fsSLO "https://github.com/floci-io/floci/releases/download/$VERSION/$ASSET.sigstore.json"+cosign verify-blob "$ASSET" --bundle "$ASSET.sigstore.json" \+ --certificate-identity-regexp '^https://github.com/floci-io/floci/.github/workflows/release.yml@' \+ --certificate-oidc-issuer https://token.actions.githubusercontent.com+gh attestation verify "$ASSET" --repo floci-io/floci+```++### Requirements++- **Linux:** glibc 2.34 or newer (RHEL 9, Ubuntu 22.04, Debian 12, Amazon Linux 2023). Older distributions+ (RHEL 8, Amazon Linux 2) and musl-based ones such as Alpine cannot run it; use the image there.+- **macOS:** a binary downloaded with a browser is quarantined by Gatekeeper. Clear it once with+ `xattr -d com.apple.quarantine floci-aws`. Downloads made with `curl` are not quarantined.+- **Docker is optional.** Without it every service that does not run containers works as usual. The+ container-backed ones keep their control plane but start no containers (RDS, ElastiCache, MemoryDB,+ OpenSearch, Neptune, DocumentDB, MSK, EKS, Timestream for InfluxDB, and EC2, whose instances run with no+ SSH, user data or SSM commands unless security-group enforcement is on, which makes a launch fail), or+ fail the request that needs one (Lambda, ECS, CodeBuild, Batch, SageMaker, AppSync JavaScript resolvers, Pipes with Kafka+ sources, MWAA, Amazon MQ, Managed Flink, Redshift, Redshift Serverless, the RDS Data API, Athena, the ECR+ registry, CodeArtifact, Verified Permissions). Floci logs one+ warning at startup naming the affected services when Docker is unreachable. With Docker, the binary finds+ the daemon the way the Docker CLI does: `DOCKER_HOST`, then the active Docker context (Docker Desktop,+ OrbStack, Colima, Podman), then the default socket.++### Where state goes++The binary listens on `127.0.0.1:4566` (the image listens on `0.0.0.0` inside its container, so a+published port reaches it). Like the image, it keeps state in memory. When persistence is turned on+(`FLOCI_STORAGE_MODE=persistent`, `hybrid` or `wal`), state goes to your user data directory rather+than the working directory:++| Platform | Default path |+|---|---|+| Linux | `$XDG_DATA_HOME/floci-aws`, or `~/.local/share/floci-aws` |+| macOS | `~/Library/Application Support/floci-aws` |+| Windows | `%LOCALAPPDATA%\floci-aws` |++`FLOCI_STORAGE_PERSISTENT_PATH` overrides it. Containers the binary starts are named with the namespace+`host-<port>`, so they do not collide with an image or with a second binary on another port sharing the+same Docker daemon. Binaries on separate hosts that use the same port and the same remote daemon share+that namespace: give each its own `FLOCI_DOCKER_RESOURCE_NAMESPACE`.++The state directory is not per port, though. Two binaries with persistence on need their own+`FLOCI_STORAGE_PERSISTENT_PATH` each, or they write the same state files. Restart a persistent binary on+the port it used before: on another port it reads its resources back, but their containers belong to the+old namespace, so container-backed resources (an RDS database, an ElastiCache cluster) come back without+their data.++### Configuring it++The binary reads the same settings as the image: `FLOCI_*` environment variables, `-D` system properties+(`floci-aws -Dfloci.port=4567`), or a `config/application.yml` in the directory it starts from. LocalStack+variables such as `PERSISTENCE` and `EDGE_PORT` are translated as described in+[Migrate from LocalStack](./migrate-from-localstack.md). Init hooks are read from+`FLOCI_INIT_HOOKS_DIR` (see [Initialization Hooks](../configuration/initialization-hooks.md)); on Windows,+`.ps1`, `.cmd` and `.bat` hooks run natively.++### Running it as a service++A systemd user unit, for example `~/.config/systemd/user/floci-aws.service`:++```ini+[Unit]+Description=Floci AWS emulator++[Service]+ExecStart=%h/.local/bin/floci-aws+Environment=FLOCI_STORAGE_MODE=persistent+Restart=on-failure++[Install]+WantedBy=default.target+```++Enable it with `systemctl --user enable --now floci-aws`. On macOS, a launchd agent in+`~/Library/LaunchAgents` with `ProgramArguments` pointing at the binary and `RunAtLoad` set does the same.+Floci stops cleanly on `SIGTERM`, so either service manager can stop it.+## Build from Source### Prerequisitesdiff --git a/src/main/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReport.java b/src/main/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReport.javaindex cc3ca203de..ee6b62569d 100644--- a/src/main/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReport.java+++ b/src/main/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReport.java@@ -13,6 +13,7 @@ import org.jboss.logging.Logger;import java.util.List;import java.util.Optional;import java.util.Set;+import java.util.stream.Stream;/*** Says once, at startup, what an unreachable Docker daemon costs.@@ -32,11 +33,11 @@ public class DockerAvailabilityReport {/** Ping Docker, report and carry on: their control plane works without a container. */static final List<String> METADATA_ONLY = List.of("rds", "elasticache", "memorydb", "opensearch", "neptune", "docdb", "msk", "eks",- "timestreaminfluxdb");+ "timestreaminfluxdb", "ec2");/** Run a container per request and fail that request (or its build, task, job) without Docker. */static final List<String> FAIL_ON_USE = List.of(- "lambda", "ecs", "ec2", "codebuild", "batch", "sagemaker", "appsync", "pipes", "mwaa",+ "lambda", "ecs", "codebuild", "batch", "sagemaker", "appsync", "pipes", "mwaa","amazonmq", "kinesisanalytics", "redshift", "redshift-serverless", "rds-data", "athena", "ecr","codeartifact", "verifiedpermissions");@@ -60,7 +61,7 @@ public class DockerAvailabilityReport {void report() {Set<String> enabled = Set.copyOf(serviceRegistry.getEnabledServices());- List<String> metadataOnly = METADATA_ONLY.stream().filter(enabled::contains).toList();+ List<String> metadataOnly = metadataOnly(enabled);List<String> failOnUse = failOnUse(enabled);if (metadataOnly.isEmpty() && failOnUse.isEmpty()) {return;@@ -76,14 +77,29 @@ public class DockerAvailabilityReport {metadataOnly, failOnUse);}+ List<String> metadataOnly(Set<String> enabled) {+ return METADATA_ONLY.stream()+ .filter(enabled::contains)+ .filter(service -> !needsDockerWhenConfigured(service))+ .toList();+ }+List<String> failOnUse(Set<String> enabled) {- return FAIL_ON_USE.stream()+ return Stream.concat(METADATA_ONLY.stream().filter(this::needsDockerWhenConfigured), FAIL_ON_USE.stream()).filter(enabled::contains).filter(service -> !runsWithoutLocalDocker(service)).map(service -> "pipes".equals(service) ? "pipes (Kafka sources)" : service).toList();}+ /**+ * A metadata-only service that a setting makes fail without Docker: with security-group+ * enforcement on, an EC2 launch with no daemon fails instead of running as metadata only.+ */+ boolean needsDockerWhenConfigured(String service) {+ return "ec2".equals(service) && config.network().securityGroupEnforcement().enabled();+ }+/** A service whose container work goes somewhere other than the local daemon. */boolean runsWithoutLocalDocker(String service) {return switch (service) {diff --git a/src/test/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReportTest.java b/src/test/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReportTest.javaindex cb6e05da13..b6d675c522 100644--- a/src/test/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReportTest.java+++ b/src/test/java/io/github/hectorvent/floci/lifecycle/DockerAvailabilityReportTest.java@@ -91,6 +91,22 @@ class DockerAvailabilityReportTest {assertThat(report.failOnUse(Set.of("lambda", "athena", "verifiedpermissions", "ecs")), contains("ecs"));}+ @Test+ void ec2RunsAsMetadataOnlyByDefault() {+ when(config.network().securityGroupEnforcement().enabled()).thenReturn(false);++ assertThat(report.metadataOnly(Set.of("ec2", "rds")), contains("rds", "ec2"));+ assertThat(report.failOnUse(Set.of("ec2", "ecs")), contains("ecs"));+ }++ @Test+ void ec2FailsOnUseWithSecurityGroupEnforcement() {+ when(config.network().securityGroupEnforcement().enabled()).thenReturn(true);++ assertThat(report.metadataOnly(Set.of("ec2", "rds")), contains("rds"));+ assertThat(report.failOnUse(Set.of("ec2", "ecs")), contains("ec2", "ecs"));+ }+@Testvoid pipesIsQualifiedToItsKafkaSources() {assertThat(report.failOnUse(Set.of("pipes")), contains("pipes (Kafka sources)"));