ImperialCollegeLondon / drunc_ui

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Steps to Set Up drunc-ui and Create a Superuser on Windows #178

Open cvzbynek opened 5 days ago

cvzbynek commented 5 days ago

Issue: Steps to Set Up drunc-ui and Create a Superuser on Windows

Description

While setting up the drunc-ui application, I encountered a few challenges, especially around creating a Django superuser and ensuring the correct permissions for Docker. I’ve documented the exact steps I followed and where I encountered issues, which might help in improving the developer documentation.

Steps Tried So Far

  1. Cloning the Repository

    • Cloned the drunc-ui repository from GitHub to a directory in Windows:
      git clone https://github.com/ImperialCollegeLondon/drunc_ui.git
      cd drunc_ui
  2. Setting Up Docker with WSL

    • I am using WSL 2 with Ubuntu as my distribution. Initially, Docker wasn’t properly integrated with WSL, so I had to enable the WSL integration in Docker Desktop.
    • After enabling integration, I ensured Docker was running in the WSL environment:
      docker --version
  3. Running Docker Compose

    • From within the project directory, I started the Docker services using Docker Compose:

      docker compose up
    • The app launched successfully, but when accessing the app at http://localhost:8000, I was prompted for a username and password, which I didn’t have yet.

  4. Creating a Superuser (Missing from Documentation)

    • To create the superuser, I followed these steps:

      • First, I ensured Docker containers were running in one terminal:

        docker compose up
      • In a new terminal, I entered the container that runs the Django app:

        docker compose exec app bash
      • Once inside the container, I ran the following command to create the superuser:

        python manage.py createsuperuser
      • I followed the prompts to set up a username, email, and password for the superuser.

      • After exiting the container, I was able to log into the app at http://localhost:8000 using the superuser credentials.

  5. Docker Permissions Issue

    • Initially, I encountered a permissions issue when running docker compose up, which resulted in the following error:

      permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
    • To resolve this, I had to add my user to the docker group:

      sudo usermod -aG docker $USER
    • After restarting my session (or running newgrp docker), I could run Docker commands without needing sudo.

Suggestions for Documentation

  1. Create a Superuser

    • Add a section explaining that after starting the Docker containers, users must create a Django superuser by entering the app container and running the createsuperuser command. The documentation should highlight that this step is necessary to log in to the application.
  2. Docker Permissions

    • Mention that users might need to add themselves to the docker group to avoid permission errors when running Docker commands. This step is common when working with Docker in WSL or Linux environments.
  3. WSL Setup

    • It might be helpful to include a brief guide on how to set up Docker with WSL 2, especially for users on Windows, as WSL integration can sometimes be tricky to configure.
cc-a commented 5 days ago

Hi @cvzbynek. Thanks for this. Happy to link to some resources on getting Docker setup on different platforms. The user creation in docker is covered in the getting started with the process manager ui section, so maybe we need to highlight this a little better?

cvzbynek commented 5 days ago

@cc-a I see now. I haven't gone to that part very thoroughly, since I didn't get to Process Manager itself. I would restructuralize to stress the need to make a superuser to actually access anything. Not just the Process Manager.

cc-a commented 5 days ago

Ok, we have an issue to create some more extensive documentation so I'll link this under that and take a pass when I look at it.