I am deploying project with NextJS, Django, Postgres, Nginx in Docker Compose, it works fine in local (ubunutu 18.04). But in the server (ubuntu 20.04) it raises Error: ENOTEMPTY: directory not empty, rmdir '/frontend/out/node_modules/cacache/node_modules/.bin'
error. How to fix this.
P.S. I am using wait-for.sh for frontend to wait for api service to be ready(otherwise I also get build error) and my local docker version is Docker version 19.03.12, build 48a66213fe
, my servers docker version is Docker version 19.03.11, build dd360c7
maybe possible causes of the error?
My Dockerfile for frontend service:
USER root
WORKDIR /frontend
COPY . /frontend
# Add wait-for-it
COPY wait-for.sh wait-for.sh
RUN chmod +x wait-for.sh
RUN yarn
My docker-compose.yml:
services:
db:
image: postgres:12.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=purple_postgres_user
- POSTGRES_PASSWORD=purple_p@ssW0rd
- POSTGRES_DB=purple_db
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
# command: ./manage.py purple.wsgi:application --bind 0.0.0.0:8000
volumes:
- ./backend/:/home/purple_user/purple/
- static_volume:/home/purple_user/purple/static/
- media_volume:/home/purple_user/purple/media/
expose:
- 8000
ports:
- 8000:8000
env_file:
- ./.env.dev
depends_on:
- db
nginx:
build: ./nginx
ports:
- 80:80
volumes:
- static_volume:/var/www/staticfiles/
- media_volume:/var/www/mediafiles/
- build_folder:/var/www/frontend/
depends_on:
- web
frontend:
container_name: frontend
build:
context: ./frontend
volumes:
- build_folder:/frontend/out
depends_on:
- web
command: ./wait-for.sh web:8000 -- yarn build
volumes:
postgres_data:
static_volume:
media_volume:
build_folder:```
For me, the solution was, to delete the volume of frontend service, which is named build_folder
. To get correct name of the build folder you can run docker volume ls
- for me it was purple_build_folder - and the delete folder by running docker volume rm [volume name]
command.