I have a basic NextJS setup with a custom Express server.
I'm trying to Dockerize the app. Here is my Dockerfile:
FROM node:alpine
WORKDIR /usr/app
RUN npm install --global pm2
COPY ./package.json ./
RUN yarn docker:build
COPY ./ ./
RUN yarn build
EXPOSE 3000
USER node
CMD [ "pm2-runtime", "yarn", "dev" ]
My docker:build command is,
rm -rf node_modules && rm -rf yarn.lock yarn && yarn
Anyway, I try to run docker-compose up and I run into the below error:
nextjs_1 | /opt/yarn-v1.22.5/bin/yarn:2
nextjs_1 | argv0=$(echo "$0" | sed -e 's,\\,/,g')
nextjs_1 | ^^^^
nextjs_1 | SyntaxError: missing ) after argument list
nextjs_1 | at wrapSafe (node:internal/modules/cjs/loader:1018:16)
nextjs_1 | at Module._compile (node:internal/modules/cjs/loader:1066:27)
nextjs_1 | at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
I have no idea what I'm doing wrong here.
I've simplified my setup in a repo here.
Any help would be appreciated.
Github issue
RUN yarnat that step (the image won't have anode_modulesdirectory yet, and you don't want to delete the lock file)? Does that error come when building the image or running it? Are you doing something that might cause theyarnscript wrapper to be interpreted with Node?