diff --git a/docs/docs/assets/img/docker-diagram.drawio.svg b/docs/docs/assets/img/docker-diagram.drawio.svg new file mode 100644 index 000000000000..2846ff432c43 --- /dev/null +++ b/docs/docs/assets/img/docker-diagram.drawio.svg @@ -0,0 +1,294 @@ + + + + + + + + + +
+
+
+ Docker +
+
+
+
+ + Docker + +
+
+ + + + +
+
+
+ mealie-api +
+
+
+
+ + mealie-api + +
+
+ + + + + +
+
+
+ HTTP +
+
+
+
+ + HTTP + +
+
+ + + + +
+
+
+ mealie-frontend +
+
+
+
+ + mealie-frontend + +
+
+ + + + + +
+
+
+ mealie-data +
+
+
+
+ + mealie-data + +
+
+ + + + + +
+
+
+ /app/data +
+
+
+
+ + /app/data + +
+
+ + + + + +
+
+
+ /app/data/ +
+
+
+
+ + /app/data/ + +
+
+ + + + +
+
+
+ Client +
+
+
+
+ + Client + +
+
+ + + + + + +
+
+
+ 9925:3000 +
+
+
+
+ + 9925:3000 + +
+
+ + + + + +
+
+
+ HTTP +
+
+
+
+ + HTTP + +
+
+ + + + +
+
+
+ (1) +
+
+
+
+ + (1) + +
+
+ + + + +
+
+
+ (2) +
+
+
+
+ + (2) + +
+
+ + + + +
+
+
+ (3) +
+
+
+
+ + (3) + +
+
+ + + + +
+
+
+ (3) +
+
+
+
+ + (3) + +
+
+ + + + +
+
+
+ Container +
+
+
+
+ + Container + +
+
+ + + + +
+
+
+ Container +
+
+
+
+ + Container + +
+
+
+ + + + + Viewer does not support full SVG 1.1 + + + +
diff --git a/docs/docs/documentation/getting-started/installation/installation-checklist.md b/docs/docs/documentation/getting-started/installation/installation-checklist.md index 7b56a8c94c76..220d2e5b06de 100644 --- a/docs/docs/documentation/getting-started/installation/installation-checklist.md +++ b/docs/docs/documentation/getting-started/installation/installation-checklist.md @@ -26,8 +26,8 @@ To deploy mealie on your local network it is highly recommended to use docker to Due to a build dependency limitation, Mealie is not supported on 32bit ARM systems. If you're running into this limitation on a newer Raspberry Pi, please consider upgrading to a 64bit operating system on the Raspberry Pi. -## Step 1: Deciding on Deployment Type -SQLite is a popular, open source, self-contained, zero-configuration database that is the ideal choice for Mealie when you have 1-20 Users and your concurrent write operations will be some-what limited. If you need to support many concurrent users, you may want to consider a more robust database such as PostgreSQL. +## Step 1: Deployment Type +SQLite is a popular, open source, self-contained, zero-configuration database that is the ideal choice for Mealie when you have 1-20 Users and your concurrent write operations will be some-what limited. If you need to support many concurrent users, you may want to consider a more robust database such as PostgreSQL. You can find the relevant ready to use docker-compose files for supported installations at the links below. @@ -36,7 +36,7 @@ You can find the relevant ready to use docker-compose files for supported instal ## Step 2: Setting up your files. -The following steps were tested on a Ubuntu 20.04 server, but should work for most other Linux distributions. These steps are not required, but is how I generally will setup services on my server. +The following steps were tested on a Ubuntu 20.04 server, but should work for most other Linux distributions. These steps are not required, but is how I generally will setup services on my server. 1. SSH into your server and navigate to the home directory of the user you want to run Mealie as. If that is your current user, you can use `cd ~` to ensure you're in the right directory. @@ -56,8 +56,8 @@ After you've decided setup the files it's important to set a few ENV variables t - [x] You've set the `DEFAULT_EMAIL` and `DEFAULT_GROUP` variable. - [x] Make any theme changes on the frontend container. [See Frontend Config](./frontend-config.md#themeing) -## Step 3: Startup -After you've configured your database, and updated the `docker-compose.yaml` files, you can start Mealie by running the following command in the directory where you've added your `docker-compose.yaml`. +## Step 3: Startup +After you've configured your database, and updated the `docker-compose.yaml` files, you can start Mealie by running the following command in the directory where you've added your `docker-compose.yaml`. ```bash $ docker-compose up -d @@ -71,7 +71,28 @@ You should see the containers start up without error. You should now be able to **Password:** MyPassword -## Step 4: Backup -While v1.0.0 is a great step to data-stability and security, it's not a backup. As a core feature, Mealie will run a backup every 24 hours. Optionally, you can also run backups whenever you'd like through the UI or the API. +## Step 4: Validate Installation -These backups are just plain .zip files that you can download from the UI or access via the mounted volume on your system. For complete data protection you MUST store these backups somewhere safe, and outside of the server where they are deployed. A favorite solution of mine is [autorestic](https://autorestic.vercel.app/) which can be configured via yaml to run an off-site backup on a regular basis. \ No newline at end of file +After the startup is complete you should see a login screen. Use the default credentials above to login and navigate to `/admin/site-settings`. Here you'll find a summary of your configuration details and their respective status. Before proceeding you should validate that the configuration is correct. For any warnings or errors the page will display an error and notify you of what you need to verify. + +!!! tip "Docker Volume" + Mealie uses a shared data-volume between the Backend and Frontend containers for images and assets. Ensure that this is configured correctly by using the "Docker Volume Test" section in the settings page. Running this validation will ensure that you have configured your volumes correctly. Mealie will not work correctly without this configured correctly. + +## Step 5: Backup +While v1.0.0 is a great step to data-stability and security, it's not a backup. Mealie provides a full site data backup mechanism through the UI. + +These backups are just plain .zip files that you can download from the UI or access via the mounted volume on your system. For complete data protection you MUST store these backups somewhere safe, and outside of the server where they are deployed. + +## Appendix + +### Docker Diagram + +While the docker-compose file should work without modification, some users want to tailor it to their installation. This diagram shows network and volume architecture for the default setup. You can use this to help you customize your configuration. + +![Docker Diagram](../../../assets/img/docker-diagram.drawio.svg) + +In the diagram above there's a few crutial things to note. + +1. Port 9925 is the host port, this can be anything you want. The important part is that it's mapped to the mealie-frontend container at port 3000. +2. The mealie-frontend container communicated with the mealie-api container through the INTERNAL docker network. This requires that the two containers are on the same network and that the network supports name resolution (anything but the default bridge network). The resolution URL can be specified in the docker-compose as the `API_URL` environment variable. +3. The mealie-data volume is mounted to BOTH the mealie-frontend and mealie-api containers. This is REQUIRED to ensure that images and assets are severed up correctly. While the default configuration is a docker-volume, that same can be accomplished by using a local directory mounted to the containers. diff --git a/docs/docs/documentation/getting-started/installation/postgres.md b/docs/docs/documentation/getting-started/installation/postgres.md index d7ec31a7d05c..8afc27e5f464 100644 --- a/docs/docs/documentation/getting-started/installation/postgres.md +++ b/docs/docs/documentation/getting-started/installation/postgres.md @@ -1,7 +1,5 @@ # Installing with PostgreSQL -Postgres support was introduced in v0.5.0. At this point it should be used with caution and frequent backups. - **For Environmental Variable Configuration See:** - [Frontend Configuration](/mealie/documentation/getting-started/installation/frontend-config/) diff --git a/frontend/Caddyfile b/frontend/Caddyfile index 7302862d9f1a..2ee7a4af7d3c 100644 --- a/frontend/Caddyfile +++ b/frontend/Caddyfile @@ -20,13 +20,19 @@ file_server } - # Handles User Images + # Handles User Images handle_path /api/media/users/* { header @static Cache-Control max-age=31536000 root * /app/data/users/ file_server } + # Handle Docker Volume Validation File + handle_path /api/media/docker/* { + root * /app/data/docker-validation/ + file_server + } + handle @apidocs { uri strip_suffix / @@ -37,4 +43,4 @@ uri strip_suffix / reverse_proxy http://127.0.0.1:3001 } -} \ No newline at end of file +} diff --git a/frontend/api/admin/admin-about.ts b/frontend/api/admin/admin-about.ts index 3c50a2f299fc..172e5cf3b284 100644 --- a/frontend/api/admin/admin-about.ts +++ b/frontend/api/admin/admin-about.ts @@ -1,5 +1,5 @@ import { BaseAPI } from "../_base"; -import { AdminAboutInfo } from "~/types/api-types/admin"; +import { AdminAboutInfo, DockerVolumeText, CheckAppConfig } from "~/types/api-types/admin"; const prefix = "/api"; @@ -7,25 +7,10 @@ const routes = { about: `${prefix}/admin/about`, aboutStatistics: `${prefix}/admin/about/statistics`, check: `${prefix}/admin/about/check`, + docker: `${prefix}/admin/about/docker/validate`, + validationFile: `${prefix}/media/docker/validate.txt`, }; - -export interface AdminStatistics { - totalRecipes: number; - totalUsers: number; - totalGroups: number; - uncategorizedRecipes: number; - untaggedRecipes: number; -} - -export interface CheckAppConfig { - emailReady: boolean; - baseUrlSet: boolean; - isSiteSecure: boolean; - isUpToDate: boolean; - ldapReady: boolean; -} - export class AdminAboutAPI extends BaseAPI { async about() { return await this.requests.get(routes.about); @@ -38,4 +23,12 @@ export class AdminAboutAPI extends BaseAPI { async checkApp() { return await this.requests.get(routes.check); } + + async checkDocker() { + return await this.requests.get(routes.docker); + } + + async getDockerValidateFileContents() { + return await this.requests.get(routes.validationFile); + } } diff --git a/frontend/components/global/HelpIcon.vue b/frontend/components/global/HelpIcon.vue index c96682e93557..4c19ee81f17a 100644 --- a/frontend/components/global/HelpIcon.vue +++ b/frontend/components/global/HelpIcon.vue @@ -2,8 +2,8 @@
@@ -19,8 +19,11 @@ import { defineComponent } from "@nuxtjs/composition-api"; export default defineComponent({ - setup() { - return {}; + props: { + small: { + type: Boolean, + default: false, + }, }, }); diff --git a/frontend/pages/admin/site-settings.vue b/frontend/pages/admin/site-settings.vue index 4f485a57e06c..09be1651a875 100644 --- a/frontend/pages/admin/site-settings.vue +++ b/frontend/pages/admin/site-settings.vue @@ -8,26 +8,67 @@
- - + + + + +
+
+ -
{{ check.text }}
+
+ Docker Volume + + Mealie requires that the frontend container and the backend share the same docker volume or storage. This + ensures that the frontend container can properly access the images and assets stored on disk. + +
- {{ check.status ? check.successText : check.errorText }} + + + +
+
+ + + Validate +
+
- - + +
Email Configuration Status
{{ appConfig.emailReady ? "Ready" : "Not Ready - Check Environmental Variables" }} @@ -51,13 +92,6 @@ {{ success ? "Succeeded" : "Failed" }} - -
@@ -95,22 +129,62 @@ import { useAsync, useContext, } from "@nuxtjs/composition-api"; -import { CheckAppConfig } from "~/api/admin/admin-about"; import { useAdminApi, useUserApi } from "~/composables/api"; import { validators } from "~/composables/use-validators"; import { useAsyncKey } from "~/composables/use-utils"; +import { CheckAppConfig } from "~/types/api-types/admin"; + +enum DockerVolumeState { + Unknown = "unknown", + Success = "success", + Error = "error", +} interface SimpleCheck { - status: boolean; text: string; + status: boolean | undefined; successText: string; errorText: string; - warning: boolean; + color: string; + icon: string; +} + +interface CheckApp extends CheckAppConfig { + isSiteSecure?: boolean; } export default defineComponent({ layout: "admin", setup() { + // ========================================================== + // Docker Volume Validation + const docker = reactive({ + loading: false, + state: DockerVolumeState.Unknown, + }); + + async function dockerValidate() { + docker.loading = true; + + // Do API Check + const { data } = await adminApi.about.checkDocker(); + if (data == null) { + docker.state = DockerVolumeState.Error; + return; + } + + // Get File Contents + const { data: fileContents } = await adminApi.about.getDockerValidateFileContents(); + + if (data.text === fileContents) { + docker.state = DockerVolumeState.Success; + } else { + docker.state = DockerVolumeState.Error; + } + + docker.loading = false; + } + const state = reactive({ loading: false, address: "", @@ -119,17 +193,21 @@ export default defineComponent({ tested: false, }); - const appConfig = ref({ - emailReady: false, - baseUrlSet: false, - isSiteSecure: false, + const appConfig = ref({ + emailReady: true, + baseUrlSet: true, + isSiteSecure: true, isUpToDate: false, ldapReady: false, }); - const api = useUserApi(); + function isLocalHostOrHttps() { + return window.location.hostname === "localhost" || window.location.protocol === "https:"; + } + const api = useUserApi(); const adminApi = useAdminApi(); + onMounted(async () => { const { data } = await adminApi.about.checkApp(); @@ -140,43 +218,53 @@ export default defineComponent({ appConfig.value.isSiteSecure = isLocalHostOrHttps(); }); - function isLocalHostOrHttps() { - return window.location.hostname === "localhost" || window.location.protocol === "https:"; - } - const simpleChecks = computed(() => { - return [ + const goodIcon = $globals.icons.checkboxMarkedCircle; + const badIcon = $globals.icons.alert; + const warningIcon = $globals.icons.alertCircle; + + const goodColor = "success"; + const badColor = "error"; + const warningColor = "warning"; + + const data: SimpleCheck[] = [ { - status: appConfig.value.isUpToDate, text: "Application Version", + status: appConfig.value.isUpToDate, errorText: `Your current version (${rawAppInfo.value.version}) does not match the latest release. Considering updating to the latest version (${rawAppInfo.value.versionLatest}).`, successText: "Mealie is up to date", - warning: true, + color: appConfig.value.isUpToDate ? goodColor : warningColor, + icon: appConfig.value.isUpToDate ? goodIcon : warningIcon, }, { - status: appConfig.value.isSiteSecure, text: "Secure Site", + status: appConfig.value.isSiteSecure, errorText: "Serve via localhost or secure with https. Clipboard and additional browser APIs may not work.", successText: "Site is accessed by localhost or https", - warning: false, + color: appConfig.value.isSiteSecure ? goodColor : badColor, + icon: appConfig.value.isSiteSecure ? goodIcon : badIcon, }, { - status: appConfig.value.baseUrlSet, text: "Server Side Base URL", + status: appConfig.value.baseUrlSet, errorText: "`BASE_URL` is still the default value on API Server. This will cause issues with notifications links generated on the server for emails, etc.", successText: "Server Side URL does not match the default", - warning: false, + color: appConfig.value.baseUrlSet ? goodColor : badColor, + icon: appConfig.value.baseUrlSet ? goodIcon : badIcon, }, { - status: appConfig.value.ldapReady, text: "LDAP Ready", + status: appConfig.value.ldapReady, errorText: "Not all LDAP Values are configured. This can be ignored if you are not using LDAP Authentication.", successText: "Required LDAP variables are all set.", - warning: true, + color: appConfig.value.ldapReady ? goodColor : warningColor, + icon: appConfig.value.ldapReady ? goodIcon : warningIcon, }, ]; + + return data; }); async function testEmail() { @@ -209,11 +297,6 @@ export default defineComponent({ return false; }); - function getColor(booly: unknown, warning = false) { - const falsey = warning ? "warning" : "error"; - return booly ? "success" : falsey; - } - // ============================================================ // General About Info @@ -292,8 +375,10 @@ export default defineComponent({ const appInfo = getAppInfo(); return { + DockerVolumeState, + docker, + dockerValidate, simpleChecks, - getColor, appConfig, validEmail, validators, @@ -310,4 +395,9 @@ export default defineComponent({ }); - + diff --git a/frontend/types/api-types/admin.ts b/frontend/types/api-types/admin.ts index fd443f8bd0fa..e23b9c343145 100644 --- a/frontend/types/api-types/admin.ts +++ b/frontend/types/api-types/admin.ts @@ -170,6 +170,9 @@ export interface CustomPageOut { categories?: RecipeCategoryResponse[]; id: number; } +export interface DockerVolumeText { + text: string; +} export interface GroupImport { name: string; status: boolean; diff --git a/frontend/types/components.d.ts b/frontend/types/components.d.ts index 450198eaa05e..2b6fd0be1d88 100644 --- a/frontend/types/components.d.ts +++ b/frontend/types/components.d.ts @@ -1,76 +1,74 @@ // This Code is auto generated by gen_global_components.py - import BaseCardSectionTitle from "@/components/global/BaseCardSectionTitle.vue"; - import MarkdownEditor from "@/components/global/MarkdownEditor.vue"; - import AppLoader from "@/components/global/AppLoader.vue"; - import BaseOverflowButton from "@/components/global/BaseOverflowButton.vue"; - import ReportTable from "@/components/global/ReportTable.vue"; - import AppToolbar from "@/components/global/AppToolbar.vue"; - import BaseButtonGroup from "@/components/global/BaseButtonGroup.vue"; - import BaseButton from "@/components/global/BaseButton.vue"; - import BannerExperimental from "@/components/global/BannerExperimental.vue"; - import BaseDialog from "@/components/global/BaseDialog.vue"; - import RecipeJsonEditor from "@/components/global/RecipeJsonEditor.vue"; - import StatsCards from "@/components/global/StatsCards.vue"; - import HelpIcon from "@/components/global/HelpIcon.vue"; - import InputLabelType from "@/components/global/InputLabelType.vue"; - import BaseStatCard from "@/components/global/BaseStatCard.vue"; - import DevDumpJson from "@/components/global/DevDumpJson.vue"; - import LanguageDialog from "@/components/global/LanguageDialog.vue"; - import InputQuantity from "@/components/global/InputQuantity.vue"; - import ToggleState from "@/components/global/ToggleState.vue"; - import AppButtonCopy from "@/components/global/AppButtonCopy.vue"; - import CrudTable from "@/components/global/CrudTable.vue"; - import InputColor from "@/components/global/InputColor.vue"; - import BaseDivider from "@/components/global/BaseDivider.vue"; - import AutoForm from "@/components/global/AutoForm.vue"; - import AppButtonUpload from "@/components/global/AppButtonUpload.vue"; - import AdvancedOnly from "@/components/global/AdvancedOnly.vue"; - import BasePageTitle from "@/components/global/BasePageTitle.vue"; - import ButtonLink from "@/components/global/ButtonLink.vue"; - - import TheSnackbar from "@/components/layout/TheSnackbar.vue"; - import AppHeader from "@/components/layout/AppHeader.vue"; - import AppSidebar from "@/components/layout/AppSidebar.vue"; - import AppFooter from "@/components/layout/AppFooter.vue"; +import BaseCardSectionTitle from "@/components/global/BaseCardSectionTitle.vue"; +import MarkdownEditor from "@/components/global/MarkdownEditor.vue"; +import AppLoader from "@/components/global/AppLoader.vue"; +import BaseOverflowButton from "@/components/global/BaseOverflowButton.vue"; +import ReportTable from "@/components/global/ReportTable.vue"; +import AppToolbar from "@/components/global/AppToolbar.vue"; +import BaseButtonGroup from "@/components/global/BaseButtonGroup.vue"; +import BaseButton from "@/components/global/BaseButton.vue"; +import BannerExperimental from "@/components/global/BannerExperimental.vue"; +import BaseDialog from "@/components/global/BaseDialog.vue"; +import RecipeJsonEditor from "@/components/global/RecipeJsonEditor.vue"; +import StatsCards from "@/components/global/StatsCards.vue"; +import HelpIcon from "@/components/global/HelpIcon.vue"; +import InputLabelType from "@/components/global/InputLabelType.vue"; +import BaseStatCard from "@/components/global/BaseStatCard.vue"; +import DevDumpJson from "@/components/global/DevDumpJson.vue"; +import LanguageDialog from "@/components/global/LanguageDialog.vue"; +import InputQuantity from "@/components/global/InputQuantity.vue"; +import ToggleState from "@/components/global/ToggleState.vue"; +import AppButtonCopy from "@/components/global/AppButtonCopy.vue"; +import CrudTable from "@/components/global/CrudTable.vue"; +import InputColor from "@/components/global/InputColor.vue"; +import BaseDivider from "@/components/global/BaseDivider.vue"; +import AutoForm from "@/components/global/AutoForm.vue"; +import AppButtonUpload from "@/components/global/AppButtonUpload.vue"; +import AdvancedOnly from "@/components/global/AdvancedOnly.vue"; +import BasePageTitle from "@/components/global/BasePageTitle.vue"; +import ButtonLink from "@/components/global/ButtonLink.vue"; +import TheSnackbar from "@/components/layout/TheSnackbar.vue"; +import AppHeader from "@/components/layout/AppHeader.vue"; +import AppSidebar from "@/components/layout/AppSidebar.vue"; +import AppFooter from "@/components/layout/AppFooter.vue"; declare module "vue" { export interface GlobalComponents { // Global Components - BaseCardSectionTitle: typeof BaseCardSectionTitle; - MarkdownEditor: typeof MarkdownEditor; - AppLoader: typeof AppLoader; - BaseOverflowButton: typeof BaseOverflowButton; - ReportTable: typeof ReportTable; - AppToolbar: typeof AppToolbar; - BaseButtonGroup: typeof BaseButtonGroup; - BaseButton: typeof BaseButton; - BannerExperimental: typeof BannerExperimental; - BaseDialog: typeof BaseDialog; - RecipeJsonEditor: typeof RecipeJsonEditor; - StatsCards: typeof StatsCards; - HelpIcon: typeof HelpIcon; - InputLabelType: typeof InputLabelType; - BaseStatCard: typeof BaseStatCard; - DevDumpJson: typeof DevDumpJson; - LanguageDialog: typeof LanguageDialog; - InputQuantity: typeof InputQuantity; - ToggleState: typeof ToggleState; - AppButtonCopy: typeof AppButtonCopy; - CrudTable: typeof CrudTable; - InputColor: typeof InputColor; - BaseDivider: typeof BaseDivider; - AutoForm: typeof AutoForm; - AppButtonUpload: typeof AppButtonUpload; - AdvancedOnly: typeof AdvancedOnly; - BasePageTitle: typeof BasePageTitle; - ButtonLink: typeof ButtonLink; - // Layout Components - TheSnackbar: typeof TheSnackbar; - AppHeader: typeof AppHeader; - AppSidebar: typeof AppSidebar; - AppFooter: typeof AppFooter; - + BaseCardSectionTitle: typeof BaseCardSectionTitle; + MarkdownEditor: typeof MarkdownEditor; + AppLoader: typeof AppLoader; + BaseOverflowButton: typeof BaseOverflowButton; + ReportTable: typeof ReportTable; + AppToolbar: typeof AppToolbar; + BaseButtonGroup: typeof BaseButtonGroup; + BaseButton: typeof BaseButton; + BannerExperimental: typeof BannerExperimental; + BaseDialog: typeof BaseDialog; + RecipeJsonEditor: typeof RecipeJsonEditor; + StatsCards: typeof StatsCards; + HelpIcon: typeof HelpIcon; + InputLabelType: typeof InputLabelType; + BaseStatCard: typeof BaseStatCard; + DevDumpJson: typeof DevDumpJson; + LanguageDialog: typeof LanguageDialog; + InputQuantity: typeof InputQuantity; + ToggleState: typeof ToggleState; + AppButtonCopy: typeof AppButtonCopy; + CrudTable: typeof CrudTable; + InputColor: typeof InputColor; + BaseDivider: typeof BaseDivider; + AutoForm: typeof AutoForm; + AppButtonUpload: typeof AppButtonUpload; + AdvancedOnly: typeof AdvancedOnly; + BasePageTitle: typeof BasePageTitle; + ButtonLink: typeof ButtonLink; + // Layout Components + TheSnackbar: typeof TheSnackbar; + AppHeader: typeof AppHeader; + AppSidebar: typeof AppSidebar; + AppFooter: typeof AppFooter; } } diff --git a/frontend/utils/icons/icon-type.ts b/frontend/utils/icons/icon-type.ts index 39684c325db2..5646cab3479f 100644 --- a/frontend/utils/icons/icon-type.ts +++ b/frontend/utils/icons/icon-type.ts @@ -3,6 +3,7 @@ export interface Icon { primary: string; // General + docker: string; chart: string; wrench: string; help: string; diff --git a/frontend/utils/icons/icons.ts b/frontend/utils/icons/icons.ts index b4037ead1c37..0d1b2001afe9 100644 --- a/frontend/utils/icons/icons.ts +++ b/frontend/utils/icons/icons.ts @@ -108,6 +108,7 @@ import { mdiWrench, mdiChartLine, mdiHelpCircleOutline, + mdiDocker, } from "@mdi/js"; export const icons = { @@ -116,6 +117,7 @@ export const icons = { wrench: mdiWrench, chart: mdiChartLine, + docker: mdiDocker, // General bowlMixOutline: mdiBowlMixOutline, diff --git a/mealie/db/models/recipe/recipe.py b/mealie/db/models/recipe/recipe.py index 080d7310a072..c016efb5ef91 100644 --- a/mealie/db/models/recipe/recipe.py +++ b/mealie/db/models/recipe/recipe.py @@ -130,6 +130,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): "recipe_ingredient", "recipe_instructions", "settings", + "comments", } @validates("name") diff --git a/mealie/routes/admin/admin_about.py b/mealie/routes/admin/admin_about.py index 6b4971562128..450dfa52e0d0 100644 --- a/mealie/routes/admin/admin_about.py +++ b/mealie/routes/admin/admin_about.py @@ -1,9 +1,14 @@ -from fastapi import APIRouter +import asyncio +import random +import shutil +import string + +from fastapi import APIRouter, BackgroundTasks from mealie.core.release_checker import get_latest_version from mealie.core.settings.static import APP_VERSION from mealie.routes._base import BaseAdminController, controller -from mealie.schema.admin.about import AdminAboutInfo, AppStatistics, CheckAppConfig +from mealie.schema.admin.about import AdminAboutInfo, AppStatistics, CheckAppConfig, DockerVolumeText router = APIRouter(prefix="/about") @@ -11,7 +16,7 @@ router = APIRouter(prefix="/about") @controller(router) class AdminAboutController(BaseAdminController): @router.get("", response_model=AdminAboutInfo) - async def get_app_info(self): + def get_app_info(self): """Get general application information""" settings = self.deps.settings @@ -30,18 +35,18 @@ class AdminAboutController(BaseAdminController): ) @router.get("/statistics", response_model=AppStatistics) - async def get_app_statistics(self): + def get_app_statistics(self): return AppStatistics( total_recipes=self.repos.recipes.count_all(), - uncategorized_recipes=self.repos.recipes.count_uncategorized(), - untagged_recipes=self.repos.recipes.count_untagged(), + uncategorized_recipes=self.repos.recipes.count_uncategorized(), # type: ignore + untagged_recipes=self.repos.recipes.count_untagged(), # type: ignore total_users=self.repos.users.count_all(), total_groups=self.repos.groups.count_all(), ) @router.get("/check", response_model=CheckAppConfig) - async def check_app_config(self): + def check_app_config(self): settings = self.deps.settings url_set = settings.BASE_URL != "http://localhost:8080" @@ -51,3 +56,25 @@ class AdminAboutController(BaseAdminController): base_url_set=url_set, is_up_to_date=get_latest_version() == APP_VERSION, ) + + @router.get("/docker/validate", response_model=DockerVolumeText) + def validate_docker_volume(self, bg: BackgroundTasks): + validation_dir = self.deps.folders.DATA_DIR / "docker-validation" + validation_dir.mkdir(exist_ok=True) + + random_string = "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(100)) + + with validation_dir.joinpath("validate.txt").open("w") as f: + f.write(random_string) + + async def cleanup(): + await asyncio.sleep(60) + + try: + shutil.rmtree(validation_dir) + except Exception as e: + self.deps.logger.error(f"Failed to remove docker validation directory: {e}") + + bg.add_task(cleanup) + + return DockerVolumeText(text=random_string) diff --git a/mealie/routes/media/__init__.py b/mealie/routes/media/__init__.py index b68a2322c053..c8560e1e0e5a 100644 --- a/mealie/routes/media/__init__.py +++ b/mealie/routes/media/__init__.py @@ -1,4 +1,7 @@ -from fastapi import APIRouter +from fastapi import APIRouter, HTTPException +from fastapi.responses import FileResponse + +from mealie.core.config import get_app_dirs from . import media_recipe, media_user @@ -6,3 +9,15 @@ media_router = APIRouter(prefix="/api/media", tags=["Recipe: Images and Assets"] media_router.include_router(media_recipe.router) media_router.include_router(media_user.router) + + +@media_router.get("/docker/validate.txt", response_class=FileResponse) +async def get_validation_text(): + folders = get_app_dirs() + + file = folders.DATA_DIR / "docker-validation" / "validate.txt" + + if file.exists(): + return file + else: + raise HTTPException(status_code=404, detail="File not found") diff --git a/mealie/schema/admin/about.py b/mealie/schema/admin/about.py index 4bed55019c4d..196faf4751ea 100644 --- a/mealie/schema/admin/about.py +++ b/mealie/schema/admin/about.py @@ -31,3 +31,7 @@ class CheckAppConfig(MealieModel): ldap_ready: bool = False base_url_set: bool = False is_up_to_date: bool = False + + +class DockerVolumeText(MealieModel): + text: str diff --git a/mealie/schema/recipe/recipe_comments.py b/mealie/schema/recipe/recipe_comments.py index 89d439fedf95..996fa4c6f4c2 100644 --- a/mealie/schema/recipe/recipe_comments.py +++ b/mealie/schema/recipe/recipe_comments.py @@ -1,6 +1,5 @@ from datetime import datetime from typing import Optional -from uuid import UUID from pydantic import UUID4 @@ -8,7 +7,7 @@ from mealie.schema._mealie import MealieModel class UserBase(MealieModel): - id: int + id: UUID4 username: Optional[str] admin: bool @@ -26,12 +25,12 @@ class RecipeCommentSave(RecipeCommentCreate): class RecipeCommentUpdate(MealieModel): - id: UUID + id: UUID4 text: str class RecipeCommentOut(RecipeCommentCreate): - id: UUID + id: UUID4 recipe_id: UUID4 created_at: datetime update_at: datetime