Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerize the appliaction #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rgallor
Copy link
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

Copy link

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
README.md Show resolved Hide resolved
@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

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/cli.rs Outdated Show resolved Hide resolved
src/main.rs Outdated
@@ -51,6 +52,13 @@ async fn main() -> eyre::Result<()> {
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

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
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
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>
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
3 participants