mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-15 09:46:19 +01:00
♻️ Disable docker when not configured
This commit is contained in:
@@ -34,6 +34,7 @@ const env = createEnv({
|
||||
NEXT_PUBLIC_DEFAULT_COLOR_SCHEME: z.enum(['light', 'dark']).optional().default('light'),
|
||||
NEXT_PUBLIC_PORT: portSchema,
|
||||
NEXT_PUBLIC_NODE_ENV: envSchema,
|
||||
NEXT_PUBLIC_DOCKER_ENABLED: z.boolean().optional().default(false),
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -50,6 +51,7 @@ const env = createEnv({
|
||||
NEXT_PUBLIC_DEFAULT_COLOR_SCHEME: process.env.DEFAULT_COLOR_SCHEME,
|
||||
NEXT_PUBLIC_PORT: process.env.PORT,
|
||||
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
|
||||
NEXT_PUBLIC_DOCKER_ENABLED: !!process.env.DOCKER_HOST,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import { MainLayout } from '~/components/layout/main';
|
||||
import { useCardStyles } from '~/components/layout/useCardStyles';
|
||||
import { useInitConfig } from '~/config/init';
|
||||
import { useConfigContext } from '~/config/provider';
|
||||
import { env } from '~/env';
|
||||
import { getServerAuthSession } from '~/server/auth';
|
||||
import { prisma } from '~/server/db';
|
||||
import { getFrontendConfig } from '~/tools/config/getFrontendConfig';
|
||||
@@ -79,7 +80,7 @@ export const HeaderActions = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DockerButton />
|
||||
{env.NEXT_PUBLIC_DOCKER_ENABLED && <DockerButton />}
|
||||
<ToggleEditModeButton />
|
||||
<CustomizeBoardButton />
|
||||
</>
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { Stack } from '@mantine/core';
|
||||
import { useDebouncedValue } from '@mantine/hooks';
|
||||
import { ContainerInfo } from 'dockerode';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useState } from 'react';
|
||||
import { MainLayout } from '~/components/layout/main';
|
||||
import { env } from '~/env';
|
||||
import ContainerActionBar from '~/modules/Docker/ContainerActionBar';
|
||||
import DockerTable from '~/modules/Docker/DockerTable';
|
||||
import { getServerAuthSession } from '~/server/auth';
|
||||
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
|
||||
import { dashboardNamespaces } from '~/tools/server/translation-namespaces';
|
||||
import { api } from '~/utils/api';
|
||||
|
||||
export default function DockerPage() {
|
||||
const [selection, setSelection] = useState<ContainerInfo[]>([]);
|
||||
// TODO: read that from somewhere else?
|
||||
const dockerEnabled = true;
|
||||
const dockerEnabled = env.NEXT_PUBLIC_DOCKER_ENABLED;
|
||||
const { data, refetch, isRefetching } = api.docker.containers.useQuery(undefined, {
|
||||
enabled: dockerEnabled,
|
||||
});
|
||||
@@ -35,6 +34,14 @@ export default function DockerPage() {
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async ({ locale, req, res }) => {
|
||||
if (!env.NEXT_PUBLIC_DOCKER_ENABLED) return { notFound: true };
|
||||
const session = await getServerAuthSession({ req, res });
|
||||
if (!session?.user.isAdmin) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
|
||||
const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res);
|
||||
return {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user