Skip to content

Commit c644160

Browse files
committed
initiated the boiler plate
1 parent 6153d1b commit c644160

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+14595
-2
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**/*.pyc
2+
**/*.pyo
3+
**/*.log
4+
**/*.egg-info
5+
**/__pycache__
6+
.venv/
7+
8+
**/node_modules/
9+
.travis.yml
10+
.env
11+
.env.example
12+
.git/
13+
.gitignore
14+
.idea/
15+
.gitmodules
16+
db.sqlite3

.env.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SECRET_KEY='dcyz)+52d)n1f3d6dsf&g0p6a($(v4&rvu=9u3u6fib9=kzy$8'
2+
ALLOWED_HOSTS=*
3+
DEBUG=True
4+
5+
# Database configs
6+
7+
DB_NAME=roboweb
8+
DB_USER=robouser
9+
DB_PASSWORD=password
10+
11+
# Email configs
12+
13+
SERVER_EMAIL=noreply@localhost.com
14+
SERVER_EMAIL_PASSWORD=password
15+
16+
# other configs

.gitignore

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
*.sqlite3
27+
**/migrations/*
28+
!**/migrations/__init__.py
29+
staticfiles/
30+
media/
31+
.idea/
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
.hypothesis/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
62+
# Flask stuff:
63+
instance/
64+
.webassets-cache
65+
66+
# Scrapy stuff:
67+
.scrapy
68+
69+
# Sphinx documentation
70+
docs/_build/
71+
72+
# PyBuilder
73+
target/
74+
75+
# Jupyter Notebook
76+
.ipynb_checkpoints
77+
78+
# pyenv
79+
.python-version
80+
81+
# celery beat schedule file
82+
celerybeat-schedule
83+
84+
# SageMath parsed files
85+
*.sage.py
86+
87+
# dotenv
88+
.env
89+
90+
# virtualenv
91+
.venv
92+
venv/
93+
ENV/
94+
95+
# Spyder project settings
96+
.spyderproject
97+
.spyproject
98+
99+
# Rope project settings
100+
.ropeproject
101+
102+
# mkdocs documentation
103+
/site
104+
105+
# mypy
106+
.mypy_cache/
107+
.DS_Store
108+
109+
110+
# Database
111+
tadb
112+
db.sqlite3
113+
114+
# VueJS files
115+
node_modules/
116+
/dist/
117+
npm-debug.log*
118+
yarn-debug.log*
119+
yarn-error.log*
120+
/test/unit/coverage
121+
/test/e2e/reports
122+
selenium-debug.log
123+
ui/src/config/index.js
124+
125+
# Editor directories and files
126+
.idea
127+
*.suo
128+
*.ntvs*
129+
*.njsproj
130+
*.sln
131+
132+
npm-debug.log
133+
yarn-error.log
134+
135+
# Editor directories and files
136+
*.sln.DS_Store
137+
node_modules
138+
/dist
139+
140+
/tests/e2e/videos/
141+
/tests/e2e/screenshots/
142+
143+
# local env files
144+
.env.local
145+
.env.*.local
146+
147+
# Editor directories and files
148+
.vscode
149+
*.sw?

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: python
2+
python:
3+
- "3.6"
4+
addons:
5+
postgresql: "9.6"
6+
dist: xenial
7+
before_script:
8+
- cp .env.example .env
9+
- psql -c "CREATE DATABASE robodb;" -U postgres
10+
- psql -c "CREATE USER robouser WITH LOGIN PASSWORD 'password';" -U postgres
11+
- psql -c "ALTER ROLE robouser WITH CREATEDB;" -U postgres
12+
- psql -c "GRANT ALL PRIVILEGES ON DATABASE robodb TO robouser;" -U postgres
13+
before_install:
14+
- export DJANGO_SETTINGS_MODULE=config.settings
15+
install:
16+
- pip3 install pipenv
17+
- pipenv install --dev
18+
script:
19+
- source "$(pipenv --venv)"/bin/activate
20+
- cd backend
21+
- flake8 .
22+
- python manage.py makemigrations
23+
- python manage.py migrate
24+
- cd ../frontend
25+
- npm install
26+
- npm run build

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
BUILD_NAME=robotics-web
2+
BUILD_TAG=$$(git log -1 --pretty=%h)
3+
4+
build:
5+
@docker build -t ${BUILD_NAME}-backend:${BUILD_TAG} -t ${BUILD_NAME}-backend:latest -f backend/Dockerfile backend
6+
@docker build -t ${BUILD_NAME}-frontend:${BUILD_TAG} -t ${BUILD_NAME}-frontend:latest -f frontend/Dockerfile frontend
7+
8+
.env:
9+
@cp .env.example .env
10+
11+
dev-start: .env
12+
@docker-compose up -d
13+
14+
dev-stop:
15+
@docker-compose down
16+
17+
dev-logs:
18+
@docker-compose logs -f
19+
20+
exec:
21+
@docker exec -it $$(echo "$$(docker ps --filter "name=django")" | awk 'NR > 1 {print $$1}') sh

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# web-portal
2-
The source code for the robotics club website.
1+
## Getting Started
2+
3+
Ensure that you have installed [Docker](https://docs.docker.com/install/) (with [Docker Compose](https://docs.docker.com/compose/install/)).
4+
5+
Run the development server:
6+
```
7+
cd <project_directory_name>
8+
make dev-start
9+
```
10+
11+
After executing `make dev-start`, you will be running:
12+
* The application on http://localhost:8080
13+
* The API Server on http://localhost:8000
14+
15+
Make database migrations:
16+
```
17+
make exec
18+
python manage.py makemigrations
19+
python manage.py migrate
20+
```
21+
22+
Create a superuser:
23+
```
24+
make exec
25+
python manage.py createsuperuser
26+
```
27+
28+
View logs of docker containers:
29+
```
30+
make dev-logs
31+
```
32+
33+
To stop the development server:
34+
```
35+
make dev-stop

backend/.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 130

backend/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM python:3.6-alpine AS base
2+
3+
ENV PYROOT /pyroot
4+
ENV PYTHONUSERBASE $PYROOT
5+
6+
# Build Container
7+
FROM base AS builder
8+
ARG BUILD_DEPS="gcc python3-dev musl-dev postgresql-dev"
9+
RUN apk --no-cache add ${BUILD_DEPS}
10+
RUN pip install pipenv
11+
COPY Pipfile* ./
12+
RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy \
13+
&& find /usr/local \
14+
\( -type d -a -name test -o -name tests \) \
15+
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
16+
-exec rm -rf '{}' \+
17+
18+
# Runtime Container
19+
FROM base
20+
ARG RUNTIME_DEPS="libcrypto1.1 libssl1.1 libpq"
21+
RUN apk --no-cache add ${RUNTIME_DEPS}
22+
COPY --from=builder $PYROOT/lib/ $PYROOT/lib/
23+
RUN pip install gunicorn
24+
25+
WORKDIR /app
26+
COPY . /app
27+
28+
CMD gunicorn -b :$PORT config.wsgi

backend/Dockerfile.prod

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.6-alpine AS base
2+
3+
ENV PYROOT /pyroot
4+
ENV PYTHONUSERBASE $PYROOT
5+
6+
# Build Container
7+
FROM base AS builder
8+
ARG BUILD_DEPS="gcc python3-dev musl-dev postgresql-dev"
9+
RUN apk --no-cache add ${BUILD_DEPS}
10+
RUN pip install pipenv
11+
COPY Pipfile* ./
12+
RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy \
13+
&& find /usr/local \
14+
\( -type d -a -name test -o -name tests \) \
15+
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
16+
-exec rm -rf '{}' \+
17+
18+
# Runtime Container
19+
FROM base AS dep-stage
20+
ARG RUNTIME_DEPS="libcrypto1.1 libssl1.1 libpq"
21+
RUN apk --no-cache add ${RUNTIME_DEPS}
22+
COPY --from=builder $PYROOT/lib/ $PYROOT/lib/
23+
RUN pip install gunicorn
24+
25+
WORKDIR /app
26+
COPY . /app
27+
RUN ls
28+
RUN python manage.py collectstatic --no-default-ignore
29+
CMD gunicorn -b :8000 config.wsgi
30+
31+
# production stage
32+
#FROM nginx:stable-alpine as production-stage

backend/Pipfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
flake8 = "*"
8+
9+
[packages]
10+
django = "==2.2.9"
11+
psycopg2 = "==2.8.4"
12+
django-decouple = "==2.1"
13+
social-auth-app-django = "==2.1.0"
14+
djangorestframework = "==3.10.2"
15+
16+
[requires]
17+
python_version = "3.6"

0 commit comments

Comments
 (0)