diff --git a/.dockerignore b/.dockerignore index 60ee29f30e..51591d01db 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,6 +7,7 @@ !lhctl/ !docker/ !dashboard/ +!dashboard-new/ !gradle.properties !settings.gradle !go.mod diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml new file mode 100644 index 0000000000..c38678e42d --- /dev/null +++ b/.github/workflows/dashboard.yml @@ -0,0 +1,98 @@ +name: dashboard +run-name: Publishing images +on: + workflow_dispatch: + push: + branches: + - "dashboard" + paths: + - .github/workflows/dashboard.yml + - server/** + - dashboard-new/** + - docker/standalone/** +permissions: + id-token: write + contents: read +jobs: + lh-server: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: "corretto" + java-version: 17 + + - name: Tests and Build + run: ./gradlew server:build + + - uses: actions/upload-artifact@v4 + with: + name: server-jar + path: server/build/libs/server-*-all.jar + + lh-dashboard-next: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Build and Publish + uses: ./.github/actions/publish-image + with: + image-name: lh-dashboard-next + dockerfile: dashboard-new/Dockerfile + github-token: ${{ secrets.GITHUB_TOKEN }} + context: ./dashboard-new + + lh-standalone: + runs-on: ubuntu-latest + needs: + - lh-server + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: pnpm/action-setup@v2 + with: + package_json_file: ./dashboard/package.json + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + cache-dependency-path: dashboard/pnpm-lock.yaml + cache: pnpm + + - name: Build Dashboard + working-directory: ./dashboard + run: | + pnpm install + pnpm build + + - name: Build Dashboard-new + working-directory: ./dashboard-new + run: | + npm ci + npm run build + + - name: Dowload Server Jar artifact + uses: actions/download-artifact@v4 + with: + name: server-jar + path: server/build/libs/ + + - name: Build and Publish + uses: ./.github/actions/publish-image + with: + image-name: lh-standalone-next + github-token: ${{ secrets.GITHUB_TOKEN }} + dockerfile: docker/standalone/Dockerfile diff --git a/dashboard-new/Dockerfile b/dashboard-new/Dockerfile new file mode 100644 index 0000000000..c77139df92 --- /dev/null +++ b/dashboard-new/Dockerfile @@ -0,0 +1,34 @@ +FROM node:alpine AS base + +FROM base as deps +RUN apk add --no-cache libc6-compat +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + +FROM base as builder +WORKDIR /app +COPY --from=deps /app/node_modules ./ +COPY . . + +RUN npm run build + +FROM base as runner +ENV NODE_ENV production +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public +COPY --from=builder /app/public ./public + +RUN mkdir .next +RUN chown nextjs:nodejs .next +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs +EXPOSE 3000 +ENV PORT 3000 + +CMD HOSTNAME="0.0.0.0" node server.js diff --git a/dashboard-new/next.config.mjs b/dashboard-new/next.config.mjs index f48560d421..6ef810ce7d 100644 --- a/dashboard-new/next.config.mjs +++ b/dashboard-new/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', webpack: config => { // Grab the existing rule that handles SVG imports const fileLoaderRule = config.module.rules.find(rule => rule.test?.test?.('.svg')) diff --git a/dashboard-new/src/app/(authenticated)/externalEventDef/[name]/components/Details.tsx b/dashboard-new/src/app/(authenticated)/externalEventDef/[name]/components/Details.tsx index 7ff934735a..f9853a511c 100644 --- a/dashboard-new/src/app/(authenticated)/externalEventDef/[name]/components/Details.tsx +++ b/dashboard-new/src/app/(authenticated)/externalEventDef/[name]/components/Details.tsx @@ -1,17 +1,16 @@ 'use client' import { ExternalEventDef } from 'littlehorse-client/dist/proto/external_event' -import { TaskDef } from 'littlehorse-client/dist/proto/task_def' import { FC } from 'react' type DetailsProps = { spec: ExternalEventDef } -export const Details: FC = ({ spec: { name, retentionPolicy } }) => { +export const Details: FC = ({ spec: { id, retentionPolicy } }) => { return (
ExternalEventDef -

{name}

+

{id?.name}

{retentionPolicy?.secondsAfterPut && (
Retention Policy: diff --git a/dashboard-new/src/app/api/auth/signin/page.tsx b/dashboard-new/src/app/api/auth/signin/page.tsx index c8622453ad..e103bd4bca 100644 --- a/dashboard-new/src/app/api/auth/signin/page.tsx +++ b/dashboard-new/src/app/api/auth/signin/page.tsx @@ -7,6 +7,7 @@ import handsomeHorse from './handsome-horse.png' export const metadata: Metadata = { title: 'Login - Littlehorse Dashboard', } +export const dynamic = "force-dynamic" export default async function Login() { const providers = await getProviders() diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index e834ac0a1b..af240d71ae 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -28,11 +28,17 @@ COPY ./dashboard/apps/web/.next/standalone ./ COPY ./dashboard/apps/web/.next/static ./apps/web/.next/static COPY ./dashboard/apps/web/public ./apps/web/public +# New dashboard +WORKDIR /lh/dashboard-new +COPY ./dashboard-new/.next/standalone ./ +COPY ./dashboard-new/.next/static ./.next/static + WORKDIR / COPY ./server/build/libs/server-*-all.jar /lh/server.jar ENV LHD_API_HOST=localhost ENV LHD_API_PORT=2023 +ENV DASHBOARD_NEXT=true ENTRYPOINT ["/lh/docker-entrypoint.sh"] diff --git a/docker/standalone/dashboard-entrypoint.sh b/docker/standalone/dashboard-entrypoint.sh index 6b40ef067e..361f5e13ff 100755 --- a/docker/standalone/dashboard-entrypoint.sh +++ b/docker/standalone/dashboard-entrypoint.sh @@ -36,11 +36,17 @@ if [ "${LHD_OAUTH_ENABLED}" == "true" ]; then export KEYCLOAK_CLIENT_SECRET=${LHD_OAUTH_CLIENT_SECRET} export KEYCLOAK_ISSUER_URI=${LHD_OAUTH_SERVER_URL} export AUTH_SECRET=${LHD_OAUTH_ENCRYPT_SECRET} + export NEXTAUTH_SECRET=${AUTH_SECRET} else export AUTH_SECRET=$(uuidgen) + export NEXTAUTH_SECRET=${AUTH_SECRET} fi export HOSTNAME=0.0.0.0 export PORT=8080 +if [ "${DASHBOARD_NEXT}" == "true" ]; then +node /lh/dashboard-new/server.js +else node /lh/dashboard/apps/web/server.js +fi