Skip to content

Latest commit

 

History

History
109 lines (85 loc) · 3.59 KB

docker-setup.md

File metadata and controls

109 lines (85 loc) · 3.59 KB

Dart Docker

Requirements

  • admin rights
  • git/zip file
  • docker

Setup DART docker installation

The following steps will set up DART as a local application running under localhost:<HOST_PORT>

Assumptions: DART root directory is /DART (this can be any path you choose, but just make sure to replace this path with yours if it is different)


Clone the repo

  1. Open a terminal and navigate to

    cd /
    
  2. Use the git clone command to download the repo

    $> git clone https://<PATH_TO_THE_REPO>/dart.git
    

    if using a zip just unzip the content in the desired location


Docker

  1. Build the image

    $> docker build --build-arg APPLICATION_PORT=8010 -t dart:latest -f deploy/docker/Dockerfile .
    

    --build-arg : Set build-time variables

    • BASE_IMAGE : The base image. Defaults python
    • BASE_TAG : The image base tag. Defaults 3.11.0-alpine3.16
    • PIP_TRUSTED_HOSTS : pip trusted hosts.Defaults --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org
    • APPLICATION_PORT : The app port. Defaults to 8000
    • APPLICATION_DIR : App container directory. Defaults to /opt/dart

    -t : Name and optionally a tag in the name:tag format -f : Location of the docker file deploy/docker/Dockerfile

  2. Run the image

    $> docker run -d -p <HOST_PORT>:<APPLICATION_PORT>/tcp dart:latest
    

    -d : Run container in background and print container ID

    -p : Publish a container’s port(s) to the host


Adding users

There are multiple ways of adding users into the app. We'll document one scenario but you are welcome to implement your own. The commands are documented in the django site.

  1. (Optional) Create a super user (a user who has all permissions). Through this user you will be able to access the admin panels. Type the following command and follow the instructions:

    $> docker exec -it <CONTAINER_ID> python manage.py createsuperuser
    
    Username: superuser
    Email address: [email protected]
    Password: 
    Password (again): 
    Superuser created successfully.
    

    Now you should be able to login with the new user

    To add more users, go to the user admin panel and complete the form to add users.

  2. Programmatically creating users: Use the create_user helper method. For more details look at the django docs:

    $> docker exec -it <CONTAINER_ID> python manage.py shell
    
    (InteractiveConsole)
    >>> from django.contrib.auth import get_user_model
    >>> user = get_user_model().objects.create_user("john", "[email protected]", "johnpassword")
    >>> user.last_name = "Lennon"
    >>> user.save()
    >>> exit()