Dokploy / dokploy

Open Source Alternative to Vercel, Netlify and Heroku.
https://dokploy.com/
Other
4.24k stars 229 forks source link

Autodeploy for docker images #164

Open Rattlyy opened 4 days ago

Rattlyy commented 4 days ago

What problem will this feature address?

Would love to see this feature, would be very useful :)

Describe the solution you'd like

Poll the registry for updates on X seconds or if a webhook system exists use that.

Describe alternatives you've considered

Github Actions, but sometimes I prefer to deploy straight from my pc so a registry autodeploy would be better.

Additional context

No response

Siumauricio commented 4 days ago

Hi, we support webhooks for dockerhub to automatically deploy when you push a new image

https://docs.dokploy.com/en/docs/core/application/overview#auto-deploy

Rattlyy commented 4 days ago

@Siumauricio ghcr?

Siumauricio commented 4 days ago

Researching looks like you can send a webhook on registry package, would you mind to try to use the webhooks in Github? Screenshot 2024-06-24 at 11 12 01 PM

Siumauricio commented 3 days ago

@Rattlyy

It seems that it is not possible with the current implementation, but there is another solution, which is to use the API directly I leave you the steps

  1. Go to settings -> profile -> view api swagger
  2. Find the endpoint /project.all -> open the disclosure and click on run
  3. this will show you all your projects with their applications and so on.
  4. Find the application you want to deploy and copy the applicationId.
  5. Then there will be 2 enpoints one to mark that the application is doing build that is called /application.markRunning and the other one is /application.deploy. the one of /application.markRunning is purely something visual it is so that the status of the application changes to a yellow state (Running),
  6. Now it will be necessary to integrate those 2 endpoints in a CI/CD that is where I assume you are doing push to the registry.

the first request would look like this

curl -X 'POST' \
  https://your-dokploy-domain/api/trpc/application.markRunning' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
"json":{
   "applicationId": "YOUR-APPLICATION-ID"
  }
}'

and then comes the one that does the deploying

curl -X 'POST' \
  'https://your-dokploy-domain/api/trpc/application.deploy' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
"json":{
   "applicationId": "YOUR-APPLICATION-ID"
  }
}'

don't forget to generate the TOKEN to have access to the API and put your dokploy-domain

So your CI/CD should be something like this

name: Deploy Application

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Mark Application Running
      run: |
        curl -X 'POST' \
        'https://your-dokploy-domain/api/trpc/application.markRunning' \
        -H 'accept: application/json' \
        -H 'Authorization: Bearer YOUR-TOKEN' \
        -H 'Content-Type: application/json' \
        -d '{
        "json":{
           "applicationId": "YOUR-APPLICATION-ID"
          }
        }'

    - name: Deploy Application
      run: |
        curl -X 'POST' \
        'https://your-dokploy-domain/api/trpc/application.deploy' \
        -H 'accept: application/json' \
        -H 'Authorization: Bearer YOUR-TOKEN' \
        -H 'Content-Type: application/json' \
        -d '{
        "json":{
           "applicationId": "YOUR-APPLICATION-ID"
          }
        }'