Skip to content

Upload latest schema on startup? #153

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

Open
NilsBaumgartner1994 opened this issue Feb 7, 2025 · 5 comments
Open

Upload latest schema on startup? #153

NilsBaumgartner1994 opened this issue Feb 7, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@NilsBaumgartner1994
Copy link

Is your feature request related to a problem? Please describe.
I would like to always upload the latest schema when i am about to start my remote servers.

Describe the solution you'd like
A small folder where it uses it to automatically push the schema from.

Describe alternatives you've considered
A script which waits for directus to boot up and then to upload the schema.

Additional context
Great work of your project. Realy hope to see it come directly from directus.

@EdouardDem EdouardDem added the enhancement New feature or request label Feb 10, 2025
@EdouardDem
Copy link
Member

Hi @NilsBaumgartner1994
I had few feature requests similar to this one.
I was thinking to add a command wait that would complete once the server is started (relying on the info endpoint of Directus).
This could be used along with other commands, like this:

npx directus-sync wait --interval 5 --timeout 60 && npx directus-sync push

Could this help for your use case ?

@NilsBaumgartner1994
Copy link
Author

I thought about a custom api hook which would start during the init server start hook.
And then maybe when completed and uploaded the new schema force the server instance to restart aka. Crash

@NilsBaumgartner1994
Copy link
Author

@EdouardDem i created in directus a feature request: directus/directus#24647

But is it possible for directus-sync to somehow be called before directus even starts? Like passing a path to the extension, where to find the latest schema?

@bgenia
Copy link
Contributor

bgenia commented May 11, 2025

If you're using docker compose you can deploy directus-sync as a separate container and make other services depend on it so they start only when configuration is uploaded.

Here's my setup:

services:
  directus:
    depends_on:
      database:
        condition: service_healthy

    healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "http://directus:8055/server/health"]

  directus-sync:
    environment:
      DIRECTUS_URL: http://directus:8055
      DIRECTUS_ADMIN_EMAIL: ${DIRECTUS_ADMIN_EMAIL}
      DIRECTUS_ADMIN_PASSWORD: ${DIRECTUS_ADMIN_PASSWORD}

    depends_on:
      directus:
        condition: service_healthy

  app:
    depends_on:
      directus-sync:
        condition: service_completed_successfully

directus-sync is just this:

FROM node:23-slim

RUN npm install --global directus-sync

WORKDIR /app

# You can mount a volume instead for development deploys
COPY ./configuration/directus /app/configuration/directus/ 

CMD ["npx", "directus-sync", "push", "--dump-path", "./configuration/directus"]

@NilsBaumgartner1994
Copy link
Author

If you're using docker compose you can deploy directus-sync as a separate container and make other services depend on it so they start only when configuration is uploaded.

Here's my setup:

services:
directus:
depends_on:
database:
condition: service_healthy

healthcheck:
  test: ["CMD", "wget", "--spider", "-q", "http://directus:8055/server/health"]

directus-sync:
environment:
DIRECTUS_URL: http://directus:8055
DIRECTUS_ADMIN_EMAIL: ${DIRECTUS_ADMIN_EMAIL}
DIRECTUS_ADMIN_PASSWORD: ${DIRECTUS_ADMIN_PASSWORD}

depends_on:
  directus:
    condition: service_healthy

app:
depends_on:
directus-sync:
condition: service_completed_successfully
directus-sync is just this:

FROM node:23-slim

RUN npm install --global directus-sync

WORKDIR /app

You can mount a volume instead for development deploys

COPY ./configuration/directus /app/configuration/directus/

CMD ["npx", "directus-sync", "push", "--dump-path", "./configuration/directus"]

Yes awesome that’s something that could work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants