grand-stack-starter
grand-stack-starter copied to clipboard
docker-compose image does not install `graphql`
- Cloned the repo
docker-compose up- It failed because the
apicontainer did not start - Did
docker-compose run api bash, thennpm install graphql apicontainer now starts
...
added 230 packages from 189 contributors, removed 21 packages, updated 195 packages and audited 928 packages in 29.399s
67 packages are looking for funding
run `npm fund` for details
found 23 vulnerabilities (21 moderate, 2 high)
run `npm audit fix` to fix them, or `npm audit` for details
root@0ef28cc3b210:/app# npm start
> [email protected] start /app
> npm run build && node build/index.js
> [email protected] build /app
> babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build
Successfully compiled 5 files with Babel (1136ms).
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module 'graphql'
Require stack:
- /app/node_modules/apollo-server-errors/dist/index.js
- /app/node_modules/apollo-server-core/dist/runHttpQuery.js
- /app/node_modules/apollo-server-core/dist/index.js
- /app/node_modules/apollo-server-express/dist/index.js
- /app/build/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/app/node_modules/apollo-server-errors/dist/index.js:4:19)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/app/node_modules/apollo-server-errors/dist/index.js',
'/app/node_modules/apollo-server-core/dist/runHttpQuery.js',
'/app/node_modules/apollo-server-core/dist/index.js',
'/app/node_modules/apollo-server-express/dist/index.js',
'/app/build/index.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `npm run build && node build/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-28T11_48_13_418Z-debug.log
root@0ef28cc3b210:/app# npm install graphql
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/nodemon/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ [email protected]
added 1 package and audited 929 packages in 10.719s
67 packages are looking for funding
run `npm fund` for details
found 23 vulnerabilities (21 moderate, 2 high)
run `npm audit fix` to fix them, or `npm audit` for details
root@0ef28cc3b210:/app# npm start
> [email protected] start /app
> npm run build && node build/index.js
> [email protected] build /app
> babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build
Successfully compiled 5 files with Babel (744ms).
GraphQL server ready at http://0.0.0.0:4001/graphql
I have solved this by updating the Dockerfile for the api project adding the following:
RUN npm i graphql
So that my api Dockerfile looks like:
FROM node:12
RUN mkdir -p /app
WORKDIR /app
COPY package.json .
RUN npm install
RUN npm i graphql
COPY . .
EXPOSE 4001
CMD ["npm", "start"]
Added "graphql": "^15.5.1" to dependencies in package.json and it seems to be working, too.