ddev / ddev-minio

MinIO addon for DDEV
Apache License 2.0
5 stars 0 forks source link

ddev minio post start /usr/bin/mc commands #23

Closed douggreen closed 11 months ago

douggreen commented 11 months ago

Where can I add a post start command to create a minio bucket. This runs in the webserver container and fails.

hooks:
  post-start:
    - exec mc mb minio/files

Before I upgraded to the latest minio, I think I had t working in .ddev/docker-compose.minio-z.yaml services. I'm not sure where I got this code. I don't know this uses /bin/sh. I don't think I need the "anonymous" line, but it was something I tried while trying to figure out https://github.com/oblakstudio/ddev-minio/issues/18. It is named -z to so that it runs last; again, I'm not sure that is necessary, but I originally named it -custom and it seems to work when I renamed it -z.

  createbuckets:
    image: minio/mc
    depends_on:
      - minio
    entrypoint: >
      /bin/sh -c "
      /usr/bin/mc mb minio/files;
      /usr/bin/mc anonymous set public minio/files
      exit 0;
      "
rfay commented 11 months ago

When you're doing a hook that doesn't run in the default web container, you have to specify the service. So

hooks:
  post-start:
    - exec: mc mb minio/files
      service: minio

See https://ddev.readthedocs.io/en/latest/users/configuration/hooks/#supported-tasks for examples that show doing something in the db container.

douggreen commented 11 months ago

Is there maybe an order issue.

service "minio" has neither an image nor a build context specified: invalid compose project

I have in my config.yaml:

hooks:
  post-start:
  - exec: mc mb minio/files
    service: minio

Yet if I run

ddev service enable minio
Service minio already enabled, see docker-compose.minio.yaml
douggreen commented 11 months ago

Closing this, @rfay's suggestion works on my bare bones setup (but not on my actual project's setup), which suggest that something is wrong with my project ???

seebeen commented 11 months ago

Doug, I'll check on our end as well.

rfay commented 11 months ago

If you're using this add-on, then there's a service named minio. Take a look at your docker-compose.minio.yaml.

I don't think you want to use ddev service enable though, it's kind of been left behind. If you did a ddev get oblakstudio/ddev-minio then you'd have a minio service.