N
Novuβ€’2y ago
balance

Why do we copy the env file?

# Get the code
git clone --depth 1 https://github.com/novuhq/novu

# Go to the docker folder
cd novu/docker

# Copy the example env file
cp .env.example ./local/deployment/.env

# Start Novu
docker-compose -f ./local/deployment/docker-compose.yml up
# Get the code
git clone --depth 1 https://github.com/novuhq/novu

# Go to the docker folder
cd novu/docker

# Copy the example env file
cp .env.example ./local/deployment/.env

# Start Novu
docker-compose -f ./local/deployment/docker-compose.yml up
What's the point of copying the env file?
12 Replies
Novu_Bot
Novu_Botβ€’2y ago
@balance, you just advanced to level 1!
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
balance
balanceβ€’2y ago
https://github.com/novuhq/novu/tree/main/docker teh readme here is outdated, the docker compose command won't work like that. Also the reason I ask about why we move the env file is: We don't provide a context, so . is the context, so the .env file we copy is never used. Or am I missing something? resp. it's the readme for the main branch yet the git clone command clones the next branch.
--
--β€’2y ago
next branch is the default branch where all the work is being merged. It is the branch deployed in our Dev environment but not in Production. It is discouraged to use the next branch into a Production environment. main branch used to be the branch with the functionality that next branch has now. Please open an issue for fixing the documentation if you think that is misleading how is explained right now. Which docker compose file are you trying to run from the 2 folders we have? Also to add that the Docker and K8s implementation is community driven so we can't offer full support unfortunately.
balance
balanceβ€’2y ago
I just try to get the API working. I follow the README on the github. Meaning:
# Get the code
git clone https://github.com/novuhq/novu

# Go to the docker folder
cd novu/docker

# Copy the example env file
cp .env.example ./local/deployment/.env

# Start Novu
docker-compose -f ./local/deployment/docker-compose.yml up
# Get the code
git clone https://github.com/novuhq/novu

# Go to the docker folder
cd novu/docker

# Copy the example env file
cp .env.example ./local/deployment/.env

# Start Novu
docker-compose -f ./local/deployment/docker-compose.yml up
The API endpoint keeps giving me a 401 which isn't surprising, since apparently the host it uses is 'Host', 'api.novu.co'? Althought none of the env vars in the container define that.
--
--β€’2y ago
api.novu.co is the fallback URL for the Notification Center and the CLI tool when the URL is not provided. I can only think in the first one being used by you, but I might be wrong, so let me try to get more information of what you are doing. Are you running the docker compose file from /docker/local/development/docker-compose.development.yml?
balance
balanceβ€’2y ago
<partly solved> Ah, interesting, thanks for that info! So chances are, I'm doing something simple wrong. Here's what I do (I pruned everything for a clean slate): 1. git@github.com:novuhq/novu.git => using the next branch. 2. Following the readme on https://github.com/novuhq/novu/tree/next/docker 2.1 cd novu/docker 2.2 cp .env.example ./local/deployment/.env 2.3 docker-compose -f ./local/deployment/docker-compose.yml up (again, step 2.2 is to my knowledge useless since 2.3 uses a different context, might be wrong though, doesn't matter anyway) Result: localhost:4200 works 3. I sign out because it seems I still have a login session cache. 4. I sign in again (I didn't prune the volumes) 5. I run curl -d "@user.json" -H "Authorization: ApiKey e0dc75817c0770773f66d990398d9ba2" -H "Content-Type: application/json" -X POST http://localhost:3000/v1/subscribers 6. works 7. I do a similar curl to /events/trigger and while I get errors because my payload isn't correct, it does communicate with the locally running API. 8. So if I try what I did before, using a js file, I get the issue with the fallback host. So I guess, my js is bad:
const { Novu } = require('@novu/node');

const novu = new Novu('e0dc75817c0770773f66d990398d9ba2');

novu.trigger('test',
{
to: {
subscriberId: 'asdasdasd',
email: 'email@email.com',
firstName: 'John',
lastName: 'Doe',
},
payload: {
customVariables: 'Hello'
},
transactionId: 'transactionId',
}
);
const { Novu } = require('@novu/node');

const novu = new Novu('e0dc75817c0770773f66d990398d9ba2');

novu.trigger('test',
{
to: {
subscriberId: 'asdasdasd',
email: 'email@email.com',
firstName: 'John',
lastName: 'Doe',
},
payload: {
customVariables: 'Hello'
},
transactionId: 'transactionId',
}
);
I changed it a bit, compare it to https://docs.novu.co/api/trigger-event/ so I can run it as a simple script. So I guess my problem is kinda solved and my JS skills just suck.
--
--β€’2y ago
If you share your JS file implementation I can try to help you to spot the problem. But I am glad that as a script it works. I am sure your JS skills are not that bad. πŸ™‚
Dima Grossman
Dima Grossmanβ€’2y ago
A small question, regarding the trigger, did you tried passing the config object as stated here: https://docs.novu.co/overview/docker-deploy#triggering-events-with-custom-installation ? because the defaults goes to the cloud version when not passed πŸ™
balance
balanceβ€’2y ago
I might if I'm not able to solve it. THanks
Novu_Bot
Novu_Botβ€’2y ago
@balance, you just advanced to level 2!
balance
balanceβ€’2y ago
thanks! I remember that I saw some config warning but figured it's some default thing that has nothing to do with Novu directly. I'll check it out