Node App Error--Failed ro replace env in config: ${NPM_TOKEN} - node.js

I am trying to build a Docker image for my Sails.js application. Here's the Dockerfile:
FROM risingstack/alpine:3.4-v8.5.0-4.7.0
ENV NODE_ENV test
RUN npm install -g sails
COPY npmrc_file .npmrc
ARG NPM_TOKEN
COPY package.json package.json
RUN npm install
RUN rm -f .npmrc
# Add your source files
COPY . .
EXPOSE 3000
CMD ["npm","start"]
I took the steps for this Dockerfile from this link on the NPM documentation site. I have made sure to match what the documentation there shows perfectly.
My docker build command is:
image="my-repo-url/tagname:tagversion"
docker build --build-arg NPM_TOKEN=my-token-goes-here -t $image -f Dockerfile .
Then I run the container with the image using docker stack or docker-compose. The container doesn't start up, due to the following error:
sails_1 | Error: Failed to replace env in config: ${NPM_TOKEN}
sails_1 | at /usr/lib/node_modules/npm/lib/config/core.js:418:13
sails_1 | at String.replace (<anonymous>)
sails_1 | at envReplace (/usr/lib/node_modules/npm/lib/config/core.js:414:12)
sails_1 | at parseField (/usr/lib/node_modules/npm/lib/config/core.js:392:7)
sails_1 | at /usr/lib/node_modules/npm/lib/config/core.js:335:17
sails_1 | at Array.forEach (<anonymous>)
sails_1 | at Conf.add (/usr/lib/node_modules/npm/lib/config/core.js:334:23)
sails_1 | at ConfigChain.addString (/usr/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
sails_1 | at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:322:10)
sails_1 | at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
sails_1 | /usr/lib/node_modules/npm/lib/npm.js:52
sails_1 | throw new Error('npm.load() required')
sails_1 | ^
sails_1 |
sails_1 | Error: npm.load() required
sails_1 | at Object.get (/usr/lib/node_modules/npm/lib/npm.js:52:13)
sails_1 | at process.errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:213:18)
sails_1 | at emitOne (events.js:115:13)
sails_1 | at process.emit (events.js:210:7)
sails_1 | at process._fatalException (bootstrap_node.js:399:26)
The thing is, by the time we get to running the container, there should be no reference to or need for the ${NPM_TOKEN}. I'm using this exact same setup in another project, and don't see this error, so I'm not really sure what the deal is. I have triple checked that everything is the same in this project as the other project.
What are the possible reasons for this error and some possible solutions?
I've also read through this thread and this SO question. I feel like everything I've read has pointed me to the same solution, which I've implemented, but with no success.

This is what worked for me in the end:
ARG NPM_TOKEN
ENV NPM_TOKEN="${NPM_TOKEN}"
Why this solved this issue, I'm not sure!

This is what I am using,
in Dockerfile
ARG NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN
ENV NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN
and in docker-compose.yml
version: '2'
services:
app:
build:
args:
- NPM_AUTH_TOKEN

Related

Nuxtjs app stops immediately when start with pm2

I am trying to run a nuxtjs app using pm2 however, the app exits immediately, and I could not get useful info from pm2 log:
2|frontend_nuxt | Error: ENOENT: no such file or directory, chdir '����' -> '/var/www/frontend_nuxt/releases/20210831071742'
2|frontend_nuxt | at wrappedChdir (node:internal/bootstrap/switches/does_own_process_state:112:14)
2|frontend_nuxt | at process.chdir (node:internal/worker:100:5)
2|frontend_nuxt | at /usr/local/share/.config/yarn/global/node_modules/pm2/lib/ProcessContainer.js:298:13
2|frontend_nuxt | at wrapper (/usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/internal/once.js:12:16)
2|frontend_nuxt | at next (/usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/waterfall.js:96:20)
2|frontend_nuxt | at /usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
2|frontend_nuxt | at WriteStream.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/pm2/lib/Utility.js:186:13)
2|frontend_nuxt | at WriteStream.emit (node:events:394:28)
2|frontend_nuxt | at node:internal/fs/streams:72:16
2|frontend_nuxt | at FSReqCallback.oncomplete (node:fs:185:23)
The nuxtjs app it self can start without issue.
I have no idea how to debug this error, or how to get more useful details, any idea?
using npm2 show id I found that the script path was not updated.
so, i just had to:
pm2 delete frontend_nuxt && pm2 start ecosystem.config.js
and all is well.

