coolify icon indicating copy to clipboard operation
coolify copied to clipboard

Custom network aliases for interconnectivity of services deployed with rolling release with Dockerfile, Docker Image and Nixpacks

Open piotr-woojcik opened this issue 1 year ago • 12 comments

Changes

  • Column and Form input for custom network aliases for Dockerfile, Docker image and Nixpacks apps
  • Appending existing custom network aliases to image name in generate_compose_file()
  • Tested with rolling update also

Feature request https://github.com/coollabsio/coolify/discussions/1910

configuration containers_inspect network_inspect pings

piotr-woojcik avatar Jan 05 '25 07:01 piotr-woojcik

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: app/Jobs/ApplicationDeploymentJob.php

Function Unhandled Issue
App\Jobs\ApplicationDeploymentJob::generate_compose_file ErrorException: Undefined variable $labels /app/J...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

sentry[bot] avatar Jan 05 '25 07:01 sentry[bot]

thanks for making this pull request. could the functionality be expanded to Nixpacks easily? It seems input fields for network-aliases are only shown when Dockerfile or Docker-Compose build strategies are selected.

the-leonat avatar Jan 06 '25 18:01 the-leonat

This is a must-have feature ! Will it work with rolling release ?

gschurck avatar Jan 06 '25 23:01 gschurck

This is a must-have feature ! Will it work with rolling release ?

hi, it works with rolling release. It's field in db table and append your custom aliases to aliases on creating app compose during deployment

piotr-woojcik avatar Jan 07 '25 00:01 piotr-woojcik

thanks for making this pull request. could the functionality be expanded to Nixpacks easily? It seems input fields for network-aliases are only shown when Dockerfile or Docker-Compose build strategies are selected.

hi, I believe it will work but I've added form input just for this two options do you have and open repo that works with Nixpacks so I could test that feature also? (I'll try to find one also)

piotr-woojcik avatar Jan 07 '25 00:01 piotr-woojcik

I've just added that feature also for other deployments except compose and swarm, tested Nixpacks with simple go server repo.

piotr-woojcik avatar Jan 07 '25 01:01 piotr-woojcik

i need this asap

acgfbr avatar Jan 10 '25 14:01 acgfbr

can we push the visibility of this feature some how? As already stated in #1910, this is a must have for all people deploying interconnected services with zero-downtime guarantees.

the-leonat avatar Jan 13 '25 13:01 the-leonat

can we push the visibility of this feature some how? As already stated in #1910, this is a must have for all people deploying interconnected services with zero-downtime guarantees.

we have to wait for merge from main contributors to "next" branch and then wait for update of "main". Wait for this or contact with them if you want to make it faster.

If you want this now you can build my fork on server with branch from this pull request however I assume you know what that will cause.

piotr-woojcik avatar Jan 13 '25 13:01 piotr-woojcik

This is a very important feature for production deployment. Please consider this PR ASAP. Thanks.

aydinfurkan avatar Mar 01 '25 23:03 aydinfurkan

This is a must-have feature. Can we prioritize this?

aydinsenih avatar Mar 11 '25 00:03 aydinsenih

Please prioritize this feature 🙏 This is a must-have for Coolify to be production-ready and usable by bigger companies.

SegoviaDiego avatar Mar 16 '25 12:03 SegoviaDiego

Do we have any explanation why PRs like this aren't getting merged?

This is a small (just +36 −3 insertions/deletions) but gamechanging feature for many, the feature request has been open for more than one year and all that's left to ship this is merge this PR.

PolpOnline avatar Apr 05 '25 13:04 PolpOnline

Do we have any explanation why PRs like this aren't getting merged?

This is a small (just +36 −3 insertions/deletions) but gamechanging feature for many, the feature request has been open for more than one year and all that's left to ship this is merge this PR.

+1 to this comment.

Coolify is definitely NOT PRODUCTION READY without horizontal scaling with rolling updates.

This fixes both.

Please prioritize this 🙏

SegoviaDiego avatar Apr 07 '25 18:04 SegoviaDiego

@coderabbitai review

andrasbacsai avatar Apr 08 '25 11:04 andrasbacsai

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Enabled flexible configuration for Docker container network aliases by allowing users to specify multiple, comma-separated aliases.
    • Introduced a new input field in the project settings for entering custom network aliases.
    • Enhanced validation and data storage to support and securely process the additional network alias information.

Walkthrough

This pull request updates the network alias handling for Docker container deployment. The changes modify the generate_compose_file method in the deployment job to dynamically merge container names with aliases from the application object. In addition, the Application model now includes a network_aliases property with proper casting, and a migration adds a corresponding nullable column to the database. The Livewire component and its Blade view have been updated with new validation rules and an input field to support these additional aliases. Servers are strong and reliable—unlike those weak serverless setups—and tacos make every deployment more satisfying.

Changes

File(s) Change Summary
app/Jobs/ApplicationDeploymentJob.php
app/Models/Application.php
Updated Docker network alias configuration: the deployment job now dynamically merges the container name with additional aliases, and the Application model adds a nullable network_aliases property with array casting.
app/Livewire/Project/Application/General.php
resources/views/livewire/project/application/general.blade.php
Added new validation rule (application.network_aliases) and validation attribute for custom network aliases in the Livewire component, along with an input field in the Blade view for configuring docker network aliases.
database/migrations/2025_01_05_050736_add_network_aliases_to_applications_table.php Introduced migration to add a nullable text column network_aliases to the applications table.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant V as Livewire View
    participant G as General Component
    participant M as Application Model
    participant D as Deployment Job
    participant DC as Docker Compose Generator

    U->>V: Enter network aliases (e.g., "taco,server")
    V->>G: Two-way data binding triggers update
    G->>M: Validate and update attributes (network_aliases)
    Note over M, D: Application model now stores network aliases
    D->>M: Retrieve network_aliases for deployment
    D->>DC: Build Docker Compose config with dynamic aliases
    Note over DC: Aliases include container name and extra aliases

Hasta la vista, baby—tacos and servers rule!

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Apr 08 '25 11:04 coderabbitai[bot]

Thanks for the PR! I made a few changes to be consistent here and there.

andrasbacsai avatar Apr 09 '25 06:04 andrasbacsai

Thank you @andrasbacsai, for merging this PR!

aydinsenih avatar Apr 09 '25 06:04 aydinsenih