Skip to content

tgrx/example-django-mssql-docker

Repository files navigation

Example: Django + MS SQL + Docker

Description

This is a bootstrap setup for a single service (webapp). The service is shipped as Docker image. The service will provide a Django/DRF webapp, which displays the tables within the given DB.

Includes:

  1. Task.
  2. Poetry.
  3. DB drivers: ODBC and PostgreSQL.
  4. Non-root user.
  5. Caches.

Current image size: ~230 MB

docker images | grep example-django-mssql-docker-webapp
example-django-mssql-docker-webapp                 latest          a071208f4698   31 seconds ago      229MB

Usage

The service utilizes a given MS SQL. Unfortunately MS SQL does not respect URLs, so you have to configure each aspect of credentials explicitly. See .env.sample for examples. WEBAPP_ is a prefix for env vars.

After successful build & run, you can open http://localhost:8000/ and observe list of tables in your MS SQL database.

Installation

Before doing something, make sure that you have

  1. copied .env.sample to .env
  2. modified values in .env according to your realm

Docker

First, hit docker compose build.

Next, hit task docker-up OR docker compose up -d.

Bare metal

Mac OS

If you have brew, pyenv and Task installed, this would be enough:

task setup-toolchain

Linux

First, be sure you're installed Microsoft ODBC drivers. Here are some key points.

Next, if you have pyenv and Task installed, this might be enough:

task setup-toolchain

I haven't checked yet this way, please send me a feedback in case of any bug.

Other

  1. be sure you have Microsoft ODBC drivers installed. Here are some key points.
  2. install Python 3.11.3
  3. install Poetry 1.5.1
  4. bind Python 3.11.3 to the cloned directory (this project)
  5. create venv and install dependencies: poetry install --with dev --sync
  6. double-check your .env
  7. start webapp with poetry run python manage.py runserver 0.0.0.0:8000

About

Example: Django + MSSQL + Docker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published