How to using docker-compose with environment

I have node application that build into an image. This image not contain .env file because I add it on .gitignore whereas the application need it. How can I configure this environment on docker-compose?
I've read some of example but still dont get it. This question has same problem with me but it still doesn't work.
docker-compose:
version: "3.7"
services:
node:
container_name: node-app
image: node_app:latest
ports:
- 3334:3333
environment:
- HOST=127.0.0.1
- PORT=3333
- NODE_ENV=dummy
- APP_NAME=AdonisJs
- CACHE_VIEWS=false
- DB_CONNECTION=mysql
- DB_HOST=127.0.0.1
- DB_PORT=3306
- DB_USER=root
- DB_PASSWORD=password
- DB_DATABASE=database
Dockerfile:
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm i -g #adonisjs/cli
RUN npm install
ENV HOST=0.0.0.0
COPY . .
EXPOSE 3333
CMD [ "node", "server.js" ]
Everytime I run docker-compose up its ended up with this.
WARNING: The HOST variable is not set. Defaulting to a blank string.
WARNING: The PORT variable is not set. Defaulting to a blank string.
Recreating node-app_node_1 ... done
Attaching to node-app_node_1
node_1 |
node_1 | Error: ENOENT: no such file or directory, open '/usr/src/app/.env'
node_1 |
node_1 |
node_1 | 1 Env.load
node_1 | /usr/src/app/node_modules/#adonisjs/framework/src/Env/index.js:110
node_1 |
node_1 | 2 new Env
node_1 | /usr/src/app/node_modules/#adonisjs/framework/src/Env/index.js:42
node_1 |
node_1 | 3 Object.closure
node_1 | /usr/src/app/node_modules/#adonisjs/framework/providers/AppProvider.js:29
node_1 |
node_1 | 4 Ioc._resolveBinding
node_1 | /usr/src/app/node_modules/#adonisjs/fold/src/Ioc/index.js:231
node_1 |
node_1 | 5 Ioc.use
node_1 | /usr/src/app/node_modules/#adonisjs/fold/src/Ioc/index.js:731
node_1 |
node_1 | 6 AppProvider.boot
node_1 | /usr/src/app/node_modules/#adonisjs/framework/providers/AppProvider.js:337
node_1 |
node_1 | 7 anonymous
node_1 | /usr/src/app/node_modules/#adonisjs/fold/src/Registrar/index.js:147
node_1 |
node_1 | 8 arrayMap
node_1 | /usr/src/app/node_modules/lodash/lodash.js:653
node_1 |
node-app_node_1 exited with code 1
All I know that docker-compose environment pass to the variable that called just as same as we define to get the value, but there is not .env file on the image to called the variable. What I have to do to make the docker-compose can pass the environment to the app? Any suggestion will be appreciated.
ENOENT indicates that node is looking for a file at /usr/src/app/.env but there is nothing there. Try adding
RUN touch /usr/src/app/.env
to your Dockerfile and see if having an empty .env file fixes it.

NPM - Failed to replace env in config: ${NPM_BASE64_USERNAME_PASSWORD}

I'm getting the error below whenever I try to execute anything in my terminal (e.g. npm test or npm install)
I've tried to follow steps similar laid out here - NPM - Failed to replace env in config: ${NPM_TOKEN}. I've also tried setting my username and (encoded) password in my .npmrc file, none of which appear to work for me.
Not really sure what else I should try here ....
Error: Failed to replace env in config: ${NPM_BASE64_USERNAME_PASSWORD}
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:415:13
at String.replace (<anonymous>)
at envReplace (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:411:12)
at parseField (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:389:7)
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:328:23)
at ConfigChain.addString (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
at Conf.<anonymous> (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:316:10)
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:123:16
/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/npm.js:59
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/npm.js:59:13)
at process.errorHandler (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/utils/error-handler.js:208:32)
at process.emit (events.js:375:28)
at process._fatalException (internal/process/execution.js:163:25)
Even, I had encounter the issue similar to thiis while pulling the node component from aws codeartifact via docker file. What you need to do is create a .nmprc file and drop it root location fo the npm installaiton, doing this your issue will get addressed. I was getting below exception while ruinnig npm install in docker file something like
Run powershell -command npm install or any anglar cli install via npm
"8 : RUN powershell -Command npm install
2022-03-03T19:16:34.2653417Z ---> Running in 97791ba93799
2022-03-03T19:16:44.2652033Z [91mError: Failed to replace env in config: ${env:CODEARTIFACT_AUTH_TOKEN}
2022-03-03T19:16:44.2652033Z at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:415:13
2022-03-03T19:16:44.2661894Z at String.replace ()
2022-03-03T19:16:44.2661894Z at envReplace (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:411:12)
2022-03-03T19:16:44.2661894Z at parseField (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:389:7)
2022-03-03T19:16:44.2661894Z at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:330:24
2022-03-03T19:16:44.2661894Z at Array.forEach ()
2022-03-03T19:16:44.2661894Z at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:328:23)"
Solution
please use this docker file, I was passing token from build file something like
Build.ps1
$env:CODEARTIFACT_AUTH_TOKEN = aws codeartifact get-authorization-token --domain se2codepkg --domain-owner 590427636078 --query authorizationToken --output text
docker.ps1
Run powershell echo "registry=https://se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/
//se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/:always-auth=true
//se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/:_authToken=${env:CODEARTIFACT_AUTH_TOKEN}">.npmrc
I got the idea by going through below link
https://developpaper.com/question/after-nodejs-is-installed-successfully-npm-cannot-run-and-prompt-failed-to-replace-env-in-config/

"Failed to load gRPC binary module" error when running a Sails.js application inside a Docker container

I have a local Docker developer environment to build a Sails.js application. This is what my Dockerfile looks like:
FROM node:8.12
LABEL Name=us.gcr.io/my-project/my-app Version=1.0.0
# Container configuration
RUN npm install -g sails#1.0.2 grunt#1.0.3 nodemon#1.18.4
WORKDIR /usr/src/app
COPY ./server/package.json ./package.json
RUN npm install
VOLUME /usr/src/app
EXPOSE 1337
This is what my docker-compose.yml file looks like:
version: '3.4'
services:
server:
image: us.gcr.io/my-project/my-app:latest
build: .
environment:
NODE_ENV: development
IS_DEV_MACHINE: "yes"
ports:
- 1338:1337 # HOST_PORT is 1339 to avoid conflicts with other Sails.js apps running on host
volumes:
- ./server:/usr/src/app
entrypoint: nodemon
mongodb:
image: mongo:4
ports:
- 27018:27017 # HOST_PORT is 27018 to avoid conflicts with other MongoDB databases running on host
volumes:
- ../database:/data/db
Normally, everything works fine however, I recently imported and initialised the #google-cloud/logging NPM package in my application and now, when I run docker-compose up, I get the following error:
server_1 | error: Bootstrap encountered an error: (see below)
server_1 | error: Failed to lift app: { Error: Failed to load gRPC binary module because it was not installed for the current system
server_1 | Expected directory: node-v57-linux-x64-musl
server_1 | Found: [node-v57-darwin-x64-unknown]
server_1 | This problem can often be fixed by running "npm rebuild" on the current system
server_1 | Original error: Cannot find module '/usr/src/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node'
server_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/grpc_extension.js:53:17)
server_1 | at Module._compile (module.js:653:30)
server_1 | at Object.Module._extensions..js (module.js:664:10)
server_1 | at Module.load (module.js:566:32)
server_1 | at tryModuleLoad (module.js:506:12)
server_1 | at Function.Module._load (module.js:498:3)
server_1 | at Module.require (module.js:597:17)
server_1 | at require (internal/module.js:11:18)
server_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/client_interceptors.js:145:12)
server_1 | at Module._compile (module.js:653:30)
server_1 | at Object.Module._extensions..js (module.js:664:10)
server_1 | at Module.load (module.js:566:32)
server_1 | at tryModuleLoad (module.js:506:12)
server_1 | at Function.Module._load (module.js:498:3)
server_1 | at Module.require (module.js:597:17)
server_1 | at require (internal/module.js:11:18) code: 'MODULE_NOT_FOUND' }
mongodb_1 | 2018-10-09T09:27:52.521+0000 I NETWORK [conn4] end connection 172.19.0.2:48730 (0 connections now open)
In the error above, "Bootstrap" is the bootstrap.js file in my Sails.js project that initialises #google-cloud/logging. This is how I am initialising the logger in bootstrap.js:
// Globally required packages
const { Logging } = require('#google-cloud/logging');
const logging = new Logging({ projectId: 'my-project' });
const logger = logging.log('test');
I just can't seem to figure out why this error is occurring. I even tried changing my base Docker image to the official Google App Engine Docker image (gcr.io/google-appengine/nodejs) and that did not help either. i can't find any solutions to this problem anywhere. Appreciate any help.
By any chance did you do a npm install on your local Mac (darwin) environment when it should have been done in the container (linux)? The grpc binary is for the wrong OS thus the error. This often happens with a local Mac running a linux Docker container.
Expected directory: node-v57-linux-x64-musl
Found: [node-v57-darwin-x64-unknown]
The solution would be to rm -fr node_modules and do npm install in the container.
Rebuild the app by the following command.
npm rebuild --target=8.1.0 --target_platform=linux --target_arch=x64 --target_libc=musl
It looks like the project is having difficulty finding dependencies such as the gRPC binary module (repaired with npm install grpc) or perhaps where they are currently located - more info here

Trying to dockerize Sails 1.0.2 with PostgreSQL, can't connect to DB by any means

