Commit Graph
9 Commits
Author SHA1 Message Date
Hector Ventura 9dcb1b65ae feat(core): translate LocalStack variables in Java instead of the entrypoint (#5851)
* feat(core): translate LocalStack variables in Java instead of the entrypoint

The LocalStack-to-Floci variable mapping (PERSISTENCE, EDGE_PORT,
LOCALSTACK_HOST, GATEWAY_LISTEN, LS_LOG/DEBUG, the Lambda and Docker
variables, the DNS suffixes, USE_SSL, CUSTOM_SSL_CERT_PATH) lived in
docker/localstack-parity.sh, sourced by the image's entrypoint. A JVM run or
a native binary on the host never saw it.

LocalStackParity now computes the same mapping and LocalStackParityConfigSource
serves it at ordinal 301, just above environment variables, as the exported
variables did. A key is produced only when its Floci variable is unset, so an
explicit Floci setting still wins; the DNS suffixes are still appended to any
configured ones; LOCALSTACK_PARITY=false still turns it all off.
TlsConfigSource, which reads its properties before the configuration exists,
consults the mapping too.

The script, its shell test and every Dockerfile copy of it are removed; the
test cases move to LocalStackParityTest.

Refs #5767

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(core): keep TLS backends on loopback, keep configured DNS suffixes, and pass LocalStack settings to hooks

Review follow-ups for the Java LocalStack translation:

- Dockerfile.compat took docker-entrypoint.sh from the published native
  image, which still sourced the removed localstack-parity.sh, so the compat
  image never became healthy. It now copies the entrypoint from the build
  context, as it already does healthcheck.sh.
- At ordinal 301 the parity source outranked TlsConfigSource's loopback pin
  (300): with TLS on and GATEWAY_LISTEN set, the backends bound the gateway
  address while the proxy dialled 127.0.0.1. It now sits at 299, below
  environment variables and the TLS source and above .env and
  config/application.yml, where the exported variables used to be.
- floci.dns.extra-suffixes is no longer a translated property, which on JVM
  and native runs replaced suffixes set in application.yml. The five
  readers append LocalStack's and Floci's suffixes to the configured list
  through LocalStackParity.withDnsSuffixes instead.
- GATEWAY_LISTEN=0.0.0.0:4566 (or [::]:4566, or a list) gives the host to
  quarkus.http.host and the port to floci.port when EDGE_PORT is unset,
  instead of a host Floci rejects as malformed.
- Init hooks get the translation as FLOCI_*/QUARKUS_* variables again, as
  they did when the entrypoint exported them.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(core): parse LOCALSTACK_HOST and GATEWAY_LISTEN the way LocalStack does

Both take LocalStack's host-and-port forms (HostAndPort.parse in its
config.py): host:port, host, :port, [v6]:port and [v6].

- LOCALSTACK_HOST is <hostname>:<port>, localhost.localstack.cloud:4566 by
  default. Its port went into floci.hostname, so the base URL came out as
  http://localhost.localstack.cloud:4566:4566. floci.hostname now gets the
  host alone.
- GATEWAY_LISTEN=:4566, LocalStack's default host on 4566, did not match
  and stopped startup with "Refusing to listen on malformed host". An empty
  host now keeps Floci's own bind address and takes just the port.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-10-17 17:37:15 -04:00
