bcc-code / directus-schema-sync

The better way to sync your Directus schema and data between environments
Apache License 2.0
90 stars 4 forks source link

Need a bit more of an idiots guide to install this: #3

Open DangerDrome opened 8 months ago

DangerDrome commented 8 months ago

Describe the Improvement

Making a better, step by step installation guide. For example:

Docker install

Step 1

    build:
      context: ./

Step 2

FROM directus/directus:latest

USER root
RUN corepack enable \
 && corepack prepare pnpm@8.9.0 --activate

USER node
RUN pnpm install directus-extension-schema-sync
COPY ./schema-sync ./schema-sync
COPY ./extensions ./extensions

Step 3

Step 4:

[+] Building 3.3s (8/9)                                                                                                                                 docker:default
 => [directus internal] load .dockerignore                                                                                                                        0.2s
 => => transferring context: 2B                                                                                                                                   0.0s
 => [directus internal] load build definition from Dockerfile                                                                                                     0.1s
 => => transferring dockerfile: 268B                                                                                                                              0.0s
 => [directus internal] load metadata for docker.io/directus/directus:latest                                                                                      1.7s
 => CACHED [directus 1/5] FROM docker.io/directus/directus:latest@sha256:92df34786069cc29cf1c7b65f274ff19439dfef02f59f545eb7a62ea6ca8e70f                         0.0s
 => [directus internal] load build context                                                                                                                        0.1s
 => => transferring context: 32B                                                                                                                                  0.0s
 => CANCELED [directus 2/5] RUN corepack enable  && corepack prepare pnpm@8.9.0 --activate                                                                        1.0s
 => CACHED [directus 3/5] RUN pnpm install directus-extension-schema-sync                                                                                         0.0s
 => ERROR [directus 4/5] COPY ./schema-sync ./schema-sync                                                                                                         0.0s
------
 > [directus 4/5] COPY ./schema-sync ./schema-sync:
------
failed to solve: failed to compute cache key: failed to calculate checksum of ref be5a7c65-2ff9-4bdf-bee5-1e16e87afaac::3159k3jw6023qiwp16d661hi1: "/schema-sync": not found

Ok, let's try NPM instead...

NPM Install

Step 1

Run npm install directus-extension-schema-sync in some directory somewhere

Step 2

Then run npx schema-sync install to install the extension's migration and config files, but not the actual extention files? Does this need to be cp'ed manually?

Step 3

Run npx directus database migrate:latest from any random location to run the migration that will add required columns to the... Oh Snap!

ERROR: "DB_CLIENT" Environment Variable is missing.

u12206050 commented 8 months ago

Hi there, thanks for the feedback and detailed explanation.

From your feedback I gather you don't run Directus as an npm package locally, so installing it directly via npm and installing won't work, since Directus isn't running locally. Was is of interest to me is the Dockerfile setup not working.

There is a current issue by extending the Directus with custom extensions via Docker, but a fix is one the way.

Maybe you could help me decide how we can improve installation. We need the following to take place.

  1. The extension needs to be loaded by Directus (either installed via pnpm in Docker, or npm if running Docker locally)
  2. The database columns used for tracking need to be added to the database. (Updated this to run via a Directus cli command directus schema-sync install)
  3. The folder with the configuration files needs to be copied, preferably outside of the Docker container so that it can be persisted.

Any ideas? :)

DangerDrome commented 7 months ago

I'm not too sure of the best approach, I think Docker should be the main focus and potentially providing one compose yaml or Dockerfile config that does everything?

In regards to the extension gui functionality it would be great if there was a list of objects to sync with Boolean checkboxes and then a button that says 'push' and another that says 'pull'? This may already be the case however I am not able to get the extension to run so I am not sure what it looks like.

The inability to sync or backup directus by default is a major drawback and your extension potentially solves this so it would be great to get it working as a one click install or something with a super simple gui along with it.

notflip commented 5 months ago

I have to second this, I have no idea how to use this repository. But I would love to try it out! Thanks

u12206050 commented 5 months ago

The issue regarding installing npm packages with the Directus docker image has been fixed since 10.8.3

Could you tell me where you feel the current Readme gets confusing or doesn't add up with what you expect.

notflip commented 5 months ago

Thanks @u12206050, I'm not sure what to do with

# This is for when building for production
COPY ./schema-sync ./schema-sync

Should we include it in our Dockerfile or not? How can we set this so it only runs on production?

u12206050 commented 5 months ago

Yes include it. So, once you have the schema-sync folder in your source code and you want to build a container that will run in the cloud, then you have to copy the schema-sync folder into the docker container that is being built.

During development however you use docker-compose, and then the using volumns is enough since volumns allows two way sync, ie. when there is a change inside the container it is made on your host machine, and vice versa.

daronjay commented 3 months ago

Hi, Some config examples would be good, what's the syntax of that stuff, is it based on some other directus feature?

JayShoe commented 2 months ago

The database columns used for tracking need to be added to the database. (Updated this to run via a Directus cli command directus schema-sync install)

So if you can only do this via CLI, I guess this won't work on Directus Cloud? I'm not a DevOps person and I'm desperately trying to get up and running in production. I have a local setup but I can't seem to get the recipe straight for going live. I would pay the price for Cloud but even that doesn't solve my issue. Unless I'm (hopefully) wrong?? Does this plugin work in Directus Cloud?

u12206050 commented 2 months ago

Correct you need to have full control of the instance and be able to add/commit the schema sync folder. So this won't work on the Directus Cloud unless you have custom enterprise.