I am trying to setup node 15.3.2 version using docker compose file. I have added all the necessary requirements in dockerfile. But after executing docker compose up
command, I am facing below error. I tried docker compose --build
command as well. If any one have any solution please let me know.
Dockerfile
FROM node:15-alpine3.10
WORKDIR /var/apps/frontend
COPY frontend /var/apps/frontend/
RUN apk update
RUN apk add alpine-sdk
RUN apk add --update npm
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
RUN npm install -g npm@9.9.2
RUN rm -rf node_modules
RUN npm cache clean --force
RUN npm rebuild node-sass --force
RUN npm i react@15.3.2 --legacy-peer-deps
RUN npm install --legacy-peer-deps
CMD [ "npm", "start" ]
docker-compose.yml
frontend:
build:
context: .
dockerfile: ./docker/frontend/Dockerfile
container_name: ui
command: bash -c "npm config set package-lock false && npm install && yarn run docker"
networks: ['ao_platform_network']
depends_on: ['django']
ports:
- "8081:8081"
environment:
- RAILS_ENV=development
- RAKE_ENV=development
- NODE_ENV=development
volumes:
- type: bind
source: ./frontend
target: /var/apps/frontend
Error:
node:internal/modules/cjs/loader:927
throw err;
^
Error: Cannot find module '/var/apps/frontend/bash'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
By default, bash
is not included with Alpine Linux
. So, you need to add this command in Dockerfile:
RUN apk update && apk add bash
But note that just adding this should be more than enough:
RUN apk add bash
You may also add --no-cache
option to avoid keeping the downloaded packages in cache:
RUN apk add --no-cache bash
More details in here: