Skip to content

Containerize the appliaction#13

Merged
harlem88 merged 10 commits intoastarte-platform:masterfrom
rgallor:feat/docker
May 12, 2025
Merged

Containerize the appliaction#13
harlem88 merged 10 commits intoastarte-platform:masterfrom
rgallor:feat/docker

Conversation

@rgallor
Copy link
Copy Markdown
Collaborator

@rgallor rgallor commented Sep 9, 2024

Make it possible to build a Docker container of the application and set all the necessary config files and environment variables to connect it to a running Astarte instance.

Closes #2

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Project coverage is 4.5%. Comparing base (7db1595) to head (baedef3).

Files with missing lines Patch % Lines
src/shutdown.rs 0.0% 10 Missing ⚠️
src/astarte.rs 0.0% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/astarte.rs 8.7% <0.0%> (ø)
src/shutdown.rs 0.0% <0.0%> (ø)

@rgallor rgallor force-pushed the feat/docker branch 7 times, most recently from 60dc443 to 1639b7f Compare September 20, 2024 13:17
@rgallor rgallor force-pushed the feat/docker branch 3 times, most recently from 33f11c8 to 1d2b0cc Compare October 4, 2024 15:19
@rgallor rgallor force-pushed the feat/docker branch 4 times, most recently from abace5f to 7499604 Compare November 27, 2024 11:18
@rgallor rgallor force-pushed the feat/docker branch 2 times, most recently from 262d342 to ff94107 Compare November 29, 2024 15:20
@rgallor rgallor force-pushed the feat/docker branch 2 times, most recently from fb179b9 to ed2deff Compare December 3, 2024 10:00
@rgallor rgallor mentioned this pull request Dec 3, 2024
@lucaato
Copy link
Copy Markdown

lucaato commented Dec 3, 2024

As wrongly commented on the next pr. I think that we should set a default location only when running in docker to make the command needed to run the application from the docker hub smaller.
I think that most people that want to quickly run the stream rust will do it from the docker hub when the image will be available there

src/main.rs Outdated
if let Err(err) = astarte_cfg_builder.try_from_env() {
warn!("failed to retrieve Astarte connection config from ENV: {err}");

#[cfg(feature = "docker")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the feature you could use an .unwrap_or_default invoked only when the feature is docker.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, since astarte_config_path is an optional parameter you can use a default value if it is not provided and since the docker feature is only used here it can be removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done some modification to the code to avoid retrieving the path from the CLI. Still, to provide flexibility (to change the comfig.toml path) i maintained the env variable ASTARTE_CONFIG_PATH, which is retrievable only if containers are not used. If it is not set, the default path /etc/stream-rust-test/ is used

Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
In this commit:
- Define scripts, env file and Dockerfile to build and run the container
- Get astarte config from env vars
- Add dependabot checks for docker
- Update Readme with the information to build and run a docker container

Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
Gracefully shut down all the active tasks when SIGINT or SIGTERM
signals are received.

Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
…fig.toml

If the application is run using the container, the config.toml config
file location is set to /etc/stream-rust-test/, otherwise it can be
modified by using the ASTARTE_CONFIG_PATH env variable

Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
rgallor added 5 commits May 12, 2025 14:51
Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
@rgallor rgallor force-pushed the feat/docker branch 3 times, most recently from 6e09b55 to a221368 Compare May 12, 2025 14:32
…ents

Signed-off-by: Riccardo Gallo <riccardo.gallo@secomind.com>
@harlem88 harlem88 merged commit a6a855b into astarte-platform:master May 12, 2025
12 of 13 checks passed
@rgallor rgallor deleted the feat/docker branch May 12, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Dockerfile and custom entrypoint

4 participants