-
Notifications
You must be signed in to change notification settings - Fork 35
fix: local docker updates and type fixes #4827
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
Open
seanmalbert
wants to merge
6
commits into
main
Choose a base branch
from
docker-updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b75c3ec
fix: fixes user type bug in auth service confirmUser
seanmalbert 3ef2809
fix: fixes type error in model-fields util
seanmalbert a5fa7ba
feat: updates local to run on docker with docker compose
seanmalbert bfebba4
fix: local docker build changes
ludtkemorgan 2b81603
fix: test fixes
ludtkemorgan 2d01228
fix: application-flagged-set fixes
ludtkemorgan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,21 @@ | ||
FROM node:18.19 | ||
|
||
# Base image | ||
FROM node:18 | ||
RUN apt-get update | ||
RUN apt-get install -y postgresql-client \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create working directory | ||
WORKDIR /usr/src/api | ||
|
||
# Copy package.json | ||
COPY package.json ./ | ||
COPY package.json yarn.lock ./ | ||
RUN yarn install --frozen-lockfile | ||
|
||
# Copy yarn.lcok | ||
COPY yarn.lock ./ | ||
|
||
# run yarn install | ||
RUN yarn install | ||
|
||
# Copy source code into docker image | ||
COPY . . | ||
|
||
# Copy .env | ||
COPY .env ./ | ||
|
||
# run build commands | ||
RUN yarn prisma generate | ||
RUN yarn build | ||
|
||
# Expose port 3100 for api | ||
COPY entrypoint.sh . | ||
RUN chmod +x entrypoint.sh | ||
|
||
EXPOSE 3100 | ||
ENTRYPOINT ["./entrypoint.sh"] | ||
|
||
# Start api | ||
CMD ["yarn", "dev"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
DB_HOST="${DB_HOST:-db}" | ||
DB_PORT="${DB_PORT:-5432}" | ||
DB_USER="${DB_USER:-postgres}" | ||
DB_PASS="${DB_PASSWORD:-postgres}" | ||
DB_NAME="bloom_prisma" | ||
|
||
echo "⏳ Waiting for Postgres at ${DB_HOST}:${DB_PORT}..." | ||
until pg_isready -h "$DB_HOST" -p "$DB_PORT"; do | ||
sleep 1 | ||
done | ||
|
||
echo "✅ Postgres is up" | ||
|
||
if [ "$RESET_DB" = "true" ]; then | ||
echo "🔄 Resetting database..." | ||
|
||
export PGPASSWORD="$DB_PASS" | ||
|
||
# Drop & recreate | ||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -c "DROP DATABASE IF EXISTS ${DB_NAME} WITH (FORCE);" | ||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -c "CREATE DATABASE ${DB_NAME};" | ||
|
||
# Enable uuid‑ossp | ||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" \ | ||
-c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" | ||
fi | ||
|
||
echo "⏳ Running migrations..." | ||
yarn db:migration:run | ||
|
||
if [ "$RUN_SEED" = "true" ]; then | ||
# Default to 'staging' if SEED_ENV not set | ||
SEED_ENV="${SEED_ENV:-staging}" | ||
echo "🌱 Seeding database (env=${SEED_ENV}, jurisdiction=${JURISDICTION_NAME})..." | ||
# this resolves to yarn db:seed:staging -- --environment staging --jurisdictionName $JURISDICTION_NAME | ||
yarn db:seed:"$SEED_ENV" -- --environment "$SEED_ENV" --jurisdictionName "$JURISDICTION_NAME" | ||
fi | ||
|
||
echo "🚀 Starting API" | ||
exec yarn dev | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,45 @@ | ||
import { Prisma } from '@prisma/client'; | ||
|
||
export const getModelFields = (modelName: string) => { | ||
return Prisma.dmmf.datamodel.models.filter( | ||
(model) => model.name === modelName, | ||
)[0].fields; | ||
}; | ||
/** | ||
* A simplified, exportable subset of Prisma's DMMF field definition. | ||
*/ | ||
export interface ModelField { | ||
/** The name of the field on the model */ | ||
name: string; | ||
/** Whether this field is the primary identifier */ | ||
isId: boolean; | ||
/** The Prisma scalar type of the field (e.g. "String", "Int", etc.) */ | ||
type: string; | ||
} | ||
|
||
export const fillModelStringFields = ( | ||
/** | ||
* Get the DMMF field metadata for a given model, cast to our exportable interface. | ||
* @param modelName The name of the Prisma model (as defined in schema.prisma) | ||
* @returns Array of ModelField objects | ||
*/ | ||
export function getModelFields(modelName: string): ModelField[] { | ||
const model = Prisma.dmmf.datamodel.models.find((m) => m.name === modelName); | ||
if (!model) { | ||
throw new Error(`Model '${modelName}' not found in Prisma DMMF.`); | ||
} | ||
// Cast the internal field definitions to our simplified, exportable shape | ||
return model.fields as unknown as ModelField[]; | ||
} | ||
|
||
/** | ||
* Create an object with only the string-based fields (excluding IDs) for a model. | ||
* Useful for seeding or generating partial objects from input data. | ||
* @param modelName The Prisma model name | ||
* @param data A record of input values keyed by field name | ||
* @returns A record containing each non-ID string field, defaulting to null if missing | ||
*/ | ||
export function fillModelStringFields( | ||
modelName: string, | ||
data: Record<string, string | null>, | ||
) => { | ||
data: Record<string, string>, | ||
): Record<string, string | null> { | ||
return Object.fromEntries( | ||
getModelFields(modelName) | ||
.filter((field) => field.isId === false && field.type === 'String') | ||
.map((field) => [field.name, data[field.name] || null]), | ||
.filter((field) => !field.isId && field.type === 'String') | ||
.map((field) => [field.name, (data[field.name] as string) || null]), | ||
); | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: everywhere else we import, it's just
from 'crypto'