Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerised the Application #11

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
94cc103
init docker
manav1403 Dec 30, 2020
7492f80
FIXED AZURE SERVER BUGS
Jan 1, 2021
975b483
test
killbotXD Jan 1, 2021
ad01787
inhome banner and timeline ui
manav1403 Jan 3, 2021
6e45a81
Merge pull request #1 from manav1403/frontend-change
manav1403 Jan 3, 2021
5d105ce
Add Particle JS
killbotXD Jan 3, 2021
301834c
Update Dependencies
killbotXD Jan 3, 2021
511af39
Update package-lock.json
killbotXD Jan 3, 2021
55d1c4b
format timeline style and fix timeline width
killbotXD Jan 4, 2021
ab54069
Change width to 40%
killbotXD Jan 4, 2021
ede8197
update year in Title
killbotXD Jan 4, 2021
a922797
Update Timeline.vue
manav1403 Jan 7, 2021
cde477e
Update Timeline.vue
manav1403 Jan 7, 2021
2901dc0
add github to mentor serializer
killbotXD Jan 7, 2021
d549d8b
Add linked in field to base model
killbotXD Jan 7, 2021
935c4fa
Add social links to mentor profile
killbotXD Jan 7, 2021
bb7e06c
add social link to serializer fields
killbotXD Jan 7, 2021
7da804a
fixed teeny error with social links
killbotXD Jan 7, 2021
7196c82
add linkedIn text field
killbotXD Jan 7, 2021
9890785
add linked in text Field on student profile
killbotXD Jan 7, 2021
4a3d767
changed a decoration
manav1403 Jan 7, 2021
c8c4239
add linked in to store
killbotXD Jan 7, 2021
1dbcf88
add linkedIn field in student store
killbotXD Jan 7, 2021
19b6434
fix setter name
killbotXD Jan 7, 2021
3cd0834
add linekdIn to Create user profile
killbotXD Jan 7, 2021
42b16e2
add linked in field to create student profile
killbotXD Jan 7, 2021
3775592
fixed typo in mentor profile
killbotXD Jan 7, 2021
0e7d1c7
fix typo in student profile
killbotXD Jan 7, 2021
9fa3ab8
fix typo in object name
killbotXD Jan 7, 2021
6070125
add github and linked in to user serializer
killbotXD Jan 7, 2021
161d9d8
fix mentor profile typo
killbotXD Jan 7, 2021
bcaa7ee
fix error that i thought was there but was not
killbotXD Jan 7, 2021
adfadfc
fix typo
killbotXD Jan 7, 2021
03b4fa2
Update Manuals
killbotXD Jan 8, 2021
eafd581
added sudo aibranch
manav1403 Jan 11, 2021
1f2b192
sudo ai branch
manav1403 Jan 11, 2021
73d98db
ADD: new branches
manav1403 Jan 12, 2021
eacdc57
ADD: new branches
manav1403 Jan 12, 2021
abd83b2
ADD: new branches
manav1403 Jan 12, 2021
3397bf5
UPDATED PORT FOR HTTPS CERTIFICATE
manav1403 Feb 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BUILD_NAME=robotics-web
BUILD_TAG=$$(git log -1 --pretty=%h)

build:
@docker build -t ${BUILD_NAME}-backend:${BUILD_TAG} -t ${BUILD_NAME}-backend:latest -f backend/Dockerfile backend
@docker build -t ${BUILD_NAME}-frontend:${BUILD_TAG} -t ${BUILD_NAME}-frontend:latest -f frontend/Dockerfile frontend

.env:
@cp .env.example .env

dev-start: .env
@docker-compose up -d

dev-stop:
@docker-compose down

dev-logs:
@docker-compose logs -f

exec:
@docker exec -it $$(echo "$$(docker ps --filter "name=django")" | awk 'NR > 1 {print $$1}') sh

pull:
@git pull origin master
497 changes: 0 additions & 497 deletions Pipfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Requirements:
- Python 3.6 runtime
- Django 2.1.2
- Other dependencies in `Pipfile`

why are you bad
> For Vuetify UI build steps, follow [this](ui/README.md)

Procedure:
Expand Down
80 changes: 80 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: '3'
services:
django:
build:
context: src
dockerfile: Dockerfile
image: 'dl-woc-django:latest'
container_name: django
restart: unless-stopped
env_file: .env
environment:
- DB_HOST=postgresql
- MODE=Development-docker
- REDIS_HOST=redis
ports:
- 8000:8000
volumes:
- ./src:/app
depends_on:
- postgresql
- redis
networks:
- app-network
command:
- /bin/sh
- -c
- |
python manage.py flush --no-input
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 0.0.0.0:8000
vue:
build:
context: ui
dockerfile: Dockerfile
image: 'dl-woc-vue:latest'
container_name: vue
restart: unless-stopped
ports:
- 8080:8080
volumes:
- ./ui:/app
- /app/node_modules
depends_on:
- django
networks:
- app-network
command: npm run dev
postgresql:
image: 'bitnami/postgresql:latest'
container_name: postgresql
restart: unless-stopped
env_file: .env
environment:
- POSTGRESQL_USERNAME=$DB_USER
- POSTGRESQL_PASSWORD=$DB_PASSWORD
- POSTGRESQL_DATABASE=$DB_NAME
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $DB_USER"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- dbdata:/bitnami/postgresql
networks:
- app-network
redis:
image: redis:alpine
container_name: redis01
ports:
- "6379:6379"
networks:
- app-network

networks:
app-network:
driver: bridge

