Files
floci/docker/Dockerfile.jvm-package
T
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

92 lines
4.0 KiB
Docker

# JVM image built from an artifact that already exists on the host:
# ./mvnw package -DskipTests && docker build -f docker/Dockerfile.jvm-package -t floci/floci:dev .
#
# The counterpart to Dockerfile.native-package, for the JVM runtime: same idea, same reason. It
# exists for the local loop: docker/Dockerfile runs Maven inside the build, which re-resolves every
# dependency and wants a couple of gigabytes, so iterating on a change through it is slow and can
# fall over on a machine with little headroom. Consuming target/quarkus-app takes seconds.
#
# Everything below the FROM is a copy of the runtime stage of docker/Dockerfile, which is the
# canonical definition. Exactly two lines differ, both by design: the default VERSION, and where
# the application directory is copied from. DockerfileRuntimeParityTest enforces that, so a change
# to the canonical runtime stage fails the build here until it is mirrored.
FROM eclipse-temurin:25-jre-noble
ARG VERSION=dev
ENV FLOCI_VERSION=${VERSION}
ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data
ENV AWS_DEFAULT_REGION=us-east-1
ENV AWS_ACCESS_KEY_ID=test
ENV AWS_SECRET_ACCESS_KEY=test
ENV AWS_CONFIG_FILE=/etc/floci/aws/config
# Privilege drop happens in the entrypoint through coreutils chroot, so no gosu
# download.
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates passwd python3 python3-pip wget; \
rm -rf /var/lib/apt/lists/*; \
pip3 install --no-cache-dir --break-system-packages awscli boto3; \
aws_bin="$(command -v aws)"; \
mv "$aws_bin" /usr/bin/aws.real; \
printf '#!/bin/sh\nexec /usr/bin/aws.real --endpoint-url=http://localhost:4566 "$@"\n' > /usr/bin/aws; \
chmod +x /usr/bin/aws; \
useradd -r -u 1001 -g root -d /app -s /sbin/nologin floci
WORKDIR /app
# cli_follow_urlparam: the bundled CLI is v1 (pip ships no v2), where a parameter value that looks
# like a URL is *fetched* and its body used as the value. An init hook putting an SSM parameter such
# as MY_API_URL=https://example.com then fails with "Unable to retrieve https://…", and a hook that
# backgrounds its calls loses that silently. AWS CLI v2 dropped the behaviour, so this only shows up
# in the image, never when the same script is run from a host with v2.
RUN mkdir -p /app/data /etc/floci/aws \
&& printf '[default]\nendpoint_url = http://localhost:4566\ncli_follow_urlparam = false\n' > /etc/floci/aws/config \
&& chown 1001:root /app \
&& chmod "g+rwX" /app \
&& chown 1001:root /app/data
COPY target/quarkus-app/ quarkus-app/
RUN chown -R 1001:root /app/quarkus-app
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY --chmod=755 docker/healthcheck.sh /usr/local/bin/
VOLUME /app/data
EXPOSE 4566
# Need to expose separately due to https://github.com/floci-io/floci/issues/2095.
# This preseres compatibility with https://github.com/docker-java/docker-java/blob/002b6eb7aa2b892be729c7c2a5e95f782924db38/docker-java-api/src/main/java/com/github/dockerjava/api/model/ExposedPort.java#L119
EXPOSE 6379
EXPOSE 6380
EXPOSE 6381
EXPOSE 6382
EXPOSE 6383
EXPOSE 6384
EXPOSE 6385
EXPOSE 6386
EXPOSE 6387
EXPOSE 6388
EXPOSE 6389
EXPOSE 6390
EXPOSE 6391
EXPOSE 6392
EXPOSE 6393
EXPOSE 6394
EXPOSE 6395
EXPOSE 6396
EXPOSE 6397
EXPOSE 6398
EXPOSE 6399
# Probe every 50 ms while Floci starts, so a wait for "healthy" ends right after startup instead of
# at the first 5 s check. The start period must stay above the 5 s fallback in healthcheck.sh.
# Docker Engine before 25.0 ignores --start-interval when it runs the image, and cannot build this file.
HEALTHCHECK --interval=5s --timeout=3s --retries=5 --start-period=10s --start-interval=50ms CMD ["/usr/local/bin/healthcheck.sh"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# A published port needs 0.0.0.0 inside the container, which Floci only accepts with explicit consent.
CMD ["java", "--enable-native-access=ALL-UNNAMED", "-Dquarkus.http.host=0.0.0.0", "-Dfloci.security.allow-unsafe-network-exposure=true", "-jar", "/app/quarkus-app/quarkus-run.jar"]