Default Version to 0.2-dev (#690)

This commit is contained in:
Yuhong Sun 2023-11-03 18:37:01 -07:00 committed by GitHub
parent 551705ad62
commit 602f9c4a0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 66 deletions

View File

@ -1,12 +1,9 @@
FROM python:3.11.4-slim-bookworm
# Default DANSWER_VERSION build argument set here.
# This can be overridden by passing in a build arg, typically from GitHub Actions.
ARG DANSWER_VERSION=0.1.0
# Then passed to the container environment.
# Default DANSWER_VERSION, typically overriden during builds by GitHub Actions.
ARG DANSWER_VERSION=0.2-dev
ENV DANSWER_VERSION=${DANSWER_VERSION}
# Install system dependencies
RUN apt-get update && \
apt-get install -y git cmake pkg-config libprotobuf-c-dev protobuf-compiler \

View File

@ -1,4 +1,3 @@
import os
# Pulls the version from the environment variable DANSWER_VERSION, or defaults to 0.1.0dev.
__version__ = os.environ.get("DANSWER_VERSION", "") or "0.1.0dev"
__version__ = os.environ.get("DANSWER_VERSION", "") or "0.2-dev"

View File

@ -1,9 +1,7 @@
FROM node:20-alpine AS base
# Default DANSWER_VERSION build argument set here.
# This can be overridden by passing in a build arg, typically from GitHub Actions.
ARG DANSWER_VERSION=0.1.0
# Then passed to the container environment.
# Default DANSWER_VERSION, typically overriden during builds by GitHub Actions.
ARG DANSWER_VERSION=0.2-dev
ENV DANSWER_VERSION=${DANSWER_VERSION}
# Step 1. Install dependencies only when needed

View File

@ -1,8 +1,8 @@
// Get Danswer Web Version
const { version: package_version } = require('./package.json'); // version from package.json
const { version: package_version } = require("./package.json"); // version from package.json
const env_version = process.env.DANSWER_VERSION; // version from env variable
// Use env version if set & valid, otherwise default to package version
const version = env_version || package_version;
const version = env_version || package_version;
/** @type {import('next').NextConfig} */
const nextConfig = {

4
web/package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "qa",
"version": "0.1.0dev",
"version": "0.2-dev",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "qa",
"version": "0.1.0dev",
"version": "0.2-dev",
"dependencies": {
"@phosphor-icons/react": "^2.0.8",
"@tremor/react": "^3.9.2",

View File

@ -1,6 +1,6 @@
{
"name": "qa",
"version": "0.1.0dev",
"version": "0.2-dev",
"private": true,
"scripts": {
"dev": "next dev",

View File

@ -1,40 +1,42 @@
import { NotebookIcon } from "@/components/icons/icons";
import { getWebVersion, getBackendVersion } from "@/lib/version"
import { getWebVersion, getBackendVersion } from "@/lib/version";
const Page = async () => {
let web_version: string | null = null;
let backend_version: string | null = null;
try {
[web_version, backend_version] = await Promise.all([
getWebVersion(),
getBackendVersion(),
]);
} catch (e) {
console.log(`Version info fetch failed for system info page - ${e}`);
}
let web_version: string | null = null;
let backend_version: string | null = null;
try {
[web_version, backend_version] = await Promise.all([
getWebVersion(),
getBackendVersion(),
]);
} catch (e) {
console.log(`Version info fetch failed for system info page - ${e}`);
}
return (
<div>
<div className="border-solid border-gray-600 border-b pb-2 mb-4 flex">
<NotebookIcon size={32} />
<h1 className="text-3xl font-bold pl-2">System Information</h1>
</div>
<div>
<p className="font-bold text-lg my-auto mb-2">Danswer MIT</p>
<div className="flex mb-2">
<p className="my-auto mr-1">Backend Version: </p>
<p className="text-base my-auto text-slate-400 italic">{backend_version}</p>
</div>
<div className="flex mb-2">
<p className="my-auto mr-1">Web Version: </p>
<p className="text-base my-auto text-slate-400 italic">{web_version}</p>
</div>
</div>
return (
<div>
<div className="border-solid border-gray-600 border-b pb-2 mb-4 flex">
<NotebookIcon size={32} />
<h1 className="text-3xl font-bold pl-2">Version</h1>
</div>
<div>
<p className="font-bold text-lg my-auto mb-2">Danswer MIT</p>
<div className="flex mb-2">
<p className="my-auto mr-1">Backend Version: </p>
<p className="text-base my-auto text-slate-400 italic">
{backend_version}
</p>
</div>
);
<div className="flex mb-2">
<p className="my-auto mr-1">Web Version: </p>
<p className="text-base my-auto text-slate-400 italic">
{web_version}
</p>
</div>
</div>
</div>
);
};
export default Page;

View File

@ -3,8 +3,7 @@ import { AuthType, OAUTH_NAME } from "@/lib/constants";
import { User } from "@/lib/types";
import { getCurrentUserSS, getAuthUrlSS, getAuthTypeSS } from "@/lib/userSS";
import { redirect } from "next/navigation";
import { getWebVersion, getBackendVersion } from "@/lib/version"
import { getWebVersion, getBackendVersion } from "@/lib/version";
const BUTTON_STYLE =
"group relative w-64 flex justify-center " +
@ -94,7 +93,7 @@ const Page = async () => {
</div>
</div>
<div className="fixed bottom-4 right-4 z-50 text-slate-400 p-2">
VERSION w{ web_version } b{ backend_version }
VERSION w{web_version} b{backend_version}
</div>
</div>
</main>

View File

@ -318,13 +318,13 @@ export async function Layout({ children }: { children: React.ReactNode }) {
],
},
{
name: "Info",
name: "System Information",
items: [
{
name: (
<div className="flex">
<NotebookIcon size={18} />
<div className="ml-1">System Information</div>
<div className="ml-1">Version</div>
</div>
),
link: "/admin/systeminfo",

View File

@ -1,27 +1,27 @@
import { buildUrl } from "./utilsSS";
import getConfig from 'next/config';
import getConfig from "next/config";
const { publicRuntimeConfig } = getConfig();
const version = publicRuntimeConfig?.version;
// Maybe improve type-safety by creating a 'VersionType' instead of generic string
export const getBackendVersion = async (): Promise<string | null> => {
try {
const res = await fetch(buildUrl("/version"));
if (!res.ok) {
//throw new Error("Failed to fetch data");
return null;
}
const data: { backend_version: string } = await res.json();
return data.backend_version as string;
} catch (e) {
console.log(`Error fetching backend version info: ${e}`);
return null;
try {
const res = await fetch(buildUrl("/version"));
if (!res.ok) {
//throw new Error("Failed to fetch data");
return null;
}
const data: { backend_version: string } = await res.json();
return data.backend_version as string;
} catch (e) {
console.log(`Error fetching backend version info: ${e}`);
return null;
}
};
// Frontend?
export const getWebVersion = (): string | null => {
return version;
return version;
};