0
votes

I've looked through different solutions and currently I'm unable to find a solution. For context, I'm building a website using the Wagtail CMS for Django and I'm trying to use Docker. I built the project using:

wagtail start sevendays

then created a docker-compose.yml file with this code:

version: "3.9"
   
services:
  db:
    image: postgres
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

I also changed the settings.py to the proper PostgreSQL configurations. Running docker-compose up gives me ModuleNotFoundError: No module named 'psycopg2'.

I also want to note that doing pip install psycopg2 and pip install psycopg2-binary did not work, it'd give me requirements satisfied message. Using pip3 doesn't work either and I am not in a venv.

1

1 Answers

0
votes

Sorry, I think I found the solution, I forgot to include psycopg2-binary in the requirements.txt

I had also replaced the default Dockerfile, but I'm pretty sure the requirements.txt is what fixed it, with

FROM python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/