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

feat(docker): update Dockerfiles to use ENTRYPOINT instead of CMD #1016

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

Conversation

skrashevich
Copy link
Contributor

  • Added a new entrypoint.sh script for dynamic configuration and validation of environment variables, improving container startup flexibility.
  • Included yq utility in the base images to facilitate YAML file manipulation within the container, enhancing configuration management capabilities.
  • Specified --platform=linux/amd64 for base images to ensure consistent cross-platform builds, addressing potential compatibility issues on multi-architecture setups.

… cross-platform compatibility

- Updated Dockerfile and hardware.Dockerfile syntax to `docker/dockerfile:1.4` for enhanced features and performance.
- Introduced `--link` option in COPY commands to optimize layer caching and reduce image size.
- Added a new `entrypoint.sh` script for dynamic configuration and validation of environment variables, improving container startup flexibility.
- Included `yq` utility in the base images to facilitate YAML file manipulation within the container, enhancing configuration management capabilities.
- Specified `--platform=linux/amd64` for base images to ensure consistent cross-platform builds, addressing potential compatibility issues on multi-architecture setups.
- Modified ENTRYPOINT to utilize the new entrypoint script, enabling pre-execution configuration checks and setting a default configuration if none is provided.
- The addition of `yq` and changes to the entrypoint mechanism provide a more robust and user-friendly setup process, potentially affecting existing workflows that rely on manual configuration file adjustments.

These changes aim to improve maintainability, efficiency, and user experience by leveraging newer Docker features, automating configuration tasks, and ensuring broader compatibility across different computing environments.
@AlexxIT
Copy link
Owner

AlexxIT commented Apr 20, 2024

Why we need to create config file? User can set default port just via command line
https://github.com/AlexxIT/go2rtc/wiki/Configuration

@skrashevich
Copy link
Contributor Author

because of without config file:
image

Also, listening to the port given by the PORT environment variable is good practice, this is the expected behavior of the applications in serverless environments, for example

@AlexxIT AlexxIT self-assigned this Apr 22, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Apr 29, 2024

Config file is not set - error only when user set config as string. It's planned behaviour.

@AlexxIT AlexxIT added the doubt label Apr 29, 2024
@AlexxIT AlexxIT removed their assignment Apr 29, 2024
@skrashevich
Copy link
Contributor Author

Config file is not set - error only when user set config as string. It's planned behaviour.

anyway, other reasons still significant:

  • support PORT env var (ok, I can refactor entrypoint.sh to use it in cli arg instead of config)
  • it's a more correct way, allowing the user in the docker run command to add their own cli arguments

@AlexxIT
Copy link
Owner

AlexxIT commented May 1, 2024

  1. Env vars supported inside config file
  2. Config supported inside command line

Both this instruments can be used to set port

@skrashevich
Copy link
Contributor Author

  1. Env vars supported inside config file
  2. Config supported inside command line

Both this instruments can be used to set port

This all requires a separate configuration from user, not a default behavior for go2rtc container

@AlexxIT
Copy link
Owner

AlexxIT commented May 1, 2024

No. 2nd can be used in raw docker compose file. Without any file config

- Removed `yq` installation from Dockerfile to reduce image size.
- Simplified default configuration file creation in entrypoint.sh by directly writing YAML content, eliminating the need for `yq`.
- Removed `yq` installation step from hardware.Dockerfile and adjusted file copying accordingly.
Simplify the entrypoint script by removing the creation of a default configuration file if it doesn't exist. Instead, directly pass the default API listen port configuration to the `go2rtc` command, while still allowing custom configurations through the existing `CONFIG_PATH`. This change ensures that the service can start with default settings without needing to write them to a file, simplifying deployment and configuration management.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants