I'm trying to build a vue/quasar app with the Dockerfile and face some errors:
The command '/bin/sh -c quasar build' returned a non-zero code: 1
I am using the latest LTS node version.
running the command: npx quaser build
in the app directory does all the job properly, but doesn't work with the Dockerfile.
this is my Dockerfile:
FROM node:latest as build-stage
COPY package*.json ./
RUN npm install
RUN npm -g install @quasar/cli
RUN npm -g install @vue/cli
COPY ./ .
RUN quasar build
FROM nginx as production-stage
RUN mkdir /app
COPY --from=build-stage /dist/spa /app
COPY nginx.conf /etc/nginx/nginx.conf
this is all the output:
(base) ysgtr@tex-len:~/tex/test$ docker build -t quaser .
Sending build context to Docker daemon 4.085MB
Step 1/11 : FROM node:latest as build-stage
latest: Pulling from library/node
647acf3d48c2: Pull complete
b02967ef0034: Pull complete
e1ad2231829e: Pull complete
5576ce26bf1d: Pull complete
a66b7f31b095: Pull complete
2f540184b4cf: Pull complete
42cd32d0102f: Pull complete
b8b4c8e22bcd: Pull complete
48e4c368fbe9: Pull complete
Digest: sha256:22f1866405ad50bb1d141739596ba803aed073d618ab2ae6d5e66aedcf9261b5
Status: Downloaded newer image for node:latest
---> 6dc0a5fbad51
Step 2/11 : COPY package*.json ./
---> f80875173de5
Step 3/11 : RUN npm install
---> Running in 1282a9fbc81b
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
added 1183 packages, and audited 1184 packages in 23s
133 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm notice
npm notice New patch version of npm available! 8.1.2 -> 8.1.4
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.1.4>
npm notice Run `npm install -g npm@8.1.4` to update!
npm notice
Removing intermediate container 1282a9fbc81b
---> e13c67d85f7b
Step 4/11 : RUN npm -g install @quasar/cli
---> Running in 9d0f4ba8e061
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
added 373 packages, and audited 374 packages in 13s
35 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Removing intermediate container 9d0f4ba8e061
---> 2669c81c7f92
Step 5/11 : RUN npm -g install @vue/cli
---> Running in 8340d87251db
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/
npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details
npm WARN deprecated apollo-cache-control@0.14.0: The functionality provided by the `apollo-cache-control` package is built in to `apollo-server-core` starting with Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#cachecontrol for details.
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
added 947 packages, and audited 948 packages in 37s
65 packages are looking for funding
run `npm fund` for details
15 vulnerabilities (8 moderate, 7 high)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
Removing intermediate container 8340d87251db
---> 3ecd65ef8620
Step 6/11 : COPY ./ .
---> 22470e123db7
Step 7/11 : RUN quasar build
---> Running in 0ab8824d1c93
___
/ _ \ _ _ __ _ ___ __ _ _ __
| | | | | | |/ _` / __|/ _` | '__|
| |_| | |_| | (_| \__ \ (_| | |
\__\_\\__,_|\__,_|___/\__,_|_|
Running @quasar/cli v1.2.2
Example usage
$ quasar <command> <options>
Help for a command
$ quasar <command> --help
$ quasar <command> -h
Options
--version, -v Print Quasar CLI version
Commands
create Create a project folder
info Display info about your machine
(and your App if in a project folder)
upgrade Check (and optionally) upgrade Quasar packages
from a Quasar project folder
serve Create an ad-hoc server on App's distributables
help, -h Displays this message
--------------
=> IMPORTANT !
=> Trigger this inside of a Quasar project (and npm/yarn install) for more commands.
--------------
Error Unknown command "build"
The command '/bin/sh -c quasar build' returned a non-zero code: 1
things I tried:
dist/
and node_modules/
folder before running the docker file.quaser build
in the dockerfile with RUN npx quasar build
So I found a way to resolve the problem, basically, I stated the WORKDIR and copied the quasar.conf.js file. Hope this helps others.
FROM node:latest as build-stage
WORKDIR /app
COPY package*.json ./
COPY quasar.conf.js ./
COPY ./ ./
RUN npm install
RUN npm install -g @vue/cli
RUN npm install -g @quasar/cli
RUN quasar build
FROM nginx as production-stage
RUN mkdir /app
COPY --from=buildenv /app/dist/spa /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf