N
N
Nikita Pavlyuk2021-07-14 23:22:38
Docker
Nikita Pavlyuk, 2021-07-14 23:22:38

After build (npm build) doesn't run npm start in Docker container?

I set up deployment of a nuxt application using Docker according to this article .
After the call

docker run -p 80:80 --rm --name app-container app-image
throws an error:


Error: No build files found in /usr/src/nuxt-app/.nuxt/dist/server. ││ Use either `nuxt build` or `builder.build()` or start nuxt in ││ development mode.


P.S. on stackoverflow they write that you need to remove the volumes section. How and where to remove it? I don't use composite

Logs

Sending build context to Docker daemon 898.6kB
Step 1/12 : FROM node:11.13.0-alpine
---> f34bcc2815ed
Step 2/12 : RUN mkdir -p /usr/src/nuxt-app
---> Running in 9f954004530a
Removing intermediate container 9f954004530a
---> fd742f75caf9
Step 3/12 : WORKDIR /usr/src/nuxt-app
---> Running in 9cb5fec3a18d
Removing intermediate container 9cb5fec3a18d
---> 41e00bbff19a
Step 4/12 : RUN apk update && apk upgrade
---> Running in 132e2c75e2ff
fetch dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APK...
fetch dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_6...
v3.9.6-143-ga5f34edab6 [dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.6-138-ge069a77b3b [dl-cdn.alpinelinux.org/alpine/v3.9/community]
OK: 9780 distinct packages available
Upgrading critical system libraries and apk-tools:
(1/1) Upgrading apk-tools (2.10.3-r1 -> 2.10.6-r0)
Executing busybox-1.29.3-r10.trigger
Continuing the upgrade transaction with new apk-tools:
(1/5) Upgrading musl (1.1.20-r4 -> 1.1.20-r6)
(2/5) Upgrading libcrypto1.1 (1.1.1b-r1 -> 1.1.1k-r0)
(3/5) Upgrading libssl1.1 (1.1.1b-r1 -> 1.1.1k-r0)
(4/5) Upgrading ca-certificates-cacert (20190108-r0 -> 20191127-r2)
(5/5) Upgrading musl-utils (1.1.20-r4 -> 1.1.20-r6)
Executing busybox-1.29.3-r10.trigger
OK: 7 MiB in 16 packages
Removing intermediate container 132e2c75e2ff
---> 3ce4fcb752b2
Step 5/12 : RUN apk add git
---> Running in ca8754b23a12
(1/7) Installing ca-certificates (20191127-r2)
(2/7) Installing nghttp2-libs (1.35.1-r2)
(3/7) Installing libssh2 (1.9.0-r1)
(4/7) Installing libcurl (7.64.0-r5)
(5/7) Installing expat (2.2.8-r0)
(6/7) Installing pcre2 (10.32-r1)
(7/7) Installing git (2.20.4-r0)
Executing busybox-1.29.3-r10.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 22 MiB in 23 packages
Removing intermediate container ca8754b23a12
---> b476f25498e7
Step 6/12 : COPY . /usr/src/nuxt-app/
---> 0793094541f3
Step 7/12 : RUN npm install
---> Running in bbeeca94d3c3

> [email protected] postinstall /usr/src/nuxt-app/node_modules/@nuxt/babel-preset-app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

> [email protected] postinstall /usr/src/nuxt-app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

> [email protected] postinstall /usr/src/nuxt-app/node_modules/nuxt
> opencollective || exit 0

:-:
.==-+:
.==. :+- .-=-
.==. :==++-+=.
:==. -**: :+=.
:+- :*+++. .++.
:+- -*= .++: .=+.
-+: =*- .+*: .=+:
-+: .=*- .=*- =+:
.==: .+*: -*- -+-
.=+:.....:+*-.........:=*=..=*-
.-=------=++============++====:

Thanks for installing nuxtjs
Please consider donating to our open collective
to help us maintain this package.

Number of contributors: 0
Number of backers: 429
Annual budget: $92,172
Current balance: $31,301

Donate: https://opencollective.com/nuxtjs/donate

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
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"})

added 1517 packages from 742 contributors and audited 1520 packages in 37.974s
found 6 vulnerabilities (2 moderate, 4 high)
run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container bbeeca94d3c3
---> e4a0d5dce165
Step 8/12 : RUN npm run build
---> Running in f17017d0f098

> [email protected] build /usr/src/nuxt-app
> nuxt build

WARN You are using an unsupported version of Node.js (v11.13.0). It is recommended to use the latest LTS version (https://nodejs.org/en/about/releases)

Removing intermediate container f17017d0f098
---> c327e2ab09be
Step 9/12 : EXPOSE 80
---> Running in 58f06db8f561
Removing intermediate container 58f06db8f561
---> f89a2efa5a58
Step 10/12 : ENV NUXT_HOST=0.0.0.0
---> Running in 873cf674e9d1
Removing intermediate container 873cf674e9d1
---> 4f07ce94bf9d
Step 11/12 : ENV NUXT_PORT=80
---> Running in fbdea169ba31
Removing intermediate container fbdea169ba31
---> 98e710523e00
Step 12/12 : CMD [ "npm", "start" ]
---> Running in f89ff55ab865
Removing intermediate container f89ff55ab865
---> 8ce855d222ac
Successfully built 8ce855d222ac
Successfully tagged app-image:latest
docker build

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Pavlyuk, 2021-07-15
@Neakit

The article is old and uses node 11 version, which is no longer supported by nuxt.js. Use version 16.5.0 by changing the first line of the Dockerfile to "FROM node:16.5.0-alpine".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question