Skip to content
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

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

Open
DangerDrome opened this issue Nov 7, 2023 · 13 comments
Open

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

DangerDrome opened this issue Nov 7, 2023 · 13 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@DangerDrome
Copy link

DangerDrome commented Nov 7, 2023

Describe the Improvement

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

Docker install

Step 1

  • Edit your docker compose file (usually docker-compose.yml)
  • Under "directus:", remove:
image: directus/directus:10.x.x
  • Replace with:
    build:
      context: ./

Step 2

  • Now create a file in the same directory (ideally the root directory of your directus install) and name it "Dockerfile".
  • Edit "Dockerfile" to read like this:
FROM directus/directus:latest

USER root
RUN corepack enable \
 && corepack prepare [email protected] --activate

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

  • Save the "Dockerfile"

Step 3

  • Run the command:
docker compose build

Step 4:

  • Oh snap! it's not working...
[+] 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 [email protected] --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
Copy link
Member

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? :)

@u12206050 u12206050 added documentation Improvements or additions to documentation question Further information is requested labels Nov 7, 2023
@DangerDrome
Copy link
Author

DangerDrome commented Nov 8, 2023

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
Copy link

notflip commented Jan 11, 2024

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

@u12206050
Copy link
Member

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
Copy link

notflip commented Jan 16, 2024

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
Copy link
Member

u12206050 commented Jan 16, 2024

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
Copy link

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

@JayShoe
Copy link

JayShoe commented Apr 20, 2024

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
Copy link
Member

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.

@BorisKamp
Copy link

I second this. This looks like a great repo to export schema, flows etc, but I have no clue how to use it.... I want to use it locally to export flows and let my colleagues import those flows for example. And to version the schema of the directus project in GIT.

I use Directus using Docker but I have no clue how to set this up locally... A better how-to would be nice (-:

@donos-63
Copy link

Hello,

I agree, I don't understand how to use this, and I'm not sure It will work with flows.

@u12206050
Copy link
Member

The latest update 3.0.2 will export an initial schema snapshot and data files based on the default config settings when you first run directus schema-sync install

Ensure to first install the extension on your local environment and then export the schema and data. This will create the necessary files for the extension to work. Only once you have the files can you update your .env file with the SCHEMA_SYNC variable.

@jonathan-chin
Copy link

I just spent an hour or so last night trying to get this to work, specifically through creating my own docker image.

could you put together an example, bare bones setup needed to get it running?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants