Reputation: 213
I'm researching as well but will keep adding links that I think might help
Migration and Seeding in Django
Providing initial data for models
This is the error that I'm getting and it's because I'm not able to write to my database with the docker command(you will see below). That's my assumption.
This is my folder structure.
docker-compose.yml
version: "3"
services:
django:
build: ./api
command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
volumes:
- ./api:/app
ports:
- "8000:8000"
frontend:
build: ./frontend
volumes:
- ./frontend:/app
- /app/node_modules
ports:
- "3000:3000"
volumes:
node-modules:
Dockerfile (inside api folder)
FROM python:3.7.6
WORKDIR /app
COPY requirements.txt /app
RUN pip3 install -r requirements.txt
COPY . .
# Run migrations and load seed data (using SQLite)
RUN python3 manage.py makemigrations
RUN python3 manage.py migrate
RUN python3 manage.py loaddata portal/fixtures/seed.yaml
RUN python3 manage.py loaddata scheduler/fixtures/seed.yaml
EXPOSE 8000
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
Have tried most of the possible items I was able to search, would really appreciate if someone could help here.
Upvotes: 1
Views: 695
Reputation: 7299
Run the commands in your Docker Image CLI
# Run migrations and load seed data (using SQLite)
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py loaddata portal/fixtures/seed.yaml
python3 manage.py loaddata scheduler/fixtures/seed.yaml
Do it in a sequential manner.
Upvotes: 1