TiM 7e3ff3c5ee fix(docker): re-own the configured persistent path, not only /app/data (#4525)
* fix(docker): re-own the configured persistent path, not only /app/data

The entrypoint's root phase re-owned /app/data, while the writability probe
and the boot-time check both use FLOCI_STORAGE_PERSISTENT_PATH. A named volume
mounted at any other path arrived root-owned, the chown never reached it, and
with non-memory storage the container refused to start.

The root phase now re-owns the same directory the probe checks. The path is
resolved physically first and never re-owned when it resolves to /, since it
now comes from an environment variable.

* test(docker): make the chown helper prove the root phase completed

An empty chown log also results from a root phase that stops before the
privilege drop, so the 'skips a missing dir' case could pass for the wrong
reason. The helper now reports when the drop was never reached.

* fix(docker): resolve the persistent path without CDPATH

A relative FLOCI_STORAGE_PERSISTENT_PATH was resolved with cd, which searches
CDPATH and prints the directory it picks, so a set CDPATH could send the chown
to another directory or corrupt its argument. The resolution now clears it.
The test stub also records chown's full arguments, so the owner and the
recursive flag are asserted, not only the target.

* fix(docker): compare the persistent path to / by inode

bash keeps a leading // through cd -P and pwd -P, so the string test let
FLOCI_STORAGE_PERSISTENT_PATH=// reach a recursive chown on the native images,
which run bash as sh. -ef compares device and inode and holds in every shell,
and chown --preserve-root refuses / on its own as a second guard. The test
harness can now run the entrypoint under a chosen shell, and a bash case pins
the // spelling that dash alone cannot reach.
2026-09-28 22:57:18 -05:00
Niels Kootstra 1831f10105 fix(config): enforce safe default network binding (#3684)
* fix: enforce safe default network binding

* fix(config): keep signed test authority stable

Pin the integration-test listener to the existing all-interface test bind and
opt into that bind only in the test profile. This preserves localhost-based
SigV4 fixtures while production keeps the loopback default.

* fix(config): keep compat image backward compatible

* chore: retrigger CI

* fix(config): mirror JVM image network binding
2026-09-16 14:46:09 -04:00
Alexy Grabov d8e7382d5b fix(docker): allow explicit root for restricted sockets (#3558) 2026-09-13 19:35:01 -05:00
Hector Ventura b0a8dff206 perf(docker): drop the gosu layer and two no-op native-image inputs (#3037)
The native image's tools layer installed shadow-utils, which ubi9-minimal
9.7 already ships, and downloaded a gosu binary: 19 MB on disk, 3.66 MB
compressed, byte-identical on every release since 1.5.34. The entrypoint
still starts as root and still grants the bind-mounted Docker socket's
group to the floci user, but through coreutils, which the base image has:
`chroot --userspec=1001:0 --groups=0,<socket gid> --skip-chdir /` drops to
uid 1001 with the socket's gid as a supplementary group. The group is
passed by number, so no /etc/group entry is needed, and --skip-chdir keeps
/app as the working directory where the relative ./data paths resolve. The
layer is now 24.6 kB (one useradd). The JVM Dockerfile drops its gosu
download too: the entrypoint is shared, so once it execs chroot nothing
there calls gosu. Floci's release and nightly pipelines never publish that
image; build-images.yml is a reusable workflow a fork invokes to publish its
own copy, and its noble base carries the same coreutils chroot flags.

Two inputs to the native build go with it, neither changing a byte:
--allow-incomplete-classpath and --report-unsupported-elements-at-runtime
have been no-ops since GraalVM 22.1 (Quarkus passes --link-at-build-time
itself, so a missing reachable class already fails the build), and the
brotli4j platform JNI jars are excluded from quarkus-rest-jackson because
Floci never enables Brotli compression and the jar was never embedded
(resource count unchanged at 197). A native build without them produces
the same 232.25 MB image and the same reachable set.

Verified on the arm64 image: uid=1001 gid=0; a socket owned by gid 999
yields groups=0,999 end to end; /app/data writable; argv fallthrough
intact; sdk-test-java compat suite 1,667/1,667 against the native image
with the socket mounted.
2026-09-04 22:30:28 -04:00
Hector Ventura fe49bee41e fix(s3): fail fast on unwritable data root instead of opaque 500s (#1868)
When the persistent path is not writable (read-only or root-owned bind
mounts), S3Service's constructor failed lazily and every S3 request
surfaced as an opaque plain-text 500 that REST-XML SDK parsers cannot
read.

- validate the persistent path at boot and refuse to start with an
  actionable error when any enabled service uses non-memory storage
- add class-scoped exception mappers so unhandled failures on S3 and
  S3-Control routes render the S3 InternalError XML contract instead of
  Quarkus's plain-text error page
- warn loudly from the container entrypoint when the state dir is not
  writable by the runtime user

Fixes #1664
2026-07-15 00:43:11 -04:00
TomDav28 3b03b1363c fix(docker): fall back to the default command when entrypoint argv is empty (#1283) 2026-06-10 07:40:05 -05:00
Hector Ventura 023880b7d9 feat(parity): LocalStack drop-in compatibility (#696)
- Translate LocalStack env vars (LOCALSTACK_HOST, PERSISTENCE, LAMBDA_DOCKER_NETWORK, etc.)
  to Floci equivalents automatically at startup; opt out with LOCALSTACK_PARITY=false
- Serve /_localstack/init and /_localstack/health alongside /_floci/* equivalents
- Report executed scripts with path, state, and return_code in /_floci/init response
- Add /_aws/sqs/messages GET (non-destructive peek) and DELETE (purge) inspection endpoint
- Add /_aws/execute-api/{apiId}/{stageName} LocalStack-compat path for REST API invocation
- Add four-phase init hook lifecycle (boot/start/ready/stop) with dual-path discovery
  (/etc/floci/init/ and /etc/localstack/init/ compat paths)
- Install Python 3, AWS CLI, boto3 in standard image; wrap aws binary to pre-configure
  --endpoint-url=http://localhost:4566 so init scripts need no extra flags
- Wire entrypoint.sh + gosu privilege drop into all Dockerfile variants
- Add migration guide and update README, docker-compose, docker-images, SQS, and
  initialization-hooks docs
2026-05-04 01:15:59 -05:00
Conor Heine 43e9ca18a0 fix(docker): make bind-mounted /var/run/docker.sock work on all hosts (#602)
The published images run as USER 1001 with primary group root. On Docker
Desktop (macOS/Windows) /var/run/docker.sock is owned root:root inside
containers so the floci process can open it via the group-0 bit, but on
native Linux Docker (and Rootless/Podman) the socket is owned by
root:<docker-group> with mode 660 — and the floci user is not a member
of that group. This silently breaks ECR, Lambda, and RDS service
emulation on those hosts: floci's docker-java client gets BindException
/ SocketException and reports CREATE_FAILED on AWS::ECR::Repository.

Fix: ship a docker/entrypoint.sh modeled on the docker-library/postgres
pattern. It starts as root, stats the bind-mounted socket to learn the
host's docker GID, ensures a group with that GID exists, adds the floci
user to it, then `exec gosu floci` re-execs the same script as uid 1001
with the supplementary group set. The 'if id -u == 0' guard means
downstream `user:` overrides in compose files keep working unchanged.

Verified end-to-end on native Linux (Pop!_OS, docker GID 999) using a
minimal CDK bootstrap repro: AWS::ECR::Repository goes from CREATE_FAILED
to CREATE_COMPLETE and the registry:2 sidecar comes up cleanly. pid 1
runs as Uid:1001 Gid:0 Groups:999.

Implementation notes:
- All three Dockerfiles keep their original base images
  (quarkus-micro-image, ubi9-minimal, eclipse-temurin alpine).
- Dockerfile.native gains a tools builder stage that uses the canonical
  Red Hat pattern (`dnf install --installroot`) to install shadow-utils
  into a stagable /toolsroot, which the runtime stage wholesale-copies
  into quarkus-micro-image. Image growth: ~42 MB (quarkus-micro has no
  package manager and lacks groupadd/usermod by itself).
- Dockerfile.native-package adds shadow-utils via microdnf (already had
  the package manager).
- Dockerfile.jvm-package adds shadow + ca-certificates via apk so the
  entrypoint can use the same useradd/groupadd/usermod syntax across
  all three image variants.
- gosu 1.17 is downloaded and SHA256-pinned (rather than GPG-verified
  as Postgres does) to avoid pulling gnupg2 into the runtime layers
  and to sidestep a gpgme dependency conflict in ubi9-minimal.
2026-04-25 14:09:11 -05:00