Skip to content

Commit

Permalink
Added the templating details
Browse files Browse the repository at this point in the history
  • Loading branch information
prakass1 committed May 16, 2021
1 parent 74b5fcb commit 5afc91a
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 67 deletions.
84 changes: 49 additions & 35 deletions .env_template
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
APP_CONFIG = "test" # dev, test, prod are the options
FLASK_BLOG_PORT = 9080
FLASK_ADMIN_PORT = 5001
FLASK_HOST = 0.0.0.0
DB_USER = "root" # change according to the env
DB_PASSWORD = "root123" # change according to the env
#DB_DATABASE_NAME = "blog" # change according to the env
DB_DRIVER = "mysql"
#DB_HOST = "mysql_db" # use while on docker
#Local computer running DB
#DB_HOST = "192.168.56.99"
DB_HOST = "localhost"
#DB_NAME = "blog"
DB_NAME = "test_blog"
DB_PORT = "3306"
# dev, test, prod are the options
APP_CONFIG=dev
FLASK_BLOG_PORT=9090
FLASK_ADMIN_PORT=5005
FLASK_HOST=0.0.0.0
# change according to the env
DB_USER=root
# change according to the env
DB_PASSWORD=strongpassword
# change according to the env
DB_DRIVER=mysql
# use while on docker. Cannot change the container name
DB_HOST=mysql_db
#Local computer running DB (If running db separetly)
#DB_HOST=localhost
# Database name of your wish
DB_NAME=yourblogdb
# Change to test db when working with testing
#DB_NAME=test_blog
# Default mysql port specification
DB_PORT=3306

#ReCaptcha Config
RECAPTCHA_SITE_KEY = "6LfHcysUAAAAALzzACVKdZD6vsvzQavcIAOR5e4b"
RECAPTCHA_SITE_SECRET = "6LfHcysUAAAAANsjuS8ZpyCUdcFUITJ9Spt1hVuO"
RECAPTCHA_SITE_KEY=YOURRECAPTCHA_SITE_KEY
RECAPTCHA_SITE_SECRET=YOURRECAPTCHA_SECRET

#SMTP Configs (Email and password of the blog email generated)
MAIL_USERNAME=admin@xyz.com
MAIL_PASSWORD=verystrongpassword

# Caching app config. (Leave it default for basic caching)
CACHE_TYPE=simple
CACHE_DEFAULT_TIMEOUT=300

# Upload of image folder
SECRET_KEY=yoursecret
UPLOAD_FOLDER=uploads

#SMTP Configs
MAIL_USERNAME = "blog.noreply.13241@gmail.com"
MAIL_PASSWORD = "sxylkelwpwpdmujx"
# The setting for admin user/password. This will be anyway changed
ADMIN_USERNAME=youradminusername
PASSWORD=useradminpassword
# The first name, accessible for posting
F_NAME=AuthorFirstName
EMAIL=AuthorEmailId

#Default post limit leave it to 10
post_init_limit=10

# Caching app config
CACHE_TYPE = "simple"
CACHE_DEFAULT_TIMEOUT = 300
SECRET_KEY = 'a1fc6623c9a17ea21d882666dc54cd50a68654a136c448ab26adfebce7ed932e98fdea'
UPLOAD_FOLDER = "uploads"
ADMIN_USERNAME = "admin" # The setting for admin user/password
PASSWORD = "root123"
F_NAME = "Subash" # The first name, accessible for posting
EMAIL = "subash.prakash0807@gmail.com"
post_init_limit = 10
#Blog content details
blog_header = "Subash Blog"
blog_subheader = "Blog on daily activities"
social_git = "https://www.github.com/prakass1"
social_linkedin = "https://www.linkedin.com/in/subash-prakash-82a1543b/"
social_stack = "https://stackoverflow.com/users/3414466/coldy?tab=profile"
blog_header="Subash Blog"
blog_subheader="Blog on daily activities"
social_git="https://www.github.com/prakass1"
social_linkedin="https://www.linkedin.com/in/subash-prakash-82a1543b/"
social_stack="https://stackoverflow.com/users/3414466/coldy?tab=profile"
1 change: 1 addition & 0 deletions blog/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COPY SimplisticBlogger/blog /app/blog
COPY SimplisticBlogger/requirements.txt /app/blog
COPY SimplisticBlogger/common /app/common
COPY SimplisticBlogger/instance /app/instance
COPY SimplisticBlogger/.env /app/blog
WORKDIR /app/blog

RUN pip install --upgrade pip
Expand Down
11 changes: 4 additions & 7 deletions blog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from os import environ
from dotenv import load_dotenv, find_dotenv
from flask_wtf.csrf import CSRFProtect
from flask_mail import Mail

load_dotenv(find_dotenv(raise_error_if_not_found=True))

from instance.config import app_config
from common import db, cache
from common import db, cache, mail

load_dotenv(find_dotenv())

blog_header = environ.get("blog_header")
blog_subheader = environ.get("blog_subheader")
Expand All @@ -18,12 +16,11 @@
social_stack = "#" if environ.get(
"social_stack") == "" else environ.get("social_stack")

resp = resp = {"blog_header": blog_header, "blog_subheader": blog_subheader,
resp = {"blog_header": blog_header, "blog_subheader": blog_subheader,
"social_git": social_git, "social_linkedin": social_linkedin, "social_stack": social_stack}


csrf_protect = CSRFProtect()
mail = Mail()

def create_app(config_name):
# More on DB init here...
Expand Down
1 change: 1 addition & 0 deletions blog_admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COPY SimplisticBlogger/blog_admin /app/blog_admin
COPY SimplisticBlogger/requirements.txt /app/blog_admin
COPY SimplisticBlogger/common /app/common
COPY SimplisticBlogger/instance /app/instance
COPY SimplisticBlogger/.env /app/blog_admin
WORKDIR /app/blog_admin

RUN pip install --upgrade pip
Expand Down
3 changes: 1 addition & 2 deletions blog_admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
from flask_login import LoginManager
from common import db, cache
from flask_wtf.csrf import CSRFProtect
from flask_mail import Mail
from common import mail

login_manager = LoginManager()
csrf_protect = CSRFProtect()
mail = Mail()

username = environ.get("ADMIN_USERNAME")
password = environ.get("PASSWORD")
Expand Down
3 changes: 3 additions & 0 deletions common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from flask_sqlalchemy import SQLAlchemy
from flask_caching import Cache
from flask_mail import Mail


db = SQLAlchemy()
cache = Cache()
mail = Mail()
2 changes: 1 addition & 1 deletion common/services/utility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from os import environ
from common.models import comments_model
from flask_mail import Message
from blog_admin import mail
from common import mail

def check_reply(comment, post_obj):
refer_names = list()
Expand Down
22 changes: 22 additions & 0 deletions docker-compose-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3.3"
networks:
backend-network:
services:
mysql_db:
image: "mysql:latest"
restart: "always"
command: "--default-authentication-plugin=mysql_native_password"
container_name: "mysql_db"
env_file: ".env"
volumes:
- mysql-data:/var/lib/mysql
ports:
- "3308:${DB_PORT}"
environment:
- "MYSQL_ROOT_PASSWORD=${DB_PASSWORD}"
- "MYSQL_DATABASE=${DB_NAME}"
networks:
- "backend-network"

volumes:
mysql-data:
24 changes: 2 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ services:
blog-app:
container_name: "blog_app"
restart: "always"
depends_on:
- "blog-admin-app"
# - "mysql_db"
# depends_on:
# - "blog-admin-app"
build:
context: ..
dockerfile: SimplisticBlogger/blog/Dockerfile
Expand All @@ -29,22 +28,3 @@ services:
- "9000:${FLASK_ADMIN_PORT}"
networks:
- "backend-network"

# mysql_db:
# #image: "mysql:latest"
# restart: "always"
# command: "--default-authentication-plugin=mysql_native_password"
# container_name: "mysql_db"
# env_file: ".env"
# #volumes:
# # - mysql-data:/var/lib/mysql
# ports:
# - "3308:${DB_PORT}"
# environment:
# MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
# MYSQL_DATABASE: "${DB_NAME}"
# networks:
# - "backend-network"

#volumes:
# mysql-data:

0 comments on commit 5afc91a

Please sign in to comment.