Setting up a dockerized python server on local machine gives Session data corrupted

Viewed 138

I'm trying to set up a dockerized Python server named Bullet Train on my local machine:

It has 3 components:

All of these 3 need to work together to get the server up and running, so this is the docker-compose file which sits at the top level of both the frontend and api-server:

version: '3'
services:
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_DB: bullettrain
    ports:
     - "5432:5432"
  api:
    build:
      context: ./bullet-train-api
      dockerfile: docker/Dockerfile
    command: bash -c "pipenv run python manage.py migrate --noinput
              && pipenv run python manage.py collectstatic --noinput
              && pipenv run gunicorn --bind 0.0.0.0:8000 -w 3 app.wsgi
              && pipenv run python src/manage.py createsuperuser"
    environment:
      DJANGO_DB_NAME: bullettrain
      DJANGO_DB_USER: postgres
      DJANGO_DB_PASSWORD: password
      DJANGO_DB_PORT: 5432
      DJANGO_ALLOWED_HOSTS: localhost
    ports:
     - "8000:8000"
    depends_on:
      - db
    links:
      - db:db
  frontend:
    build:
      context: ./bullet-train-frontend
      dockerfile: Dockerfile
    ports:
      - "8080:8080"

This way, all the 3 components run in parallel. So far so good! Now to initialize it, I run the createsuperuser as stated here by following these steps:

docker exec -it research_api_1 bash ## go to the context of the API server terminal
run python manage.py createsuperuser ## run the createsuperuser command

The command runs successfully and I get this output:

Superuser created successfully.

To confirm, I went to the database:

docker exec -it research_db_1 bash ## go to the database instance
psql bullettrain postgres ## connect to the bullettrain database
select * from public.users_ffadminuser; ## check if the super user is created

The results show that the user is indeed created:

super user created

Now, if I go to the admin panel as per the docs, nothing happens and the server logs always throw Session data corrupted:

Session data corrupted

0 Answers
Related