Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build in production failed : nuxt not found #2636

Open
victoria557 opened this issue Feb 15, 2024 · 0 comments
Open

Build in production failed : nuxt not found #2636

victoria557 opened this issue Feb 15, 2024 · 0 comments

Comments

@victoria557
Copy link

I use API Platform 3.2.

I'm deploying my API Platform application with Nuxt, and when I run the command:

SERVER_NAME=your-domain-name.example.com \
APP_SECRET=ChangeMe \
POSTGRES_PASSWORD=ChangeMe \
CADDY_MERCURE_JWT_SECRET=ChangeThisMercureHubJWTSecretKey \
docker compose -f compose.yaml -f compose.prod.yaml up --wait

I have the following error:

=> ERROR [pwa builder 4/4] RUN PNPM install --frozen-lockfile --offline --prod &&  pnpm run build                                                                                                     4.9s
------                                                                                                                                                                                                      
 > [pwa builder 4/4] RUN        PNPM install --frozen-lockfile --offline --prod &&      pnpm run build:                                                                                                     
3.272 ? The modules directory at "/srv/app/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) ‣ true                                                                                
4.190 > nuxt-app@ build /srv/app                                                                                                                                                                            
4.190 > nuxt build                                                                                                                                                                                          
4.190                                                                                                                                                                                                       
4.196 sh: 1: nuxt: not found                                                                                                                                                                                
4.199  ELIFECYCLE  Command failed.                                                                                                                                                                          
------
failed to solve: process "/bin/sh -c pnpm install --frozen-lockfile --offline --prod && \tpnpm run build" did not complete successfully: exit code: 1

Here is my pwa/Dockerfile:

#syntax=docker/dockerfile:1.4

# Versions
FROM node:lts AS node_upstream


# Base stage for dev and build
FROM node_upstream AS base

WORKDIR /srv/app

RUN corepack enable && \
	corepack prepare --activate pnpm@latest && \
	pnpm config -g set store-dir /.pnpm-store

# Development image
FROM base as dev

EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME localhost

CMD ["sh", "-c", "pnpm install; pnpm dev"]


FROM base AS builder

COPY --link pnpm-lock.yaml ./
RUN pnpm fetch --prod

COPY --link . .

RUN	pnpm install --frozen-lockfile --offline --prod && \
	pnpm run build


# Production image, copy all the files and run nuxt
FROM node_upstream AS prod

WORKDIR /srv/app

ENV NODE_ENV production

RUN addgroup --system --gid 1001 nodejs; \
	adduser --system --uid 1001 nuxt

COPY --from=builder --link /srv/app/public ./public

USER nuxt

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME localhost

CMD ["node", "server.js"]

And my compose.prod.yaml:

# Production environment override
services:
  php:
    build:
      context: ./api
      target: frankenphp_prod
    environment:
      APP_SECRET: ${APP_SECRET}
      MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}
      MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}

  pwa:
    build:
      context: ./pwa
      target: prod

  database:
    environment:
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant