Skip to content

Commit

Permalink
feat: Update GitHub Actions workflow and app configuration
Browse files Browse the repository at this point in the history
- Change runs-on value for build_ghcr and build_dh jobs in the beta-ci.yml GitHub Actions workflow from "self-hosted" to "ubuntu-latest" for consistency and reliability.
- Update the session file and upload folder paths in the app configuration file to use the definitions from the definitions module for better maintainability.
- Update the path to the latest file in the get_current_version function in the migrator module to use the LATEST_FILE definition for clarity and simplicity.
- Update the path to the latest file in the get_current_version function in the software_lifecycle module to use the LATEST_FILE definition for consistency and readability.
- Add new definitions to the definitions module for ROOT_DIR, LATEST_FILE, and DATABASE_DIR to improve configuration flexibility in different environments.
- Update the environment variable names in the Dockerfile for wizarr-backend and wizarr to use DATABASE_DIR and LATEST_FILE for consistency with the definitions module.
- Add a new environment variable LATEST_FILE to the Dockerfile for wizarr-frontend for consistency with the other Dockerfiles.
  • Loading branch information
realashleybailey committed Oct 22, 2023
1 parent 0a48c56 commit a21c762
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/beta-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
build_ghcr:
name: Build Digest for GHCR
runs-on: self-hosted
runs-on: ubuntu-latest
needs:
- before_build
strategy:
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:

build_dh:
name: Build Digest for Docker Hub
runs-on: self-hosted
runs-on: ubuntu-latest
needs:
- before_build
strategy:
Expand Down
11 changes: 4 additions & 7 deletions apps/wizarr-backend/wizarr_backend/app/config.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from datetime import timedelta
from os import environ, getenv, path

from os import environ, path
from flask import Flask

from app.security import secret_key, SchedulerAuth
from definitions import DATABASE_DIR

def create_config(app: Flask):
config = {}
base_dir = path.abspath(path.join(path.dirname(__file__), "../"))

config["SESSION_TYPE"] = "filesystem"
config["SESSION_FILE_DIR"] = path.join(base_dir, "../", "database", "sessions")
config["SESSION_FILE_DIR"] = path.join(DATABASE_DIR, "sessions")
config["PERMANENT_SESSION_LIFETIME"] = timedelta(hours=5)
config["UPLOAD_FOLDER"] = path.join(base_dir, "../", "database", "uploads")
config["UPLOAD_FOLDER"] = path.join(DATABASE_DIR, "uploads")
config["SWAGGER_UI_DOC_EXPANSION"] = "list"
config["SERVER_NAME"] = "127.0.0.1:5000"
config["APPLICATION_ROOT"] = "/"
Expand Down
7 changes: 2 additions & 5 deletions apps/wizarr-backend/wizarr_backend/app/migrator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
from packaging.version import parse
from datetime import datetime, timedelta

from definitions import ROOT_DIR
from definitions import LATEST_FILE

def get_current_version():
# File path to the version file
version_file = path.abspath(path.join(ROOT_DIR, "../", "../", "latest"))

# Read the current version
with open(version_file, "r") as f:
with open(LATEST_FILE, "r") as f:
current_version = parse(f.read())

return current_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from json import load
from app.models.database.base import db_dir

from definitions import ROOT_DIR
from definitions import LATEST_FILE

session = CachedSession(cache_name=path.join(db_dir, "wizarr_cache"), backend="sqlite", expire_after=3600, cache_control=True, stale_if_error=True, allowable_codes=[200])

Expand Down Expand Up @@ -35,8 +35,7 @@ def get_latest_beta_version():
return None

def get_current_version():
package = path.abspath(path.join(ROOT_DIR, "../", "../", "latest"))
with open(package, "r", encoding="utf-8") as f:
with open(LATEST_FILE, "r", encoding="utf-8") as f:
return parse(f.read())


Expand Down
6 changes: 4 additions & 2 deletions apps/wizarr-backend/wizarr_backend/definitions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from os import path, environ
from os import path, getenv

ROOT_DIR = path.dirname(path.join(path.abspath(__file__), "../", "../"))
ROOT_DIR = getenv("ROOT_DIR", path.abspath(path.join(path.abspath(__file__), "../")))
LATEST_FILE = getenv("LATEST_FILE", path.join(ROOT_DIR, "../", "../", "../", "latest"))
DATABASE_DIR = getenv("DATABASE_DIR", path.join(ROOT_DIR, "../", "database"))
3 changes: 2 additions & 1 deletion dockerfiles/wizarr-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ RUN chmod +x /root/.bashrc
COPY ../../latest /

# Environment Variables
ENV DB_DIR=/data/database
ENV DATABASE_DIR=/data/database
ENV LATEST_FILE=/latest

# Set Entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]
3 changes: 3 additions & 0 deletions dockerfiles/wizarr-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ RUN chmod +x /root/.bashrc
# Copy latest file
COPY ../../latest /

# Environment Variables
ENV LATEST_FILE=/latest

# Set Entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]
3 changes: 2 additions & 1 deletion dockerfiles/wizarr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ RUN chmod +x /root/.bashrc
COPY ../../latest /

# Environment Variables
ENV DB_DIR=/data/database
ENV DATABASE_DIR=/data/database
ENV LATEST_FILE=/latest

# Set Entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]

0 comments on commit a21c762

Please sign in to comment.