Skip to content

Commit 343ff80

Browse files
authored
Merge pull request #16 from AIObjectives/brandon-nextjs2
Repo rearchitecture to add nextjs server
2 parents 86e66b2 + ee9ec52 commit 343ff80

File tree

225 files changed

+25872
-11260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+25872
-11260
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ node_modules/
33
.DS_Store
44
google-credentials.json
55
.env*
6-
.vscode/
6+
.vscode/
7+
.next
8+
dist

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run format

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignore artifacts:
2+
build
3+
coverage
4+
dist
5+
fixtures
6+
node_modules

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Dockerfile

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,37 @@ FROM node:16-slim
55
# Create and change to the app directory.
66
WORKDIR /usr/src/app
77

8-
# Copy application dependency manifests to the container image.
9-
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
10-
COPY package*.json ./
8+
# copy the packages from common and express
9+
COPY ./common/package*.json ./common/
10+
COPY ./express-pipeline/package*.json ./express-pipeline/
1111

12-
# Install production dependencies.
12+
# npm install common before express
13+
WORKDIR /usr/src/app/common
1314
RUN npm install --only=production
1415

15-
# Copy local code to the container image.
16-
COPY . .
16+
# move contents of common into docker image before express
17+
WORKDIR /usr/src/app
18+
COPY ./common ./common
19+
20+
# build common
21+
WORKDIR /usr/src/app/common
22+
RUN npm run build
23+
24+
# install express packages
25+
WORKDIR /usr/src/app/express-pipeline
26+
RUN npm install --only-production
27+
28+
# copy express contents
29+
WORKDIR /usr/src/app
30+
COPY ./express-pipeline ./express-pipeline
31+
32+
# build express app
33+
WORKDIR /usr/src/app/express-pipeline
34+
RUN npm run build
1735

18-
# Expose port 8080 to the Docker daemon, since Cloud Run only listens on this port.
36+
# # Expose port 8080 to the Docker daemon, since Cloud Run only listens on this port.
1937
EXPOSE 8080
2038

21-
# Run the web service on container startup.
39+
WORKDIR /usr/src/app/express-pipeline
40+
# # Run the web service on container startup.
2241
CMD [ "npm", "start" ]

bin/docker-build-gcloud.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# get current project id from gcloud
22
PROJECT_ID=$(gcloud config get-value project)
33
# build for linux platform
4-
docker build --platform=linux/amd64 -t gcr.io/$PROJECT_ID/ttc-light-js-app .
4+
docker build --platform=linux/amd64 -t gcr.io/$PROJECT_ID/ttc-light-js-app ..
55
# push to google cloud registry
66
docker push gcr.io/$PROJECT_ID/ttc-light-js-app

bin/docker-build-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docker build -t tttc-light-js .
1+
docker build -t tttc-light-js ..

common/api.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { z } from "zod";
2+
3+
export const generateApiReponse = z.object({
4+
message: z.string(),
5+
filename: z.string().min(1),
6+
jsonUrl: z.string().url(),
7+
reportUrl: z.string().url(),
8+
});
9+
10+
export type GenerateApiResponse = z.infer<typeof generateApiReponse>;

common/package-lock.json

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "tttc-common",
3+
"version": "1.0.0",
4+
"description": "Shares common code across monorepo",
5+
"main": "index.ts",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "npx tsc",
9+
"watch": "npx tsc --watch --outDir ./dist"
10+
},
11+
"author": "",
12+
"license": "MIT",
13+
"dependencies": {
14+
"react": "^18.2.0",
15+
"react-dom": "^18.2.0",
16+
"zod": "^3.22.4"
17+
},
18+
"devDependencies": {
19+
"@types/react": "^18.2.67",
20+
"typescript": "^5.3.3"
21+
}
22+
}

0 commit comments

Comments
 (0)