-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from SmartWasteSegregatorAndRoutePlanner/docke…
…rize-project Dockerize project
- Loading branch information
Showing
8 changed files
with
334 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
### Django ### | ||
*.log | ||
*.pot | ||
*.pyc | ||
__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. | ||
# <django-project-name>/staticfiles/ | ||
*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/ | ||
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/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Django stuff: | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .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/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
### 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 | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .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. | ||
|
||
# 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 | ||
|
||
# Cython debug symbols | ||
|
||
# custom files | ||
*.sqlite3 | ||
.git | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,3 +274,4 @@ poetry.toml | |
*migrations* | ||
*temp* | ||
*cache* | ||
staticfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# DESCRIPTION: Deploys Backend-APIs repo in Container | ||
# AUTHOR: Dhrumil Mistry <contact@dmdhrumilmistry.tech> | ||
# COMMENTS: | ||
# This file describes how to deploy Backend-APIs | ||
# in a container with all dependencies installed. | ||
# USAGE: | ||
# # Download googlephish Dockerfile | ||
# wget [link] | ||
# | ||
# # Build image | ||
# docker build -t swsrp-backend-api . | ||
# | ||
# # run docker container | ||
# docker run -d -p 8000:8000 swsrp-backend-api | ||
# | ||
|
||
# choose baseimage | ||
FROM python:3.10 | ||
|
||
# set initial Working Directory | ||
WORKDIR / | ||
|
||
# create project directory and set as workding directory | ||
ENV PROJ_DIR="/Backend-APIs" | ||
RUN [ -d ${PROJ_DIR} ] || mkdir -p ${PROJ_DIR} | ||
WORKDIR ${PROJ_DIR} | ||
|
||
# copy project files | ||
COPY . . | ||
|
||
# add current directory to python path | ||
ENV PYTHONPATH=${PYTHONPATH}:${PWD} | ||
|
||
# install requirements | ||
RUN python -m pip install gunicorn | ||
RUN python -m pip install poetry | ||
RUN poetry config virtualenvs.create false | ||
RUN poetry install --no-root --only main | ||
|
||
# check for errors in application | ||
RUN python manage.py check | ||
|
||
# migrate database | ||
RUN python manage.py makemigrations | ||
RUN python manage.py migrate | ||
# --run-syncdb creates table without migrations | ||
RUN python manage.py migrate --run-syncdb | ||
|
||
# collect static images | ||
RUN python manage.py collectstatic | ||
|
||
# get build arguments (credentials) | ||
ARG dj_email=admin@localhost | ||
ARG dj_username=admin | ||
ARG dj_password=admin | ||
ARG dj_allowed_host=* | ||
ARG dj_debug=false | ||
|
||
# create superuser | ||
ENV DJANGO_SUPERUSER_EMAIL=${dj_email} | ||
ENV DJANGO_SUPERUSER_USERNAME=${dj_username} | ||
ENV DJANGO_SUPERUSER_PASSWORD=${dj_password} | ||
ENV ALLOWED_HOSTS=${dj_allowed_host} | ||
ENV DEBUG=${dj_debug} | ||
RUN python manage.py createsuperuser --noinput | ||
|
||
# expose ports | ||
EXPOSE 8000 | ||
|
||
# start application | ||
CMD [ "gunicorn", "backend_api.wsgi", "-b", "0.0.0.0:8000" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
swsrp-backend: | ||
image: dmdhrumilmistry/swsrp-backend-api | ||
ports: | ||
- 8000:8000 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.