volumes:
dbdata:
24 changes: 24 additions & 0 deletions production/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SECRET_KEY=s=#*8(rzoq=+@7nn04b!w6ivfubd=(n!=%jw%$n_l=b&x@rpdd
ALLOWED_HOSTS=*
DEBUG=True
STATIC_PATH=../../staticfiles
MEDIA_PATH=../../media

# Database configs
SQLITE_DB=True

DB_HOST=postgres
DB_NAME=wocdb
DB_USER=wocuser
DB_PASSWORD=password

# Email configs

EMAIL_ID=''
EMAIL_PASSWORD=''

# Social Auth configs
GOOGLE_OAUTH2_KEY=replace_with_your_key
GOOGLE_OAUTH2_SECRET=replace_with_your_secret

# other configs
27 changes: 27 additions & 0 deletions production/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
BUILD_NAME=robotics-web
BUILD_TAG=$$(git log -1 --pretty=%h)

build:
@docker build -t ${BUILD_NAME}-backend:${BUILD_TAG} -t ${BUILD_NAME}-backend:latest -f backend/Dockerfile backend
@docker build -t ${BUILD_NAME}-frontend:${BUILD_TAG} -t ${BUILD_NAME}-frontend:latest -f frontend/Dockerfile frontend

.env:
@cp .env.example .env

launch: .env
@docker-compose up -d

stop:
@docker-compose down

logs:
@docker-compose logs -f

ex-django:
@docker exec -it $$(echo "$$(docker ps --filter "name=django")" | awk 'NR > 1 {print $$1}') sh

ex-vue:
@docker exec -it $$(echo "$$(docker ps --filter "name=vue")" | awk 'NR > 1 {print $$1}') sh

ex-postgresql:
@docker exec -it $$(echo "$$(docker ps --filter "name=postgresql")" | awk 'NR > 1 {print $$1}') sh
84 changes: 84 additions & 0 deletions production/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
version: '3'
services:
django:
build:
context: ../src
dockerfile: Dockerfile.prod
image: 'woc-src-1:latest'
container_name: django
restart: unless-stopped
env_file: .env
environment:
- DB_HOST=postgresql
- MODE=Production
- PORT=8000
- REDIS_HOST=redis
ports:
- 8000:8000
volumes:
- django_static_files:/app/staticfiles
- django_media_files:/app/media
- ../src:/app
depends_on:
- postgresql
- redis
networks:
- app-network
command: gunicorn -b :8000 woc.wsgi

vue:
build:
context: ../ui
dockerfile: Dockerfile.prod
image: 'woc-ui-1:latest'
container_name: vue
restart: unless-stopped
env_file: .env
environment:
- BACKEND_HOST=django
ports:
- 8088:80
volumes:
- django_static_files:/usr/share/nginx/html/static
- django_media_files:/usr/share/nginx/html/media
depends_on:
- django
networks:
- app-network

postgresql:
image: 'bitnami/postgresql:latest'
container_name: postgresql
restart: unless-stopped
env_file: .env
environment:
- POSTGRESQL_USERNAME=$DB_USER
- POSTGRESQL_PASSWORD=$DB_PASSWORD
- POSTGRESQL_DATABASE=$DB_NAME
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $DB_USER"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- dbdata:/bitnami/postgresql
networks:
- app-network

redis:
image: redis:alpine
container_name: redis01
restart: unless-stopped
networks:
- app-network

networks:
app-network:
driver: bridge

volumes:
dbdata:
driver: local
django_static_files:
django_media_files:
driver: local
3 changes: 3 additions & 0 deletions src/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./**/__pycache__/
./**/migrations/*
!./**/migrations/__init__.py
15 changes: 15 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.6-alpine

ARG BUILD_DEPS="gcc python3-dev musl-dev postgresql-dev jpeg-dev zlib-dev libjpeg libressl-dev libffi-dev"
RUN apk --no-cache add ${BUILD_DEPS}
RUN pip install --upgrade pip
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* ./
RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy --ignore-pipfile --dev \
&& find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' \+

WORKDIR /app
COPY . /app
27 changes: 27 additions & 0 deletions src/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM python:3.6-alpine AS base

ENV PYROOT /pyroot
ENV PYTHONUSERBASE $PYROOT

# Build Container
ARG BUILD_DEPS="gcc python3-dev musl-dev postgresql-dev jpeg-dev zlib-dev libjpeg libressl-dev libffi-dev"
RUN apk --no-cache add ${BUILD_DEPS}
RUN pip install --upgrade pip
RUN pip install pipenv
COPY Pipfile* Pipfile.lock* ./
RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy --ignore-pipfile --dev \
&& find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' \+

ARG RUNTIME_DEPS="libcrypto1.1 libssl1.1 libpq"
RUN apk --no-cache add ${RUNTIME_DEPS}
RUN pip install gunicorn

WORKDIR /app
COPY . /app
COPY ./entrypoint.sh /home/entrypoint.sh
RUN chmod +x /home/entrypoint.sh
ENTRYPOINT [ "/home/entrypoint.sh" ]

3 changes: 2 additions & 1 deletion Pipfile → src/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ django-cleanup = "==2.1.0"
social-auth-app-django = "==2.1.0"
djangorestframework = "==3.8.2"
psycopg2 = "==2.7.5"
requests = "*"

[dev-packages]
flake8 = "==3.5.0"
drf-yasg = "*"
drf-yasg = "==1.10.0"
flex = "*"
coveralls = "*"
swagger-spec-validator = "*"
Expand Down
Loading