I've been trying to dockerize a Sails 1.0.2 app to be able to run it locally with docker-compose, but it doesn't seem to be able to connect to PostgreSQL server by any means.
Also, I think I might be missing some concepts on how DB creation works with Sails. I've tried either model "safe" behaviour (for manual migrations), "alter" and "drop".
When running safe mode, I tried using sails-migrations db:create, or sails-migrations migrate in a separate task within the container to check if any of them would be necessary for setting up the database, even though I still have only a scaffold generated User.js model.
None of them seem to work. On the other way, the Docker database itself looks like it was created. Any help would be appreciated, thanks in advance.
Versions I'm using:
Sails: 1.0.2
PostgreSQL: 9.6
sails-migrations: 2.1.0
sails-postgresql: 1.0.0
File List:
docker-compose.yml
version: '2'
volumes:
postgres_data_dev: {}
postgres_backup_dev: {}
services:
postgres:
build: ./compose/postgres
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- postgres_backup_dev:/backups
environment:
- POSTGRES_USER=test_project
sails:
build:
context: .
dockerfile: ./compose/sails/Dockerfile
command: /start-dev.sh
depends_on:
- postgres
environment:
- POSTGRES_USER=test_project
- USE_DOCKER=yes
volumes:
- .:/app
ports:
- "8000:8000"
links:
- postgres
compose/sails/Dockerfile
FROM node:latest
RUN npm install -g sails grunt npm-check-updates
COPY ./package.json /package.json
RUN npm install
RUN npm install --save sails-postgresql
COPY ./compose/sails/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY ./compose/sails/start-dev.sh /start-dev.sh
RUN sed -i 's/\r//' /start-dev.sh
RUN chmod +x /start-dev.sh
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]
compose/sails/entrypoint.sh
#!/bin/bash
set -e
cmd="$#"
export REDIS_URL=redis://redis:6379
# the official postgres image uses 'postgres' as default user if not set explictly.
if [ -z "$POSTGRES_USER" ]; then
export POSTGRES_USER=postgres
fi
export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD#postgres:5432/$POSTGRES_USER
function postgres_ready(){
node << END
var postgres = require("pg");
var client = new postgres.Client({
user: '$POSTGRES_USER',
password: '$POSTGRES_PASSWORD',
database: '$POSTGRES_USER',
port: 5432,
host: 'postgres',
});
client.connect(function(err) {
if (err) {
console.log('connection failed');
console.error(err);
process.exit(1);
}
console.log('connection successful');
process.exit(0);
});
END
}
until postgres_ready; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - continuing..."
exec $cmd
compose/sails/start-dev.sh
sails lift --port 8000 --verbose
compose/postgres/Dockerfile
FROM postgres:9.6
# add backup scripts
ADD backup.sh /usr/local/bin/backup
ADD restore.sh /usr/local/bin/restore
ADD list-backups.sh /usr/local/bin/list-backups
# make them executable
RUN chmod +x /usr/local/bin/restore
RUN chmod +x /usr/local/bin/list-backups
RUN chmod +x /usr/local/bin/backup
config/datastores.js
default: {
adapter: "sails-postgresql",
user: "test_project",
host: "localhost",
},
Notes and error outputs
Note: I've also tried datastores url: 'postgresql://test_project#localhost:5432' and 'postgresql://test_project#localhost:5432/postgres' instead of separate declarations for each attribute on the connection string.
Although the database created by Docker seems to be fine, I keep getting either ECONNREFUSED (probably whenever I play around with docker DB or DB connection's parameters to try and make it work), or the following error (when it connects to the DB successfully):
error: Could not tear down the ORM hook.
Error details: Error: Invalid data store identity.
No data store exist with that identity.
The error's full output can be found down below (when using model alter strategy):
sails_1 | Postgres is unavailable - sleeping
postgres_1 | done
postgres_1 | server stopped
postgres_1 |
postgres_1 | PostgreSQL init process complete; ready for start up.
postgres_1 |
postgres_1 | LOG: database system was shut down at 2018-09-05 13:45:04 UTC
postgres_1 | LOG: MultiXact member wraparound protections are now enabled
postgres_1 | LOG: database system is ready to accept connections
postgres_1 | LOG: autovacuum launcher started
sails_1 | connection successful
sails_1 | Postgres is up - continuing...
sails_1 |
sails_1 | info: Starting app...
sails_1 |
sails_1 | verbo: Using locally-installed Sails.
sails_1 | verbo: • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
sails_1 | verbo: • Loading Sails with "verbose" logging enabled... •
sails_1 | verbo: • (For even more details, try "silly".) •
sails_1 | verbo: • •
sails_1 | verbo: • http://sailsjs.com/config/log •
sails_1 | verbo: • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
sails_1 | verbo: moduleloader hook loaded successfully. (0ms)
sails_1 | verbo: userconfig hook loaded successfully. (104ms)
sails_1 | verbo: Exposing global variables... (you can customize/disable this by modifying the properties in `sails.config.globals`. Set it to `false` to disable all globals.)
sails_1 | verbo: userhooks hook loaded successfully. (8669ms)
sails_1 | verbo: logger hook loaded successfully. (4ms)
sails_1 | verbo: request hook loaded successfully. (0ms)
sails_1 | verbo: views hook loaded successfully. (46ms)
sails_1 | verbo: responses hook loaded successfully. (49ms)
sails_1 | verbo: helpers hook loaded successfully. (11ms)
sails_1 | verbo: policies hook loaded successfully. (9ms)
sails_1 | verbo: services hook loaded successfully. (1ms)
sails_1 | verbo: security hook loaded successfully. (4ms)
sails_1 | verbo: i18n hook loaded successfully. (19ms)
sails_1 | verbo: session hook loaded successfully. (149ms)
sails_1 | verbo: http hook loaded successfully. (1341ms)
sails_1 | info: Initializing hook... (`api/hooks/custom`)
sails_1 | verbo: Some optional settings have not been configured yet:
sails_1 | ---------------------------------------------------------------------
sails_1 | No `sails.config.custom.stripeSecret` was configured.
sails_1 | No `sails.config.custom.stripePublishableKey` was configured.
sails_1 | No `sails.config.custom.mailgunSecret` was configured.
sails_1 | No `sails.config.custom.mailgunDomain` was configured.
sails_1 |
sails_1 | Until this is addressed, this app's billing and email features
sails_1 | will be disabled and/or hidden in the UI.
sails_1 |
sails_1 | [?] If you're unsure or need advice, come by https://sailsjs.com/support
sails_1 | ---------------------------------------------------------------------
sails_1 | verbo: custom hook loaded successfully. (1ms)
sails_1 | info: Initializing `apianalytics` hook... (requests to monitored routes will be logged!)
sails_1 | verbo: apianalytics hook loaded successfully. (0ms)
sails_1 | verbo: grunt hook loaded successfully. (11ms)
sails_1 | verbo: organics hook loaded successfully. (135ms)
sails_1 | verbo: sockets hook loaded successfully. (205ms)
sails_1 | verbo: Loading adapter (`sails-postgresql`) from this app's `node_modules/` directory...
sails_1 | info: ·• Auto-migrating... (alter)
sails_1 | info: Hold tight, this could take a moment.
sails_1 | error: A hook (`orm`) failed to load!
sails_1 | verbo: Lowering sails...
sails_1 | error: Could not tear down the ORM hook. Error details: Error: Invalid data store identity. No data store exist with that identity.
sails_1 | at Object.teardown (/app/node_modules/sails-postgresql/helpers/teardown.js:60:26)
sails_1 | at wrapper (/app/node_modules/#sailshq/lodash/lib/index.js:3275:19)
sails_1 | at Deferred.parley.retry [as _handleExec] (/app/node_modules/machine/lib/private/help-build-machine.js:1076:19)
sails_1 | at Deferred.exec (/app/node_modules/parley/lib/private/Deferred.js:286:10)
sails_1 | at Deferred.switch (/app/node_modules/machine/lib/private/help-build-machine.js:1469:16)
sails_1 | at teardownDatastore (/app/node_modules/sails-postgresql/lib/adapter.js:96:18)
sails_1 | at /app/node_modules/async/dist/async.js:3047:20
sails_1 | at replenish (/app/node_modules/async/dist/async.js:884:21)
sails_1 | at /app/node_modules/async/dist/async.js:888:13
sails_1 | at eachLimit$1 (/app/node_modules/async/dist/async.js:3136:26)
sails_1 | at Object.<anonymous> (/app/node_modules/async/dist/async.js:920:20)
sails_1 | at Object.teardown (/app/node_modules/sails-postgresql/lib/adapter.js:91:13)
sails_1 | at /app/node_modules/waterline/lib/waterline.js:758:27
sails_1 | at /app/node_modules/async/dist/async.js:3047:20
sails_1 | at eachOfArrayLike (/app/node_modules/async/dist/async.js:1002:13)
sails_1 | at eachOf (/app/node_modules/async/dist/async.js:1052:9)
sails_1 | at Object.eachLimit (/app/node_modules/async/dist/async.js:3111:7)
sails_1 | at Object.teardown (/app/node_modules/waterline/lib/waterline.js:742:11)
sails_1 | at Hook.teardown (/app/node_modules/sails-hook-orm/index.js:246:30)
sails_1 | at Sails.wrapper (/app/node_modules/#sailshq/lodash/lib/index.js:3275:19)
sails_1 | at Object.onceWrapper (events.js:273:13)
sails_1 | at Sails.emit (events.js:182:13)
sails_1 | at Sails.EventEmitter.emit (domain.js:442:20)
sails_1 | at Sails.emitter.emit (/app/node_modules/sails/lib/app/private/after.js:56:26)
sails_1 | at /app/node_modules/sails/lib/app/lower.js:67:11
sails_1 | at beforeShutdown (/app/node_modules/sails/lib/app/lower.js:45:12)
sails_1 | at Sails.lower (/app/node_modules/sails/lib/app/lower.js:49:3)
sails_1 | at Sails.wrapper [as lower] (/app/node_modules/#sailshq/lodash/lib/index.js:3275:19)
sails_1 | verbo: (The error above was logged like this because `sails.hooks.orm.teardown()` encountered an error in a code path where it was invoked without providing a callback.)
sails_1 | error:
sails_1 | error: Exception: `registerDataStore` failed ("badConfiguration"). The configuration was invalid. (Also got an additional error -- see `.raw`).
sails_1 | at Object.registerDatastore (/app/node_modules/sails-postgresql/lib/adapter.js:56:17)
sails_1 | at /app/node_modules/waterline/lib/waterline.js:714:27
sails_1 | at /app/node_modules/async/dist/async.js:3047:20
sails_1 | at eachOfArrayLike (/app/node_modules/async/dist/async.js:1002:13)
sails_1 | at eachOf (/app/node_modules/async/dist/async.js:1052:9)
sails_1 | at Object.eachLimit (/app/node_modules/async/dist/async.js:3111:7)
sails_1 | at Object.initialize (/app/node_modules/waterline/lib/waterline.js:650:11)
sails_1 | at buildOntologyAndRunAutoMigrations (/app/node_modules/sails-hook-orm/lib/build-ontology-and-run-auto-migrations.js:55:7)
sails_1 | at async.auto._buildOntology (/app/node_modules/sails-hook-orm/lib/initialize.js:456:7)
sails_1 | at runTask (/app/node_modules/async/dist/async.js:1660:17)
sails_1 | at /app/node_modules/async/dist/async.js:1602:17
sails_1 | at processQueue (/app/node_modules/async/dist/async.js:1612:17)
sails_1 | at taskComplete (/app/node_modules/async/dist/async.js:1630:13)
sails_1 | at /app/node_modules/async/dist/async.js:1653:21
sails_1 | at /app/node_modules/async/dist/async.js:339:31
sails_1 | at /app/node_modules/async/dist/async.js:847:20
sails_1 | at async.auto._checkAdapterCompatibility (/app/node_modules/sails-hook-orm/lib/initialize.js:428:14)
sails_1 | at runTask (/app/node_modules/async/dist/async.js:1660:17)
sails_1 | at /app/node_modules/async/dist/async.js:1602:17
sails_1 | at processQueue (/app/node_modules/async/dist/async.js:1612:17)
sails_1 | at taskComplete (/app/node_modules/async/dist/async.js:1630:13)
sails_1 | at /app/node_modules/async/dist/async.js:1653:21
sails_1 |
sails_1 | error: Could not load Sails app.
sails_1 | error:
sails_1 | error: Tips:
sails_1 | error: • First, take a look at the error message above.
sails_1 | error: • Make sure you've installed dependencies with `npm install`.
sails_1 | error: • Check that this app was built for a compatible version of Sails.
sails_1 | error: • Have a question or need help? (http://sailsjs.com/support)
Your datastores.js references the database host as localhost, it should be the name of the docker service postgres when running from the compose file. The migration part in compose/sails/entrypoint.sh references the host as postgres

Resources