mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(docker): Check for /app/config volume mount during setup (#826)
This commit is contained in:
@@ -15,6 +15,8 @@ RUN yarn install --production --ignore-scripts --prefer-offline
|
|||||||
RUN rm -rf src && \
|
RUN rm -rf src && \
|
||||||
rm -rf server
|
rm -rf server
|
||||||
|
|
||||||
|
RUN touch config/DOCKER
|
||||||
|
|
||||||
RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json
|
RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1477,6 +1477,24 @@ paths:
|
|||||||
example: 1.0.0
|
example: 1.0.0
|
||||||
commitTag:
|
commitTag:
|
||||||
type: string
|
type: string
|
||||||
|
/status/appdata:
|
||||||
|
get:
|
||||||
|
summary: Get /app/data volume status
|
||||||
|
description: For Docker installs, returns whether or not the /app/data volume mount was configured properly. Always returns true for non-Docker installs.
|
||||||
|
security: []
|
||||||
|
tags:
|
||||||
|
- public
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: /app/data volume status
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
appData:
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
/settings/main:
|
/settings/main:
|
||||||
get:
|
get:
|
||||||
summary: Get main settings
|
summary: Get main settings
|
||||||
|
@@ -15,6 +15,7 @@ import personRoutes from './person';
|
|||||||
import collectionRoutes from './collection';
|
import collectionRoutes from './collection';
|
||||||
import { getAppVersion, getCommitTag } from '../utils/appVersion';
|
import { getAppVersion, getCommitTag } from '../utils/appVersion';
|
||||||
import serviceRoutes from './service';
|
import serviceRoutes from './service';
|
||||||
|
import { appDataStatus } from '../utils/appDataVolume';
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
@@ -27,6 +28,12 @@ router.get('/status', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/status/appdata', (_req, res) => {
|
||||||
|
return res.status(200).json({
|
||||||
|
appData: appDataStatus(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
router.use('/user', isAuthenticated(Permission.MANAGE_USERS), user);
|
router.use('/user', isAuthenticated(Permission.MANAGE_USERS), user);
|
||||||
router.get('/settings/public', (_req, res) => {
|
router.get('/settings/public', (_req, res) => {
|
||||||
const settings = getSettings();
|
const settings = getSettings();
|
||||||
|
8
server/utils/appDataVolume.ts
Normal file
8
server/utils/appDataVolume.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { existsSync } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const DOCKER_PATH = path.join(__dirname, '../../config/DOCKER');
|
||||||
|
|
||||||
|
export const appDataStatus = (): boolean => {
|
||||||
|
return !existsSync(DOCKER_PATH);
|
||||||
|
};
|
41
src/components/AppDataWarning/index.tsx
Normal file
41
src/components/AppDataWarning/index.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
import Alert from '../Common/Alert';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
dockerVolumeMissing: 'Docker Volume Mount Missing',
|
||||||
|
dockerVolumeMissingDescription:
|
||||||
|
'The <code>/app/config</code> volume mount was not configured properly. All data will be cleared when the container is stopped or restarted.',
|
||||||
|
});
|
||||||
|
|
||||||
|
const AppDataWarning: React.FC = () => {
|
||||||
|
const intl = useIntl();
|
||||||
|
const { data, error } = useSWR<{ appData: boolean }>(
|
||||||
|
'/api/v1/status/appdata'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!data && !error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!data.appData && (
|
||||||
|
<Alert title={intl.formatMessage(messages.dockerVolumeMissing)}>
|
||||||
|
{intl.formatMessage(messages.dockerVolumeMissingDescription, {
|
||||||
|
code: function code(msg) {
|
||||||
|
return <code className="bg-opacity-50">{msg}</code>;
|
||||||
|
},
|
||||||
|
})}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AppDataWarning;
|
@@ -11,6 +11,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|||||||
import Badge from '../Common/Badge';
|
import Badge from '../Common/Badge';
|
||||||
import LanguagePicker from '../Layout/LanguagePicker';
|
import LanguagePicker from '../Layout/LanguagePicker';
|
||||||
import PageTitle from '../Common/PageTitle';
|
import PageTitle from '../Common/PageTitle';
|
||||||
|
import AppDataWarning from '../AppDataWarning';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
setup: 'Setup',
|
setup: 'Setup',
|
||||||
@@ -66,6 +67,7 @@ const Setup: React.FC = () => {
|
|||||||
className="w-auto mx-auto mb-10 max-h-32"
|
className="w-auto mx-auto mb-10 max-h-32"
|
||||||
alt="Logo"
|
alt="Logo"
|
||||||
/>
|
/>
|
||||||
|
<AppDataWarning />
|
||||||
<nav className="relative z-50">
|
<nav className="relative z-50">
|
||||||
<ul
|
<ul
|
||||||
className="bg-gray-800 bg-opacity-50 border border-gray-600 divide-y divide-gray-600 rounded-md md:flex md:divide-y-0"
|
className="bg-gray-800 bg-opacity-50 border border-gray-600 divide-y divide-gray-600 rounded-md md:flex md:divide-y-0"
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"components.AppDataWarning.dockerVolumeMissing": "Docker Volume Mount Missing",
|
||||||
|
"components.AppDataWarning.dockerVolumeMissingDescription": "The <code>/app/config</code> volume mount was not configured properly. All data will be cleared when the container is stopped or restarted.",
|
||||||
"components.CollectionDetails.movies": "Movies",
|
"components.CollectionDetails.movies": "Movies",
|
||||||
"components.CollectionDetails.numberofmovies": "Number of Movies: {count}",
|
"components.CollectionDetails.numberofmovies": "Number of Movies: {count}",
|
||||||
"components.CollectionDetails.overview": "Overview",
|
"components.CollectionDetails.overview": "Overview",
|
||||||
|
Reference in New Issue
Block a user