#I want to use directus in my project. And we have the requirement to build extensions

25 messages Β· Page 1 of 1 (latest)

deft sleet
#

Should i need to fork the project
or create the project via npm for deployment

Which method should be useful for my scenario?||

young hare
#

I'd recommend sticking with the docker image

deft sleet
young hare
deft sleet
#

thanks Tim

deft sleet
#

Suppose if i am creating directus project via npm for development
In this scenario how to build the base project in my local. Any idea on this?
i have tried 'npm run build'. It is looking for src folder. But if we create via npm we wont have src folder.

#

In document they have provided run command - npm directus start

young hare
#

i have tried 'npm run build'. It is looking for src folder. But if we create via npm we wont have src folder.
Are you talking about an extension here? you should have a src folder if you've followed the docs

deft sleet
#

Not about extension.
Instead of using directus docker image
I have created the project using 'npm init directus-project directus' . In this case src folder will not be available in the project structure.
https://docs.directus.io/self-hosted/quickstart.html
So how to build the project that is created via npm ?

young hare
deft sleet
#

i tried by running - npm run build

My package.json file
"scripts": {
"build": "react-scripts build"
}
Got this error:

Could not find a required file.
Name: index.js
😣

young hare
#

Not sure where that package.json came from but that is not part of Directus πŸ€” We don't use React. Perhaps using docker for local development works better for you πŸ™‚

#

It looks like you're confusing some different aspects of running directus πŸ™‚ i'd recommend doing it 1 step at a time, first setup a directus instance/project, once that works start looking into setting up your extensions.

deft sleet
#

is this a proper link for setup a new directus project ?

young hare
#

It is πŸ™‚ after step 1 you should have a running directus

deft sleet
#

yes directus is running properly in local πŸ™‚

But, for prod deployment i need to build a docker image from this project

Dockerfile
ARG NODE_VERSION=16-alpine
FROM node:${NODE_VERSION}
WORKDIR /directus
COPY . .
RUN yarn install
EXPOSE 8055
CMD ["yarn", "directus", "start"]

Here i am copying the entire directus project (COPY . .) . Instead of that i need to copy only build folder.
I am facing an issue while building this project in local (command used: npm run build)

young hare
#

you cannot build a docker image from a production npm installation, you'd need to build from source for that

deft sleet
#

got it πŸ˜€ .Thanks Tim for your help
Is this a suggested way?
And since it is open source, if the latest docker image contains any vulnerability. That should be handled manually?

young hare
#

My suggested way is to not bother with NPM and stick with the docker image (build on top of that if need be) πŸ˜ƒ If the latest docker image contains a vulnerability please let us know so we can fix that for everyone instead of manually monkey patching the code (or shoot us a PR at least) πŸ˜‰

deft sleet
#

sure Tim πŸ™‚ . Thanks a lot

deft sleet
#

Hi Tim. You have any sample project for reference (using directus docker image)?