Skip to content

Commit b2c2bc1

Browse files
authored
Merge branch 'main' into 4730/upgrade-next-to-react19
2 parents 770200d + 1b9eb2e commit b2c2bc1

101 files changed

Lines changed: 3018 additions & 957 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docker Image Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
env:
14+
image_base: ghcr.io/${{ github.repository }}
15+
16+
jobs:
17+
build-image:
18+
# Builds each image in a separate job in parallel.
19+
strategy:
20+
matrix:
21+
# The docker/build-push-action uses the git repo as the docker build context instead of
22+
# cloning the repo to the action runner disk and using the disk context. For the API image
23+
# we need to set the context to just the api/ directory which the '{{defaultContext}}:api'
24+
# syntax does: https://github.com/docker/build-push-action?tab=readme-ov-file#git-context.
25+
include:
26+
- container: api
27+
docker_context: "{{defaultContext}}:api"
28+
dockerfile: Dockerfile
29+
- container: partners
30+
docker_context: "{{defaultContext}}"
31+
dockerfile: Dockerfile.sites.partners
32+
- container: public
33+
docker_context: "{{defaultContext}}"
34+
dockerfile: Dockerfile.sites.public
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Log in to GitHub Container Registry
38+
uses: docker/login-action@v3.6.0
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
# Required to use image layer cache.
45+
- name: Setup Docker Buildx
46+
uses: docker/setup-buildx-action@v3.11.1
47+
48+
- name: "Build and push image"
49+
uses: docker/build-push-action@v6.18.0
50+
with:
51+
push: true
52+
cache-to: type=registry,mode=max,ref=${{ env.image_base }}/${{ matrix.container }}/container-layer-cache:latest
53+
cache-from: type=registry,ref=${{ env.image_base }}/${{ matrix.container }}/container-layer-cache:latest
54+
context: ${{ matrix.docker_context }}
55+
file: ${{ matrix.dockerfile }}
56+
tags: |
57+
${{ env.image_base }}/${{ matrix.container }}:latest
58+
${{ env.image_base }}/${{ matrix.container }}:gitsha-${{ github.sha }}
59+
# Connects the image to the repository: https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package.
60+
labels: org.opencontainers.image.source=https://github.com/${{ github.repository }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ dump.rdb
9999
# Development planning files
100100
memory-bank/
101101
.github/copilot-instructions.md
102+
103+
# Terraform providers
104+
.terraform

Dockerfile.sites.partners

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Keep up to date with Active LTS: https://nodejs.org/en/about/previous-releases
2+
FROM node:22@sha256:23c24e85395992be118734a39903e08c8f7d1abc73978c46b6bda90060091a49
3+
4+
# Create a non-root user to build and run (principle of least privilege).
5+
WORKDIR /app
6+
RUN groupadd --gid 2002 next && useradd --gid 2002 --uid 2002 --home /app next
7+
RUN chown 2002:2002 /app
8+
USER 2002:2002
9+
10+
# Copy package.json and yarn.lock in a separate layer from the source code and install the
11+
# dependencies. This allows docker to cache this step if dependencies haven't changed from the last
12+
# docker build, making build times a lot faster.
13+
COPY --chown=2002:2002 package.json yarn.lock .
14+
COPY --chown=2002:2002 shared-helpers ./shared-helpers
15+
COPY --chown=2002:2002 sites/partners/package.json ./sites/partners/
16+
WORKDIR /app/sites/partners
17+
RUN yarn install --frozen-lockfile
18+
19+
# Copy in the source code. `next build` needs the tsconfig.json at repo root for type
20+
# checking.
21+
COPY --chown=2002:2002 tsconfig.json /app/tsconfig.json
22+
COPY --chown=2002:2002 sites/partners .
23+
24+
ENV NEXT_TELEMETRY_DISABLED=1
25+
CMD [ "/bin/bash", "-c", "yarn build && yarn start" ]

Dockerfile.sites.public

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Keep up to date with Active LTS: https://nodejs.org/en/about/previous-releases
2+
FROM node:22@sha256:23c24e85395992be118734a39903e08c8f7d1abc73978c46b6bda90060091a49
3+
4+
# Create a non-root user to build and run (principle of least privilege).
5+
WORKDIR /app
6+
RUN groupadd --gid 2002 next && useradd --gid 2002 --uid 2002 --home /app next
7+
RUN chown 2002:2002 /app
8+
USER 2002:2002
9+
10+
# Copy package.json and yarn.lock in a separate layer from the source code and install the
11+
# dependencies. This allows docker to cache this step if dependencies haven't changed from the last
12+
# docker build, making build times a lot faster.
13+
COPY --chown=2002:2002 package.json yarn.lock .
14+
COPY --chown=2002:2002 shared-helpers ./shared-helpers
15+
COPY --chown=2002:2002 sites/public/package.json ./sites/public/
16+
WORKDIR /app/sites/public
17+
RUN yarn install --frozen-lockfile
18+
19+
# Copy in the source code. `next build` needs the tsconfig.json at repo root for type
20+
# checking.
21+
COPY --chown=2002:2002 tsconfig.json /app/tsconfig.json
22+
COPY --chown=2002:2002 sites/public .
23+
24+
ENV NEXT_TELEMETRY_DISABLED=1
25+
CMD [ "/bin/bash", "-c", "yarn build && yarn start" ]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ You can also run each process individually from separate terminals with the foll
8282

