Skip to content

Commit

Permalink
Refactor Dockerfile and Flask app config
Browse files Browse the repository at this point in the history
- Dockerfile: Remove redundant environment variable declaration
- Flask app: Remove code to override server name and environment variable assignment
- Flask app config: Update upload folder path, server name, and preferred URL scheme
  • Loading branch information
realashleybailey committed Sep 12, 2023
1 parent 48dbb48 commit 9b5cb16
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ RUN npm run build
RUN cp /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone

# Set Environment Variables
ENV APP_URL 127.0.0.1:5000
ENV TZ Etc/UTC

# Start Nginx in Background and Gunicon in Foreground
Expand Down
6 changes: 0 additions & 6 deletions backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
# environment="development" if app.debug else "production"
# )

# Override Flask server name if it contains http or https
if getenv("APP_URL") and getenv("APP_URL", "").startswith("http://") or getenv("APP_URL", "").startswith("https://"):
host = getenv("APP_URL").replace("http://", "").replace("https://", "")
app.config["SERVER_NAME"] = host
environ["APP_URL"] = host

# Run database migrations scripts
if not app.debug or getenv("MIGRATE"):
migrate()
Expand Down
5 changes: 2 additions & 3 deletions backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ def create_config(app: Flask):
config["SESSION_TYPE"] = "filesystem"
config["SESSION_FILE_DIR"] = path.join(base_dir, "../", "database", "sessions")
config["PERMANENT_SESSION_LIFETIME"] = timedelta(hours=5)
config["UPLOAD_FOLDER"] = path.join(base_dir, "database", "uploads")
config["UPLOAD_FOLDER"] = path.join(base_dir, "../", "database", "uploads")
config["SWAGGER_UI_DOC_EXPANSION"] = "list"
config["SERVER_NAME"] = getenv("APP_URL")
config["SERVER_NAME"] = "127.0.0.1:5000"
config["APPLICATION_ROOT"] = "/"
config["PREFERRED_URL_SCHEME"] = "https" if getenv("HTTPS", "false") == "true" else "http"
config["JWT_SECRET_KEY"] = secret_key()
config["JWT_BLACKLIST_ENABLED"] = True
config["JWT_TOKEN_LOCATION"] = ["headers", "json", "query_string"]
Expand Down

0 comments on commit 9b5cb16

Please sign in to comment.