Skip to content

Repository files navigation

Django-Docker

Django Docker start up project

For making new projects with docker and django without using virtual environment Now included vite, postcss, bun, tailwindcss

Installation

  • First - Clone this repo to your local machine git clone https://github.com/issamlk1/django-docker
  • Create .env file and fill it, it's content is inside the file .env.example for development enviroment
  • Open terminal from the project file and follow the next steps

Start new project

First build the docker file

$ docker compose build

Then create the new project

$ docker compose run web django-admin startproject config .

Setup

  • After building the project you need to edit sittings.py to your new database information

change /settings.py From

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

If you kept the postgresql it should look like this (its better to use the .env)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'myproject',
        'USER': 'postgres',
        'PASSWORD' : 'postgres',
        'HOST': 'postgresql',
        'PORT': 5432,
    }
}

Start the App

$ docker compose up -d

Shut down

$ docker compose down

Access the containers

  • To access the docker containers just type this command in your terminal

django

$ docker compose exec -it django zsh 

postgresql

$ docker compose exec -it postgresql bash

Important

  • If you added new django packages to your projects make sure to run following command from inside the django container before shutting down
$ pip freeze > requirements.txt

Then before running the project again build the project again to download your packages

$ docker compose build web

FAQ

  • How do I use mysql database?
    • I removed the mysql example from the project, maybe I'll add it later.

Support

Reach out to me at one of the following places!


License

License

About

For making new projects with docker and django without using virtual environment

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages