Skip to content

Commit

Permalink
ci(dashboard): publish dashboard next image
Browse files Browse the repository at this point in the history
  • Loading branch information
mijailr committed Apr 12, 2024
1 parent a15b006 commit 9e83a7c
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
!lhctl/
!docker/
!dashboard/
!dashboard-new/
!gradle.properties
!settings.gradle
!go.mod
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/dashboard.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions dashboard-new/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions dashboard-new/next.config.mjs
Original file line number Diff line number Diff line change
@@ -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'))
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DetailsProps> = ({ spec: { name, retentionPolicy } }) => {
export const Details: FC<DetailsProps> = ({ spec: { id, retentionPolicy } }) => {
return (
<div className="mb-4">
<span className="italic">ExternalEventDef</span>
<h1 className="block text-2xl font-bold">{name}</h1>
<h1 className="block text-2xl font-bold">{id?.name}</h1>
{retentionPolicy?.secondsAfterPut && (
<div className="flex items-center gap-2">
Retention Policy:
Expand Down
1 change: 1 addition & 0 deletions dashboard-new/src/app/api/auth/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions docker/standalone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 6 additions & 0 deletions docker/standalone/dashboard-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9e83a7c

Please sign in to comment.