Skip to content

Commit

Permalink
Migrate to client rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszbachorski committed Sep 5, 2024
1 parent 4d84be8 commit 7d922f0
Show file tree
Hide file tree
Showing 144 changed files with 3,758 additions and 17,215 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#

.git
.next
.results
scripts
*Dockerfile*
Expand Down
17 changes: 17 additions & 0 deletions .env.declaration
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# This source file is part of the Stanford Biodesign Digital Health ENGAGE-HF open-source project
#
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#

# File is needed for https://github.com/garronej/vite-envs, allowing
# for dynamic configuration via environment variables in Vite
VITE_PUBLIC_FIREBASE_API_KEY=''
VITE_PUBLIC_FIREBASE_APP_ID=''
VITE_PUBLIC_FIREBASE_AUTH_DOMAIN=''
VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=''
VITE_PUBLIC_FIREBASE_PROJECT_ID=''
VITE_PUBLIC_FIREBASE_STORAGE_BUCKET=''
VITE_PUBLIC_EMULATOR=''
9 changes: 5 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
"/out/**",
"/coverage/**",
"/public/authServiceWorker.js",
"**/jest.config.js",
"**/next.config.js",
"**/postcss.config.js",
"**/tailwind.config.js"
],
Expand Down Expand Up @@ -108,11 +106,14 @@
"error",
{ "allowNumber": true, "allowBoolean": true }
],
"react/no-unescaped-entities": "off"
"react/no-unescaped-entities": "off",
// some tanstack router functions result are thrown, like notFound
"@typescript-eslint/only-throw-error": "off",
"@next/next/no-img-element": "off"
},
"overrides": [
{
"files": ["app/**/*.ts?(x)", "**/*.stories.ts?(x)"],
"files": ["app/**/*.ts?(x)", "**/*.stories.ts?(x)", "vite.config.ts"],
"rules": {
"import/no-default-export": "off"
}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
testscript: test.sh
secrets:
ENV_FILE: |
NEXT_PUBLIC_FIREBASE_API_KEY='${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}'
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN='${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}'
NEXT_PUBLIC_FIREBASE_PROJECT_ID='${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}'
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET='${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}'
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID='${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}'
NEXT_PUBLIC_FIREBASE_APP_ID='${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}'
VITE_PUBLIC_FIREBASE_API_KEY='${{ secrets.VITE_PUBLIC_FIREBASE_API_KEY }}'
VITE_PUBLIC_FIREBASE_AUTH_DOMAIN='${{ secrets.VITE_PUBLIC_FIREBASE_AUTH_DOMAIN }}'
VITE_PUBLIC_FIREBASE_PROJECT_ID='${{ secrets.VITE_PUBLIC_FIREBASE_PROJECT_ID }}'
VITE_PUBLIC_FIREBASE_STORAGE_BUCKET='${{ secrets.VITE_PUBLIC_FIREBASE_STORAGE_BUCKET }}'
VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID='${{ secrets.VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}'
VITE_PUBLIC_FIREBASE_APP_ID='${{ secrets.VITE_PUBLIC_FIREBASE_APP_ID }}'
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
# testing
/coverage

# next.js
/.next/
/out/

# production
/build
/public/authServiceWorker.js
/dist

# misc
.DS_Store
Expand All @@ -44,7 +40,6 @@ admin-creds.json

# typescript
*.tsbuildinfo
next-env.d.ts

# lint
eslint_report.json
Expand Down
63 changes: 10 additions & 53 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,24 @@
#


FROM node:18-alpine AS base
FROM node:latest AS build

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN mkdir /app
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json package-lock.json ./
RUN npm ci


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1

ARG NEXT_PUBLIC_FIREBASE_API_KEY
ARG NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ARG NEXT_PUBLIC_FIREBASE_PROJECT_ID
ARG NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
ARG NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
ARG NEXT_PUBLIC_FIREBASE_APP_ID

RUN npm ci
RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public
FROM nginx:stable-alpine

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs
RUN mkdir -p /var/www
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

ENV PORT 80
# set hostname to localhost
ENV HOSTNAME "0.0.0.0"

CMD ["node", "server.js"]
# https://github.com/garronej/vite-envs
# enable env var configuration
ENTRYPOINT ["sh", "-c", "/usr/share/nginx/html/vite-envs.sh && nginx -g 'daemon off;'"]
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ npm install
Create an `.env.local` file or inject the following environment variables required for the Google Firebase Setup:

```
NEXT_PUBLIC_FIREBASE_API_KEY=
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
NEXT_PUBLIC_FIREBASE_APP_ID=
VITE_PUBLIC_FIREBASE_API_KEY=
VITE_PUBLIC_FIREBASE_AUTH_DOMAIN=
VITE_PUBLIC_FIREBASE_PROJECT_ID=
VITE_PUBLIC_FIREBASE_STORAGE_BUCKET=
VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
VITE_PUBLIC_FIREBASE_APP_ID=
```

3. Start the Next.js Application
3. Start the Vite Application

```bash
npm run dev
Expand Down Expand Up @@ -94,15 +94,6 @@ You need to configure the OpenID Connect Sign-in provider as follows:
- Issuer (URL): `https://login.stanford.edu`
- Client secret: Client ID obtained from your OIDC configuration from the [Stanford SAML and OIDC Configuration Manager](https://spdb-prod.iam.stanford.edu).

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## License

This project is licensed under the MIT License. See [Licenses](https://github.com/StanfordBDHG/ENGAGE-HF-Web-Frontend/tree/main/LICENSES) for more information.
Expand Down
35 changes: 0 additions & 35 deletions app/(dashboard)/layout.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions app/(dashboard)/users/actions.tsx

This file was deleted.

25 changes: 25 additions & 0 deletions app/ReactQueryClientProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// This source file is part of the Stanford Biodesign Digital Health ENGAGE-HF open-source project
//
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { type ReactNode } from 'react'

interface ReactQueryClientProviderProps {
children: ReactNode
}

export const queryClient = new QueryClient({
defaultOptions: {
queries: { retry: false },
},
})

export const ReactQueryClientProvider = ({
children,
}: ReactQueryClientProviderProps) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
49 changes: 0 additions & 49 deletions app/layout.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions app/sign-in/SignInForm.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions app/sign-in/layout.tsx

This file was deleted.

Loading

0 comments on commit 7d922f0

Please sign in to comment.