Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ogma #35

Merged
merged 13 commits into from
Mar 5, 2024
Merged

Ogma #35

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ on:
branches:
- main
paths:
- 'frontend'
- 'frontend/**'
- '.github/workflows/frontend.yml'
- 'k8s/**'

pull_request:
types: [ opened, synchronize, reopened ]
branches:
- main
paths:
- 'frontend'
- 'frontend/**'
- '.github/workflows/frontend.yml'

# Allows you to run this workflow manually from the Actions tab
Expand Down Expand Up @@ -52,6 +52,8 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-frontend-${{ hashFiles('frontend/package-lock.json', 'frontend/yarn.lock') }}-
- name: Install dependencies
env:
OGMA_KEY: ${{ secrets.OGMA_KEY }}
run: npm ci
- name: Perform linting
run: |
Expand All @@ -66,7 +68,7 @@ jobs:
permissions:
contents: read
id-token: write
if: github.event_name != 'pull_request'
# if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -92,6 +94,11 @@ jobs:
tags: northamerica-northeast1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/foresight/frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
OGMA_KEY=${{ secrets.OGMA_KEY }}
NEO4J_USERNAME=${{ secrets.NEO4J_USERNAME }}
NEO4J_PASSWORD=${{ secrets.NEO4J_PASSWORD }}
NEO4J_URL=${{ secrets.NEO4J_URL }}

- name: Get GKE credentials
uses: google-github-actions/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion frontend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules
npm-debug.log
README.md
.next
.git
.git
coverage
5 changes: 5 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ NEXTAUTH_URL="http://localhost:3000"
# Next Auth Discord Provider
DISCORD_CLIENT_ID="example"
DISCORD_CLIENT_SECRET="example"

# Neo4j credentials
NEO4J_USERNAME="example"
NEO4J_PASSWORD="example"
NEO4J_URL="bolt://example:7687"
3 changes: 2 additions & 1 deletion frontend/.vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"esbenp.prettier-vscode",
"rvest.vs-code-prettier-eslint",
"bradlc.vscode-tailwindcss",
"github.vscode-github-actions"
"github.vscode-github-actions",
"bierner.markdown-preview-github-styles"
]
}
3 changes: 3 additions & 0 deletions frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.rulers": [80,]
}
17 changes: 15 additions & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
##### DEPENDENCIES

FROM --platform=linux/amd64 node:20-alpine AS deps
ARG OGMA_KEY

RUN apk add --no-cache libc6-compat openssl
WORKDIR /app

Expand All @@ -10,7 +12,7 @@ COPY prisma ./

# Install dependencies based on the preferred package manager

COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./
COPY package.json env-dependencies.js yarn.lock* package-lock.json* pnpm-lock.yaml\* ./

RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
Expand All @@ -23,6 +25,10 @@ RUN \

FROM --platform=linux/amd64 node:20-alpine AS builder
ARG DATABASE_URL
ARG NEO4J_URL
ARG NEO4J_USERNAME
ARG NEO4J_PASSWORD

WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
Expand All @@ -41,9 +47,16 @@ RUN \
FROM --platform=linux/amd64 gcr.io/distroless/nodejs20-debian12 AS runner
WORKDIR /app

ARG NEO4J_URL
ARG NEO4J_USERNAME
ARG NEO4J_PASSWORD

ENV NODE_ENV production
ENV NEO4J_URL ${NEO4J_URL}
ENV NEO4J_USERNAME ${NEO4J_USERNAME}
ENV NEO4J_PASSWORD ${NEO4J_PASSWORD}

# ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_TELEMETRY_DISABLED 1

COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
Expand Down
33 changes: 19 additions & 14 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Create T3 App
# Foresight Proof of Concept

This is a [T3 Stack](https://create.t3.gg/) project bootstrapped with `create-t3-app`.
This proof of concept is a showcase of tools to aid humans detect potential health
threats by leveraging the data innovation team's proposed architecture.


## Getting started

First thing to do is to create the set of required environment variables by copying
the examples from [.env.example](./.env.example) to `./env`.

## What's next? How do I make an app with this?
```bash
cp .env.example .env
```

We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.
Then start the development server:

If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help.
```bash
npm run dev
```

- [Next.js](https://nextjs.org)
- [NextAuth.js](https://next-auth.js.org)
- [Prisma](https://prisma.io)
- [Tailwind CSS](https://tailwindcss.com)
- [tRPC](https://trpc.io)
Finally use your browser to visit [http://localhost:3000](http://localhost:3000).

## Learn More

This is a [T3 Stack](https://create.t3.gg/) project bootstrapped with `create-t3-app`.

To learn more about the [T3 Stack](https://create.t3.gg/), take a look at the following resources:

- [Documentation](https://create.t3.gg/)
- [Learn the T3 Stack](https://create.t3.gg/en/faq#what-learning-resources-are-currently-available) — Check out these awesome tutorials

You can check out the [create-t3-app GitHub repository](https://github.com/t3-oss/create-t3-app) — your feedback and contributions are welcome!

## How do I deploy this?

Follow our deployment guides for [Vercel](https://create.t3.gg/en/deployment/vercel), [Netlify](https://create.t3.gg/en/deployment/netlify) and [Docker](https://create.t3.gg/en/deployment/docker) for more information.
37 changes: 37 additions & 0 deletions frontend/env-dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as dotenv from "dotenv";
import pkg from "./package.json" assert { type: "json" };
import { execSync } from "child_process";

dotenv.config();

if (!pkg.envDependencies) {
process.exit(0);
}

const env = Object.assign({}, process.env);

const deps = Object.entries(pkg.envDependencies);

if (!Array.isArray(deps) || !deps.every(([_, v]) => typeof v === "string")) {
console.log("ERROR");
throw new Error(`pkg.envDependencies should have a signature of String[]`);
}

const parsed = deps.map(([_k, v]) => {
return v.replace(/\${([0-9a-zA-Z_]*)}/g, (_, varName) => {
if (varName in env) {
if (typeof varName === "string") {
const v = env[varName];
if (typeof v === "string") return v;
}
}
return "";
});
}).join(' ');

try {
execSync('npm install --no-save ' + parsed, { stdio: [0, 1, 2] })
process.exit(0)
} catch (err) {
throw new Error('Could not install pkg.envDependencies.');
}
6 changes: 6 additions & 0 deletions frontend/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ const navActual: object = jest.requireActual("next/navigation");
jest.mock("next/navigation", () => ({
...navActual,
useParams: jest.fn(),
useRouter() {
return {
prefetch: jest.fn(),
push: jest.fn(),
}
},
}));
2 changes: 1 addition & 1 deletion frontend/messages/en-CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"TimeTravel": {
"chooseDate": "Today is",
"currentDate": "current",
"travelText": "Time travel to",
"travelText": "Time travel",
"startButton": "Start",
"nextButton": "Next",
"lastButton": "Last",
Expand Down
4 changes: 2 additions & 2 deletions frontend/messages/fr-CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"title": "Sérum"
},
"TimeTravel": {
"chooseDate": "aujourd'hui c'est le",
"chooseDate": "Aujourd'hui c'est le",
"currentDate": "actuelle",
"travelText": "Voyager dans le temps vers le",
"travelText": "Voyager dans le temps",
"startButton": "Premier",
"nextButton": "Prochain",
"lastButton": "Dernier",
Expand Down
Loading
Loading