diff --git a/.gitignore b/.gitignore index 87ae4a7..7cd1826 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,208 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/django,python +# Edit at https://www.toptal.com/developers/gitignore?templates=django,python + +### Django ### +*.log +*.pot *.pyc -*.pyo -*sublime* -python_environment/* -environment/* +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# End of https://www.toptal.com/developers/gitignore/api/django,python diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aa2c654 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3 +ENV PYTHONUNBUFFERED 1 + +RUN mkdir /code + +WORKDIR /code + +COPY requirements.txt /code/ +RUN pip install -r requirements.txt + +COPY . /code/ + +ENTRYPOINT [ "python", "manage.py", "runserver", "0.0.0.0:8000" ] diff --git a/README.md b/README.md index 533a821..601300d 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,14 @@ Python 3x, pip, Django, Postgresql ## How to start +We have a description of two different ways of starting a development server: +- With a Python Local Installation +- With a Docker environment + +Be free to choose that which satisfies your necessities. + +### Python Local Instalation + 1. Install Python 3.x and Pip. Use virtual environment if your host has older python version and it cant be upgraded. 2. Install PostgreSQL or some other Django-friendly database engine. Also you might want to install PgAdmin or any other administrative tool for your database. 3. Go to your charts storage folder and run `pip install -r requirements.txt`. Unix users : you have to have python-dev package to install `psycopg2`. @@ -15,3 +23,10 @@ Python 3x, pip, Django, Postgresql 5. Run `python manage.py migrate`. This will create database schema without any data. 6. Run `python manage.py runserver` to run *TEST* instance of your database. Use some other stuff (i.e., Gunicorn) for your production environment. +### Using Docker + +1. Install `docker` and `docker-compose`. +2. Run `docker-compose up --build` to run TEST instance of your database. Use some other stuff (i.e., Gunicorn) for your production environment. +3. If it is your first run, in another terminal run `docker-compose run web python manage.py migrate` when all the services are already up and running. This will create database schema without any data. + +If you want to use another database host, change the environment options in `docker-compose` of the `web`service and run `docker-compose up web --build` to startup the development environment. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..62b2d3c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,27 @@ +version: '3' + +services: + db: + image: postgres + environment: + - POSTGRES_DB=postgres + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - "5432:5432" + web: + build: . + environment: + - DB_NAME=postgres + - DB_USER=postgres + - DB_PASSWORD=postgres + - DB_HOST=db + - DB_PORT=5432 + volumes: + - .:/code + ports: + - "8000:8000" + depends_on: + - db + links: + - "db"