Configuring docker-compose.yaml for vue, redis and django [closed]

I plan to run the application with one command from the terminal. However, when configuring docker-compose.yaml I have encountered many problems and gaps in my knowledge. At last I have compiled this file and realized that only redis works and the rest does not start. The Django works on the postgresql and the redis is needed only for the normal work of the celery which I don't want to add to docker

yet

Annex structure

  • docker-compose.yaml
  • src/web/static/museum/(application front end in vue.js)
  • src/manage.py
  • python/Dockerfile
  • vue-js/Dockerfile
  • python/Dockerfile

    FROM python:3.8
    
    ENV PYTHONUNBUFFERED 1
    
    RUN pip install poetry==1.1.8 && poetry config virtualenvs.create false
    
    WORKDIR /app
    COPY pyproject.toml .
    RUN poetry install
    
    COPY . .
    
    RUN python src/manage.py collectstatic --no-input
    
    EXPOSE 8000
    
    CMD python src/manage.py migrate && python src/manage.py runserver 0.0.0.0:8000
    

    vue-js/Dockerfile

    FROM node:lts-alpine
    
    WORKDIR /app/src/web/static/museum
    
    RUN npm run serve
    
    CMD ["npm", "run", "serve"]
    

    docker-compose.yaml

    version: '3'
    
    services:
    
      redis:
        image: redis:6-alpine
        ports:
          - 6379:6379
    
      vue:
        image: node:lts-alpine
        build:
          context: ./vue-js
          dockerfile: Dockerfile
        ports:
          - 8080:8080
        restart: always
    
       app:
        image: django3.2:latest
        build:
          context: ./python
          dockerfile: Dockerfile
        depends_on:
          - redis
        environment:
          DB_USER: user
          DB_NAME: name
          DB_PASSWORD: password
          CELERY_BROKER_URL: redis://redis:6379/0
        restart: always
    
    

    at startup docker-compose.yaml gives out an error

    app_1    |     connection = Database.connect(**conn_params)
    app_1    |   File "/usr/local/lib/python3.8/site-packages/psycopg2/__init__.py", line 122, in connect
    app_1    |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
    app_1    | django.db.utils.OperationalError: could not connect to server: Connection refused
    app_1    |      Is the server running on host "127.0.0.1" and accepting
    app_1    |      TCP/IP connections on port 5432?
    app_1    |
    app_1 exited with code 1
    
    

    What exactly is the error?

    Thanks in advance!

    Вернуться на верх