Skip to content

Commit ce59f84

Browse files
authored
spike: turbo repo (#2044)
* add dockerignore * gitignore turbo and out * fix imports * update sass path for uswds to use top level node_modules * rename shared resources to @repo/ui in package.json export accordion container * setup top level package.json and turbo.json * remove install of shared-resource and add @repo/ui as a dep * use turbo Dockerfile * update context and remove volume from docker compose * remove more shared-resources stuff * set e2e and lighthouse timeouts to 20 minutes * update file path for ecr viewer github action * Delete old Dockerfile.dev * add e2e env file * update middleware and next config to not run auth and new basepath when running e2e * update package-lock * fix imports * fix dockerfile import * fix path for staging and orchestration files * remove volumes from docker-compose-orchestration.yml * update .env.e2e.test to be "TEST" * fix recommendation for dockerfile * ignore tsconfig tsbuildinfo * remove unnecessary args in Dockerfile * use .env.test in ecr-viewer and lighthouse actions Rename database url * update url for ECR_VIEWER_URL * fix middleware test * remove ecr-viewer basepath * add app env to environment variables for docker-compose * share docker services orchestration and remove docker-compose-orchestration.yml * cleanup env variables * set env variables for orchestration - ecr viewer * remove cd into ecr viewer * disable turbo telemetry * update README.md * add lighthouse job to container-ecr-viewer workflow. (#2101) merge lighthouse into container-ecr-viewer action * update package-lock.json after running npm i * Remove commented out public file in Dockerfile
1 parent 5e87661 commit ce59f84

23 files changed

+2056
-514
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/.venv
2+
**/node_modules

.github/workflows/container-ecr-viewer.yaml

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ concurrency:
2121
cancel-in-progress: true
2222

2323
env:
24-
TEST_RUNNER_PYTHON_VERSION: 3.11
2524
CONTAINER: ecr-viewer
2625
NODE_VERSION: 18 # Adjust the Node.js version as needed
2726

@@ -41,15 +40,9 @@ jobs:
4140
- name: Checkout code
4241
uses: actions/checkout@v4
4342
- name: Set up Node.js
44-
uses: actions/setup-node@v2
43+
uses: actions/setup-node@v4
4544
with:
4645
node-version: ${{env.NODE_VERSION}}
47-
- name: Remove symlinks
48-
working-directory: ./containers/${{env.CONTAINER}}/src/app/shared
49-
run: rm -rf ./*
50-
- name: Copy shared-resources
51-
working-directory: ./containers/${{env.CONTAINER}}
52-
run: cp -r ../../shared-resources/src/ ./src/app/shared/
5346
- name: Install dependencies
5447
working-directory: ./containers/${{env.CONTAINER}} # Navigate to your Node.js app directory
5548
run: npm install
@@ -58,26 +51,21 @@ jobs:
5851
run: npm test
5952
cypress-e2e-tests:
6053
runs-on: ubuntu-latest
54+
timeout-minutes: 20
6155
steps:
6256
- name: Checkout code
6357
uses: actions/checkout@v4
6458
- name: Set up Node.js
65-
uses: actions/setup-node@v2
59+
uses: actions/setup-node@v4
6660
with:
6761
node-version: ${{env.NODE_VERSION}}
68-
- name: Remove symlinks
69-
working-directory: ./containers/${{env.CONTAINER}}/src/app/shared
70-
run: rm -rf ./*
71-
- name: Copy shared-resources
72-
working-directory: ./containers/${{env.CONTAINER}}
73-
run: cp -r ../../shared-resources/src/ ./src/app/shared/
7462
- name: Install dependencies
7563
working-directory: ./containers/${{env.CONTAINER}} # Navigate to your Node.js app directory
7664
run: npm install
7765

7866
- name: Start ${{env.CONTAINER}}
7967
working-directory: ./containers/${{env.CONTAINER}}
80-
run: docker compose up -d
68+
run: docker compose --env-file .env.test up -d
8169

8270
- name: Wait for server to be ready
8371
run: |
@@ -89,6 +77,36 @@ jobs:
8977
- name: Run cypress tests
9078
working-directory: ./containers/${{env.CONTAINER}}
9179
run: npm run cypress:run
80+
lighthouse:
81+
runs-on: ubuntu-latest
82+
timeout-minutes: 20
83+
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v4
87+
88+
- name: Set up Node.js
89+
uses: actions/setup-node@v4
90+
with:
91+
node-version: ${{env.NODE_VERSION}}
92+
93+
- name: Build app
94+
run: docker compose --env-file .env.test up -d
95+
working-directory: ./containers/${{env.CONTAINER}}
96+
97+
- name: Wait for Application to be ready
98+
run: |
99+
until curl --output /dev/null --silent --head --fail http://localhost:3000; do
100+
printf '.'
101+
sleep 5
102+
done
103+
104+
- name: Run Lighthouse
105+
uses: treosh/lighthouse-ci-action@v12
106+
with:
107+
configPath: "./lighthouserc.yaml"
108+
uploadArtifacts: true
109+
92110
build-container:
93111
runs-on: ubuntu-latest
94112
steps:
@@ -104,18 +122,11 @@ jobs:
104122
- name: Set up Docker Buildx
105123
uses: docker/setup-buildx-action@v2
106124

107-
- name: Remove symlinks
108-
working-directory: ./containers/${{env.CONTAINER}}/src/app/shared
109-
run: rm -rf ./*
110-
111-
- name: Copy shared-resources
112-
working-directory: ./containers/${{env.CONTAINER}}
113-
run: cp -r ../../shared-resources/src/ ./src/app/shared/
114-
115125
- name: Build ${{ env.CONTAINER }} Container
116126
uses: docker/build-push-action@v3
117127
with:
118-
context: ./containers/${{ env.CONTAINER }}
128+
context: .
129+
file: ./containers/${{ env.CONTAINER }}/Dockerfile
119130
push: false
120131
cache-from: type=gha
121132
cache-to: type=gha,mode=max

.github/workflows/lighthouse.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,8 @@ persistent_storage/
7979
build/
8080

8181
## ECR Viewer Seed data
82-
/containers/ecr-viewer/seed-scripts/fhir_data/
82+
/containers/ecr-viewer/seed-scripts/fhir_data/
83+
84+
.turbo
85+
out
86+
tsconfig.tsbuildinfo

containers/ecr-viewer/.env.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DATABASE_URL=postgres://postgres:pw@db:5432/ecr_viewer_db
2+
APP_ENV=test

containers/ecr-viewer/Dockerfile

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,55 @@
11
FROM node:18-alpine AS base
22

3-
ARG APP_ENV
4-
ENV APP_ENV=${APP_ENV}
5-
6-
# Install dependencies only when needed
7-
FROM base AS deps
3+
FROM base AS builder
84
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
5+
RUN apk update
96
RUN apk add --no-cache libc6-compat
10-
WORKDIR /app
11-
12-
# Install dependencies based on the preferred package manager
13-
COPY package.json package-lock.json* ./
14-
RUN npm ci
15-
167

17-
# Rebuild the source code only when needed
18-
FROM base AS builder
8+
# Set working directory
199
WORKDIR /app
20-
COPY --from=deps /app/node_modules ./node_modules
10+
RUN npm i -g turbo
2111
COPY . .
12+
ENV TURBO_TELEMETRY_DISABLED=1
13+
RUN turbo prune ecr-viewer --docker
14+
15+
# Add lockfile and package.json's of isolated subworkspace
16+
FROM base AS installer
17+
RUN apk update
18+
RUN apk add --no-cache libc6-compat
19+
WORKDIR /app
2220

23-
# Next.js collects completely anonymous telemetry data about general usage.
24-
# Learn more here: https://nextjs.org/telemetry
25-
# Uncomment the following line in case you want to disable telemetry during the build.
26-
ENV NEXT_TELEMETRY_DISABLED 1
21+
# First install the dependencies (as they change less often)
22+
COPY .gitignore .gitignore
23+
COPY --from=builder /app/out/json/ .
24+
COPY --from=builder /app/out/package-lock.json ./package-lock.json
25+
RUN npm i
2726

28-
RUN npm run build
27+
# Build the project
28+
COPY --from=builder /app/out/full/ .
29+
COPY turbo.json turbo.json
30+
ENV NEXT_TELEMETRY_DISABLED=1
31+
ENV TURBO_TELEMETRY_DISABLED=1
32+
33+
RUN npx turbo build --filter=ecr-viewer...
2934

30-
# Production image, copy all the files and run next
3135
FROM base AS runner
3236
WORKDIR /app
3337

34-
# Uncomment the following line in case you want to disable telemetry during runtime.
35-
ENV NEXT_TELEMETRY_DISABLED 1
36-
38+
# Don't run production as root
3739
RUN addgroup --system --gid 1001 nodejs
3840
RUN adduser --system --uid 1001 nextjs
41+
USER nextjs
3942

40-
# COPY --from=builder /app/public ./public
41-
42-
# Set the correct permission for prerender cache
43-
RUN mkdir .next
44-
RUN chown nextjs:nodejs .next
43+
COPY --from=installer /app/containers/ecr-viewer/next.config.js .
44+
COPY --from=installer /app/containers/ecr-viewer/package.json .
4545

4646
# Automatically leverage output traces to reduce image size
4747
# https://nextjs.org/docs/advanced-features/output-file-tracing
48-
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
49-
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
48+
COPY --from=installer --chown=nextjs:nodejs /app/containers/ecr-viewer/.next/standalone ./
49+
COPY --from=installer --chown=nextjs:nodejs /app/containers/ecr-viewer/.next/static ./containers/ecr-viewer/.next/static
5050

51-
USER nextjs
52-
53-
EXPOSE 3000
54-
55-
ENV PORT 3000
56-
ENV HOSTNAME "0.0.0.0"
51+
ENV TURBO_TELEMETRY_DISABLED=1
52+
ENV NEXT_TELEMETRY_DISABLED=1
5753
ENV OTEL_TRACES_EXPORTER=otlp
5854
ENV OTEL_METRICS_EXPORTER=otlp
5955
ENV OTEL_LOGS_EXPORTER=none
@@ -65,9 +61,6 @@ ENV OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://otel-collector:4318/v1/metrics
6561
# Jaeger preferred routing is gRPC for native OTLP
6662
ENV OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
6763
# Contrary to orchestration, this must be 4318
68-
ENV OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4318/v1/traces
69-
64+
ENV OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4318/v1/traces
7065

71-
# server.js is created by next build from the standalone output
72-
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
73-
CMD node server.js
66+
CMD ["node", "containers/ecr-viewer/server.js"]

containers/ecr-viewer/Dockerfile.dev

Lines changed: 0 additions & 22 deletions
This file was deleted.

containers/ecr-viewer/docker-compose-orchestration.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)