coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
33.45k stars 1.81k forks source link

[Bug]: Docker compose from git repository does not recognize database services #1738

Closed GringoDotDev closed 1 week ago

GringoDotDev commented 8 months ago

Description

If you deploy a docker-compose.yaml as part of a git repository deployment, it doesn't seem to recognize things like mysql or redis as the database subtype. This means that you can't access things like database backups, etc.

This is a difference in behavior between pasting in the same docker-compose as part of the non-git workflow.

Let's take a simple example, let's say your docker compose looks like this:

version: '3.8'

services:
    mysql:
        image: mysql:8.3
        environment:
          MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-rootpassword}"
          MYSQL_DATABASE: "${DB_DATABASE:-laravel_db}"
          MYSQL_USER: "${DB_USER:-laravel_user}"
          MYSQL_PASSWORD: "${DB_PASSWORD:-laravel_pass}"
        volumes:
          - mysql_data:/var/lib/mysql
        healthcheck:
          test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${DB_USER:-laravel_user}", "--password=${DB_PASSWORD:-laravel_pass}" ]
          interval: 5s
          retries: 10
          timeout: 2s
volumes:
  mysql_data:

If you paste that into the git-less deploy flow, the docker-compose will come out like this for the mysql container (excluding networks, volumes, etc. for brevity):

  mysql:
    image: 'mysql:8.3'
    environment:
      MYSQL_ROOT_PASSWORD: '${DB_ROOT_PASSWORD:-rootpassword}'
      MYSQL_DATABASE: '${DB_DATABASE:-laravel_db}'
      MYSQL_USER: '${DB_USER:-laravel_user}'
      MYSQL_PASSWORD: '${DB_PASSWORD:-laravel_pass}'
    volumes:
      - 'g0o0c8o_mysql-data:/var/lib/mysql'
    healthcheck:
      test:
        - CMD
        - mysqladmin
        - ping
        - '-h'
        - localhost
        - '-u'
        - '${DB_USER:-laravel_user}'
        - '--password=${DB_PASSWORD:-laravel_pass}'
      interval: 5s
      retries: 10
      timeout: 2s
    networks:
      g0o0c8o: null
    labels:
      - coolify.managed=true
      - coolify.version=4.0.0-beta.213
      - coolify.serviceId=8
      - coolify.type=service
      - coolify.name=mysql-g0o0c8o
      - coolify.pullRequestId=0
      - coolify.service.subId=7
      - coolify.service.subType=database
    restart: unless-stopped
    container_name: mysql-g0o0c8o

But if you set up an app using a git repo, the same compose will come out like this:

  mysql:
    image: 'mysql:8.3'
    environment:
      MYSQL_ROOT_PASSWORD: '${DB_ROOT_PASSWORD:-rootpassword}'
      MYSQL_DATABASE: '${DB_DATABASE:-laravel_db}'
      MYSQL_USER: '${DB_USER:-laravel_user}'
      MYSQL_PASSWORD: '${DB_PASSWORD:-laravel_pass}'
    volumes:
      - 'mysql_data:/var/lib/mysql'
    healthcheck:
      test:
        - CMD
        - mysqladmin
        - ping
        - '-h'
        - localhost
        - '-u'
        - '${DB_USER:-laravel_user}'
        - '--password=${DB_PASSWORD:-laravel_pass}'
      interval: 5s
      retries: 10
      timeout: 2s
    networks:
      rg0s0k0: null
    labels:
      - coolify.managed=true
      - coolify.version=4.0.0-beta.213
      - coolify.applicationId=22
      - coolify.type=application
      - coolify.name=mysql-rg0s0k0-195343739031
      - coolify.pullRequestId=0
    restart: unless-stopped
    container_name: mysql-rg0s0k0-195343739031

Not sure if it's the root cause, but notice the difference in the labels applied to the containers.

Net-net, instead of having a dashboard that looks like this:

image

With the ability to manage your db services like this:

image

You instead end up with this:

image

I'm motivated to get this fixed since it would unblock some cool deployment workflows for us (that I would also like to publicize on Youtube). I'm a pretty good Laravel dev but don't know this codebase particularly well. If you point me in the right direction I'm happy to make an attempt at a PR.

Thank you!

Minimal Reproduction (if possible, example repository)

Exception or Error

No response

Version

v4.0.0-beta.213

AlejandroAkbal commented 7 months ago

Happening to me too, would love to see this, it's such a great quality of life

AlejandroAkbal commented 5 months ago

Hey @andrasbacsai, could you take a look at this issue? I think it could be easily fixed since it already works on compose only deployments

It would be specially important for teams that want to back up their database to S3 in git + docker compose deployments

peaklabs-dev commented 1 week ago

This is more of a feature request, so I am moving this to a GitHub discussion (as this has not been implemented). This will be included in the full backup manager that will be coming in the future.