Skip to content

Commit

Permalink
Remove turbo & shared-resources from eCR Viewer (#2878)
Browse files Browse the repository at this point in the history
* update github workflows

* move back shared resources and fix build errors

* remove shared-resources and turbo from phdi

* one more nit

* update snapshot test

* remove turbo daemon log

* update context location in github workflow

* add package-lock.json, forgot to add to merge

* ran npm ci
  • Loading branch information
angelathe authored Nov 13, 2024
1 parent 5a243bf commit e130012
Show file tree
Hide file tree
Showing 27 changed files with 3,312 additions and 3,373 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/buildReleaseContainers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,3 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push with shared-resources
uses: docker/build-push-action@v3
if: ${{ contains(fromJSON('["ecr-viewer"]'), matrix.container-to-build) }}
with:
context: .
file: ./containers/${{ matrix.container-to-build }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 1 addition & 2 deletions .github/workflows/container-ecr-viewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
paths:
- containers/ecr-viewer/**
- containers/fhir-converter/**
- packages/**
merge_group:
types:
- checks_requested
Expand Down Expand Up @@ -146,7 +145,7 @@ jobs:
- name: Build ${{ env.CONTAINER }} Container
uses: docker/build-push-action@v3
with:
context: .
context: ./containers/${{ env.CONTAINER }}
file: ./containers/${{ env.CONTAINER }}/Dockerfile
push: false
cache-from: type=gha
Expand Down
51 changes: 0 additions & 51 deletions .github/workflows/package-shared-resources.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ build/
## ECR Viewer Seed data
/containers/ecr-viewer/seed-scripts/fhir_data/

.turbo
out
tsconfig.tsbuildinfo

.env
Expand Down
79 changes: 40 additions & 39 deletions containers/ecr-viewer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,69 +1,70 @@
FROM node:18-alpine AS base

FROM base AS builder
ARG APP_ENV
ENV APP_ENV=${APP_ENV}

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update
RUN apk add --no-cache libc6-compat

# Set working directory
WORKDIR /app
RUN npm i -g turbo
COPY . .
ENV TURBO_TELEMETRY_DISABLED=1
RUN turbo prune ecr-viewer --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* ./
RUN npm ci

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
RUN npm i

# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
ENV NEXT_TELEMETRY_DISABLED=1
ENV TURBO_TELEMETRY_DISABLED=1
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npx turbo build --filter=ecr-viewer...
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

# Don't run production as root
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/containers/ecr-viewer/next.config.js .
COPY --from=installer /app/containers/ecr-viewer/package.json .
# COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

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

USER nextjs

EXPOSE 3000

ENV TURBO_TELEMETRY_DISABLED=1
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
ENV OTEL_TRACES_EXPORTER=otlp
ENV OTEL_METRICS_EXPORTER=otlp
ENV OTEL_LOGS_EXPORTER=none

# Prometheus preferred transfer is via HTTP
ENV OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
ENV OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://otel-collector:4318/v1/metrics

# Jaeger preferred routing is gRPC for native OTLP
ENV OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
# Contrary to orchestration, this must be 4318
ENV OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4318/v1/traces
EXPOSE 3000
ENV OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4318/v1/traces


ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "containers/ecr-viewer/server.js"]
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD node server.js
4 changes: 2 additions & 2 deletions containers/ecr-viewer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
services:
ecr-viewer:
build:
context: ../../
dockerfile: ./containers/ecr-viewer/Dockerfile
context: ./
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
Expand Down
9 changes: 1 addition & 8 deletions containers/ecr-viewer/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ const path = require("path");
const nextConfig = {
sassOptions: {
includePaths: [
path.join(
__dirname,
"../..",
"node_modules",
"@uswds",
"uswds",
"packages",
),
path.join(__dirname, "node_modules", "@uswds", "uswds", "packages"),
],
},
experimental: {
Expand Down
Loading

0 comments on commit e130012

Please sign in to comment.