8383
We have a number of default users seeded for local development, the most basic of which being (email: `admin@example.com`, password: `abcdef`) which will login to both the public and partners sites, but you can view other default seeded users and their permissions by checking out the user section of the [seed file](https://github.com/bloom-housing/bloom/blob/aed77bf06525be359ef9205044fabbea2ab2576d/api/prisma/seed-staging.ts#L67).
8484

85+
### Running locally in docker
86+
87+
Docker documentation is in [docker.md](./docker.md).
88+
8589
### Bloom UIC development
8690

8791
Because Bloom's ui-components package is a separate open source repository, developing in Bloom while concurrently iterating in ui-components requires linking the folders with the following steps:

api/.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ LOTTERY_PUBLISH_PROCESSING_CRON_STRING=58 23 * * *
4444
LOTTERY_PROCESSING_CRON_STRING=0 * * * *
4545
# how many days till lottery data expires
4646
LOTTERY_DAYS_TILL_EXPIRY=45
47+
# how many days until application PII data exists
48+
APPLICATION_DAYS_TILL_EXPIRY=
4749
# the list of allowed urls that can make requests to the api (strings must be exact matches)
4850
CORS_ORIGINS=["http://localhost:3000", "http://localhost:3001"]
4951
# spill over list of allowed urls that can make requests to the api (strings are turned into regex)

api/Dockerfile

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,56 @@
1-
2-
# Base image
3-
FROM node:18
4-
5-
# Create working directory
6-
WORKDIR /usr/src/api
7-
8-
# Copy package.json
9-
COPY package.json ./
10-
11-
# Copy yarn.lcok
12-
COPY yarn.lock ./
13-
14-
# run yarn install
15-
RUN yarn install
16-
17-
# Copy source code into docker image
18-
COPY . .
19-
20-
# Copy .env
21-
COPY .env ./
22-
23-
# run build commands
1+
# Keep up to date with Active LTS: https://nodejs.org/en/about/previous-releases
2+
#
3+
# IMPORTANT: keep the 'run' layer below in sync.
4+
FROM node:22@sha256:23c24e85395992be118734a39903e08c8f7d1abc73978c46b6bda90060091a49 AS build
5+
6+
7+
# Create a non-root user to build (principle of least privilege).
8+
WORKDIR /build
9+
RUN groupadd --gid 2002 build && useradd --gid 2002 --uid 2002 --home /build build
10+
RUN chown 2002:2002 /build
11+
USER 2002:2002
12+
13+
# Install only runtime dependencies into a separate directory. This will be copied into the runner
14+
# image.
15+
WORKDIR /build/runtime_dependencies
16+
COPY --chown=2002:2002 package.json yarn.lock ./
17+
RUN yarn install --frozen-lockfile --production
18+
19+
# Copy package.json and yarn.lock in a separate layer from the source code and install the
20+
# dependencies. This allows docker to cache this step if package.json and yarn.lock haven't changed
21+
# from the last docker build, making build times a lot faster.
22+
WORKDIR /build
23+
COPY --chown=2002:2002 package.json yarn.lock ./
24+
RUN yarn install --frozen-lockfile
25+
26+
# Copy the source code and build.
27+
COPY --chown=2002:2002 . .
2428
RUN yarn prisma generate
2529
RUN yarn build
2630

27-
# Expose port 3100 for api
28-
EXPOSE 3100
29-
30-
# Start api
31-
CMD ["yarn", "dev"]
31+
# Start a new container filesystem and copy in just the runtime dependencies and the built
32+
# application.
33+
#
34+
# IMPORTANT: keep the 'build' layer above in sync.
35+
FROM node:22@sha256:23c24e85395992be118734a39903e08c8f7d1abc73978c46b6bda90060091a49 AS run
36+
WORKDIR /run
37+
38+
# Copy over build artifacts.
39+
COPY --from=build /build/runtime_dependencies/ .
40+
COPY --from=build /build/dist ./dist
41+
42+
# Need to copy the prisma schema file and generated package from `yarn prisma generate`.
43+
# TODO: be explicit about where the client package is generated:
44+
# https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/generating-prisma-client
45+
COPY --from=build /build/prisma/schema.prisma ./prisma/schema.prisma
46+
COPY --from=build /build/prisma/migrations ./prisma/migrations
47+
COPY --from=build /build/node_modules/.prisma ./node_modules/.prisma
48+
49+
# Create a non-root user to run (priciple of least priviledge).
50+
WORKDIR /run
51+
RUN groupadd --gid 2002 run && useradd --gid 2002 --uid 2002 --home /run run
52+
RUN chown --recursive 2002:2002 /run
53+
USER 2002:2002
54+
55+
# Run any DB migrations then start the server.
56+
CMD [ "/bin/bash", "-c", "yarn db:migration:run && yarn start:prod" ]

api/Dockerfile.dbseed

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Keep up to date with Active LTS: https://nodejs.org/en/about/previous-releases
2+
FROM node:22 AS build
3+
4+
# Create a non-root user to build (priciple of least priviledge).
5+
WORKDIR /dbseed
6+
RUN groupadd --gid 2002 dbseed && useradd --gid 2002 --uid 2002 --home /dbseed dbseed
7+
RUN chown 2002:2002 /dbseed
8+
USER 2002:2002
9+
10+
# Copy package.json and yarn.lock in a separate layer from the source code and install the
11+
# dependencies. This allows docker to cache this step if package.json and yarn.lock haven't changed
12+
# from the last docker build, making build times a lot faster.
13+
WORKDIR /build
14+
COPY --chown=2002:2002 package.json yarn.lock ./
15+
RUN yarn install --frozen-lockfile
16+
17+
# Copy the source code and generate the prisma client.
18+
COPY --chown=2002:2002 . .
19+
RUN yarn prisma generate
20+
21+
CMD [ "yarn", "db:seed:staging" ]

api/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"test:cov": "yarn db:resetup && yarn db:migration:run && jest --config ./test/jest-with-coverage.config.js --logHeapUsage",
2020
"test:cov-ci": "yarn db:migration:run && jest --config ./test/jest-with-coverage.config.js --runInBand --logHeapUsage",
2121
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
22-
"db:resetup": "psql -c 'DROP DATABASE IF EXISTS bloom_prisma WITH (FORCE);' && psql -c 'CREATE DATABASE bloom_prisma;' && psql -d bloom_prisma -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'",
22+
"db:resetup": "psql -c \"DROP DATABASE IF EXISTS bloom_prisma WITH (FORCE);\" && psql -c \"CREATE DATABASE bloom_prisma;\" && psql -d bloom_prisma -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"",
2323
"db:migration:run": "yarn prisma migrate deploy",
2424
"db:seed:production": "npx prisma db seed -- --environment production",
25-
"db:seed:staging": "npx prisma db seed -- --environment staging",
25+
"db:seed:staging": "npx prisma db seed -- --environment staging --jurisdictionName Bloomington",
2626
"db:seed:development": "npx prisma db seed -- --environment development --jurisdictionName Bloomington",
2727
"generate:client": "ts-node scripts/generate-axios-client.ts && prettier -w ../shared-helpers/src/types/backend-swagger.ts",
2828
"test:e2e": "yarn db:resetup && yarn db:migration:run && jest --config ./test/jest-e2e.config.js",
@@ -48,7 +48,7 @@
4848
"@nestjs/schedule": "^4.1.1",
4949
"@nestjs/swagger": "^7.4.2",
5050
"@nestjs/throttler": "^5.1.2",
51-
"@prisma/client": "^5.0.0",
51+
"@prisma/client": "^5.3.0",
5252
"@sendgrid/helpers": "^8.0.0",
5353
"@sendgrid/mail": "7.7.0",
5454
"@turf/boolean-point-in-polygon": "6.5.0",
@@ -66,7 +66,7 @@
6666
"cookie-parser": "~1.4.6",
6767
"cron": "^3.1.7",
6868
"dayjs": "~1.11.9",
69-
"dotenv": "^16.4.5",
69+
"dotenv": "^17.2.3",
7070
"exceljs": "^4.4.0",
7171
"express": "^4.21.1",
7272
"handlebars": "~4.7.8",
@@ -76,7 +76,7 @@
7676
"passport": "~0.6.0",
7777
"passport-jwt": "~4.0.1",
7878
"passport-local": "~1.0.0",
79-
"prisma": "^5.0.0",
79+
"prisma": "^5.3.0",
8080
"qs": "~6.11.2",
8181
"reflect-metadata": "~0.1.13",
8282
"rimraf": "^3.0.2",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterEnum
2+
ALTER TYPE "listings_review_order_type_enum" ADD VALUE 'waitlistLottery';

0 commit comments

Comments
 (0)