feat: basic django app with docker-compose
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
parent
16dd402319
commit
e110616d67
6 changed files with 148 additions and 2 deletions
|
|
@ -2,6 +2,10 @@ FROM python:3.9.1-alpine3.13
|
||||||
|
|
||||||
MAINTAINER "Ameya Shenoy <shenoy.ameya@gmail.com>"
|
MAINTAINER "Ameya Shenoy <shenoy.ameya@gmail.com>"
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
COPY requirements.txt /
|
COPY requirements.txt /
|
||||||
|
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
|
|
@ -10,7 +14,13 @@ RUN set -ex \
|
||||||
musl-dev \
|
musl-dev \
|
||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
python3-dev \
|
python3-dev \
|
||||||
|
&& apk add --no-cache \
|
||||||
|
libpq \
|
||||||
&& pip install -r /requirements.txt \
|
&& pip install -r /requirements.txt \
|
||||||
&& rm -rf requirements.txt \
|
&& rm -rf requirements.txt \
|
||||||
&& apk del .build-deps
|
&& apk del .build-deps
|
||||||
|
|
||||||
|
COPY . /code
|
||||||
|
|
||||||
|
ENTRYPOINT sh /code/entrypoint.sh
|
||||||
|
|
||||||
|
|
|
||||||
35
backend/app/migrations/0001_initial.py
Normal file
35
backend/app/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Generated by Django 3.1.6 on 2021-02-08 21:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BhavCopyEquity',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||||
|
('date', models.DateField(auto_now_add=True)),
|
||||||
|
('sc_code', models.PositiveIntegerField()),
|
||||||
|
('sc_name', models.CharField(max_length=20)),
|
||||||
|
('sc_group', models.CharField(max_length=2)),
|
||||||
|
('sc_type', models.CharField(max_length=1)),
|
||||||
|
('open_price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('high_price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('low_price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('close_price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('last_price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('prevclose_price', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('no_trades', models.PositiveIntegerField()),
|
||||||
|
('no_of_shrs', models.PositiveIntegerField()),
|
||||||
|
('net_turnov', models.PositiveIntegerField()),
|
||||||
|
('tdcloindi', models.TextField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -1,3 +1,28 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
class BhavCopyEquity(models.Model):
|
||||||
|
id = models.AutoField(primary_key=True)
|
||||||
|
date = models.DateField(auto_now_add=True, editable=False)
|
||||||
|
|
||||||
|
# Ref: https://www.bseindia.com/markets/debt/BhavCopyhelp.aspx
|
||||||
|
sc_code = models.PositiveIntegerField()
|
||||||
|
sc_name = models.CharField(max_length=20)
|
||||||
|
sc_group = models.CharField(max_length=2)
|
||||||
|
sc_type = models.CharField(max_length=1)
|
||||||
|
open_price = models.DecimalField(max_digits=12, decimal_places=2)
|
||||||
|
high_price = models.DecimalField(max_digits=12, decimal_places=2)
|
||||||
|
low_price = models.DecimalField(max_digits=12, decimal_places=2)
|
||||||
|
close_price = models.DecimalField(max_digits=12, decimal_places=2)
|
||||||
|
last_price = models.DecimalField(max_digits=12, decimal_places=2)
|
||||||
|
prevclose_price = models.DecimalField(max_digits=12, decimal_places=2)
|
||||||
|
no_trades = models.PositiveIntegerField()
|
||||||
|
no_of_shrs = models.PositiveIntegerField()
|
||||||
|
net_turnov = models.PositiveIntegerField()
|
||||||
|
tdcloindi = models.TextField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'{self.DATE}-{self.SC_CODE}'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'app',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
@ -74,14 +75,25 @@ WSGI_APPLICATION = 'backend.wsgi.application'
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||||
|
|
||||||
|
# DATABASES = {
|
||||||
|
# 'default': {
|
||||||
|
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
# 'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
|
# }
|
||||||
|
# }
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
'NAME': 'bullish',
|
||||||
|
'USER': 'bullish',
|
||||||
|
'PASSWORD': 'password',
|
||||||
|
'HOST': 'db',
|
||||||
|
'PORT': '5432',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
|
|
||||||
11
backend/entrypoint.sh
Normal file
11
backend/entrypoint.sh
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Apply database migrations
|
||||||
|
echo "Apply database migrations"
|
||||||
|
python manage.py migrate
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
echo "Starting server"
|
||||||
|
python manage.py runserver 0.0.0.0:8000
|
||||||
|
|
||||||
|
|
||||||
53
docker-compose.yml
Normal file
53
docker-compose.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: codingcoffee/bullish-backend
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
volumes:
|
||||||
|
- ./backend:/code
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
ports:
|
||||||
|
- 8000:8000
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:6.0.10-alpine3.13
|
||||||
|
# ports:
|
||||||
|
# - 6379:6379
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:13.1-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- bullish-db-data:/var/lib/postgresql/data/pgdata
|
||||||
|
# TODO: remove pass
|
||||||
|
environment:
|
||||||
|
- PGDATA=/var/lib/postgresql/data/pgdata
|
||||||
|
- POSTGRES_SERVER=db
|
||||||
|
- POSTGRES_USER=bullish
|
||||||
|
- POSTGRES_PASSWORD=password
|
||||||
|
- POSTGRES_DB=bullish
|
||||||
|
# ports:
|
||||||
|
# - 5432:5432
|
||||||
|
|
||||||
|
pgadmin:
|
||||||
|
image: dpage/pgadmin4
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
environment:
|
||||||
|
- PGADMIN_LISTEN_PORT=5050
|
||||||
|
- PGADMIN_DEFAULT_EMAIL=admin@bullish.io
|
||||||
|
- PGADMIN_DEFAULT_PASSWORD=password
|
||||||
|
ports:
|
||||||
|
- 5050:5050
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
bullish-db-data:
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue