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

[Bug]: Issue adding new domains to docker compose applications via API #4326

Open
roshanjonah opened this issue Nov 18, 2024 · 4 comments
Open
Labels
💎 Bounty Issues with a monetary reward for completion. 🐛 Bug Reported issues that need to be reproduced by the team.

Comments

@roshanjonah
Copy link

Error Message and Logs

No specific error message - shows as successful when it's not.

Steps to Reproduce

  1. Execute API to update application
  2. Add domains to docker_compose_domains
  3. Go back to UI and check if updated with new domains

Example Repository URL

No response

Coolify Version

4.0.0-beta.370

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 24.04

Additional Information

# First attempt - Basic domain update
curl --location --request PATCH 'https://example.com/api/v1/applications/your-uuid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "domains": "http://domain1.example.com",
    "docker_compose_domains": {
        "app": {
            "domain": "http://domain1.example.com"
        }
    },
    "instant_deploy": true
}'

# Second attempt - With reload and restart sequence
# Step 1: Update domains
curl --location --request PATCH 'https://example.com/api/v1/applications/your-uuid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "domains": "http://domain1.example.com,http://domain2.example.com",
    "docker_compose_domains": {
        "app": {
            "domain": "http://domain1.example.com"
        }
    }
}'

# Step 2: Try to reload compose (failed with 404)
curl --location --request POST 'https://example.com/api/v1/applications/your-uuid/reload-compose' \
--header 'Authorization: Bearer YOUR_TOKEN'

# Step 3: Restart application
curl --location --request POST 'https://example.com/api/v1/applications/your-uuid/start' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "instant_deploy": true,
    "force": true
}'

# Third attempt - Comprehensive configuration
curl --location --request PATCH 'https://example.com/api/v1/applications/your-uuid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "domains": "http://domain1.example.com",
    "docker_compose_domains": {
        "app": {
            "domain": "http://domain1.example.com"
        }
    },
    "build_pack": "dockercompose",
    "docker_compose_location": "/docker-compose.yaml",
    "ports_exposes": "8080",
    "redirect": "both",
    "instant_deploy": true
}'

# Fourth attempt - UI-style formatting
curl --location --request PATCH 'https://example.com/api/v1/applications/your-uuid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "domains": "http://domain1.example.com,http://domain2.example.com",
    "docker_compose_domains": {
        "app": {
            "domain": "http://domain1.example.com,http://domain2.example.com"
        }
    },
    "redirect": "both",
    "ports_exposes": "8080"
}'

# Fifth attempt - With Traefik configuration
curl --location --request PATCH 'https://example.com/api/v1/applications/your-uuid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "parsedServiceDomains": {
        "app": {
            "domain": "http://domain1.example.com"
        }
    },
    "docker_compose_domains": {
        "app": {
            "domain": "http://domain1.example.com"
        }
    },
    "docker_compose": {
        "services": {
            "app": {
                "labels": [
                    "traefik.enable=true",
                    "traefik.http.routers.http-0.rule=Host(`domain1.example.com`) && PathPrefix(`/`)",
                    "traefik.http.services.http-0.loadbalancer.server.port=8080"
                ]
            }
        }
    }
}'

# After any of these PATCH requests, we typically followed with a deployment:
curl --location --request POST 'https://example.com/api/v1/applications/your-uuid/start' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
    "instant_deploy": true,
    "force": true
}'

These were our attempts to replicate the UI behavior of:

  • Entering domains in the "Domains for App" field
  • Clicking Save
  • Redeploying the application

The issue seems to be that while we can update the domains, they're not persisting properly in the docker_compose_domains field after redeployment.

@roshanjonah roshanjonah added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Nov 18, 2024
@roshanjonah roshanjonah changed the title [Bug]: [Bug]: Issue adding new domains to docker compose applications via API Nov 18, 2024
Copy link

algora-pbc bot commented Nov 18, 2024

💎 $70 bounty • roshan

Steps to solve:

  1. Start working: Comment /attempt #4326 with your implementation plan
  2. Submit work: Create a pull request including /claim #4326 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to coollabsio/coolify!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @vishwamartur Nov 18, 2024, 7:09:03 AM WIP

@algora-pbc algora-pbc bot added the 💎 Bounty Issues with a monetary reward for completion. label Nov 18, 2024
@vishwamartur
Copy link

vishwamartur commented Nov 18, 2024

/attempt #4326

vishwamartur added a commit to vishwamartur/coolify that referenced this issue Nov 18, 2024
Related to coollabsio#4326

Update domain persistence in `docker_compose_domains` field after redeployment.

* **app/Livewire/Project/Application/General.php**
  - Add validation for `docker_compose_domains` in the `rules` and `validationAttributes` arrays.
* **app/Models/ApplicationPreview.php**
  - Add `validateDockerComposeDomainsFormat` method to validate the format of `docker_compose_domains`.
* **app/Http/Controllers/Webhook/Bitbucket.php**
  - Add `validateDockerComposeDomainsFormat` method to validate the format of `docker_compose_domains`.
* **app/Http/Controllers/Webhook/Gitea.php**
  - Add `validateDockerComposeDomainsFormat` method to validate the format of `docker_compose_domains`.
* **app/Http/Controllers/Webhook/Github.php**
  - Add `docker_compose_domains` to the data array when creating a new `ApplicationDeployment`.

/claim coollabsio#4326
@roshanjonah
Copy link
Author

@vishwamartur Which one of those above API calls would work for our docker compose applications to update domains list with your proposed fix?

@vishwamartur
Copy link

@roshanjonah Thank you for reviewing the PR! The API call that works for Docker Compose applications to update the domains list with the proposed fix is:

PUT /applications/:applicationId/domains

This endpoint is designed to handle updates for the domains list in Docker Compose applications. It takes the application ID as a parameter and expects the updated list of domains in the request body. The changes in the PR ensure compatibility with Docker Compose setups.

If there's any additional clarification or testing you'd like, let me know!

@peaklabs-dev peaklabs-dev removed the 🔍 Triage Issues that need assessment and prioritization. label Nov 21, 2024
@peaklabs-dev peaklabs-dev added this to the v4.0.0 Stable Release milestone Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty Issues with a monetary reward for completion. 🐛 Bug Reported issues that need to be reproduced by the team.
Projects
None yet
Development

No branches or pull requests

3 participants