Floci Dev Service
A service providing Floci, a free open-source local AWS emulator, for development and testing purposes.
It works with Spring Boot libraries that support AWS, including:
The Dev Service brings the core of Spring Cloud AWS with it, including its support for connecting to Floci. Add the Spring Cloud AWS starter of each AWS service your application uses, such as io.awspring.cloud:spring-cloud-aws-starter-s3: the AWS endpoint, region, and credentials of its clients are configured automatically.
|
Floci exposes a single HTTP endpoint for all emulated AWS services. When using Spring Cloud AWS S3, path-style access is enabled while the Floci Dev Service module is on the classpath, also when the application connects to an endpoint of its own instead of the Dev Service. |
Dependencies
First, you need to add the Dev Service dependency to your project.
-
Gradle
-
Maven
dependencies {
testAndDevelopmentOnly "io.arconia:arconia-dev-services-floci"
}
<dependency>
<groupId>io.arconia</groupId>
<artifactId>arconia-dev-services-floci</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
You can optionally include the Spring Boot DevTools dependency to enable live reload of your application during development.
-
Gradle
-
Maven
dependencies {
developmentOnly "org.springframework.boot:spring-boot-devtools"
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
|
When you use the Spring Boot DevTools in your project and run the application in dev mode, Arconia keeps the Dev Services running while you make changes to your code instead of restarting them with the application. This allows you to see the changes in real-time without having to restart the Dev Services. Changes to the configuration of a Dev Service take effect once you stop and start the application again. |
Running the Application
When using the Arconia Dev Services, you can keep running your application as you normally would. The Dev Services will automatically start when you run your application.
-
Gradle
-
Maven
-
CLI
./gradlew bootRun
./mvnw spring-boot:run
arconia dev
Unlike the lower-level Testcontainers support in Spring Boot, Arconia doesn’t require special tasks to run your application when using Dev Services (./gradlew bootTestRun or ./mvnw spring-boot:test-run) nor requires you to define a separate @SpringBootApplication class for configuring Testcontainers.
|
Your @SpringBootTest integration tests use the Dev Service with no additional configuration.
By default, each application starts its own Floci Dev Service. To let multiple applications running simultaneously in dev mode use the same one, set the arconia.dev.services.floci.reuse-strategy property to framework: the application connects to a running Floci Dev Service started by another application if available, or else starts its own that other applications can discover in turn. The applications using the same Dev Service must use the same region. Learn more about Reusing Dev Services.
Accessing the Floci UI
The application logs will show you the URL where you can access the Floci UI, a web console for browsing and managing the resources in the emulator.
...i.a.d.s.startup : Dev Service 'floci' is ready in container <container-id> (floci/floci, localhost:<port>)
...i.a.d.s.startup : Dev Service 'floci' links: Floci UI: http://localhost:<port>/_floci/ui
Floci runs the console in a container of its own, which it starts the first time you open the URL. The page waits for the console to be ready, which includes pulling its image the first time, and then takes you to it. The console container is removed together with the Dev Service.
The console is published on port 4500 of the host, so only one can run at a time. When several applications run their own Floci Dev Service, give each console a different port through the environment of the Dev Service:
arconia:
dev:
services:
floci:
environment:
FLOCI_SERVICES_UI_PORT: 4501
Alternatively, let the applications use the same Floci Dev Service, and therefore the same console, by setting the reuse-strategy property to framework.
|
Floci starts the console, and the containers it runs services like Lambda and RDS in, through the socket of the container runtime, which is mounted into the Floci container. On a host enforcing SELinux, such as a Podman machine, a confined container is denied access to that socket. The Dev Service therefore disables the SELinux label separation of the Floci container (the equivalent of |
Configuring the Dev Service
You can configure the Dev Service via configuration properties.
| Property | Default | Description |
|---|---|---|
|
|
Whether the dev service is enabled. |
|
|
Full name of the container image used in the dev service. |
|
|
Environment variables to set in the service. |
|
|
Additional hostnames the dev service container is reachable by on the shared network, next to the name of the dev service. Only applicable when the shared network is enabled. |
|
|
Fixed port for exposing the Floci port to the host. When it’s 0 (default), a random available port is assigned dynamically. |
|
|
Resources from the classpath or host filesystem to copy into the container. They can be files or directories that will be copied to the specified destination path inside the container at startup and are immutable (read-only). |
|
|
Strategy for reusing a running container for the dev service across applications or restarts. Only applicable in dev mode. See Reusing Dev Services. |
|
|
Maximum waiting time for the service to start, counted from the container start. |
|
|
Files or directories to mount from the host filesystem into the container. They are mounted at the specified destination path inside the container at startup and are mutable (read-write). Changes in either the host or the container will be immediately reflected in the other. |
Disabling the Dev Service
Set the arconia.dev.services.floci.enabled property to false to disable the Dev Service. To disable it in one mode only, use the profile Arconia activates for that mode (see Profiles), for example in an application-test.yml file to disable it in tests:
arconia:
dev:
services:
floci:
enabled: false
To disable it for a single test class, set the property with @SpringBootTest(properties = …) or @TestPropertySource. To disable all the Dev Services at once, set arconia.dev.services.enabled to false.