-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
992 additions
and
289 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -10,3 +10,7 @@ stories | |
.prettier* | ||
LICENSE | ||
README.md | ||
__mocks__ | ||
test-results | ||
.env.local.sample | ||
dev |
This file contains 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,6 +1,19 @@ | ||
BASE_CANONICAL_URL= | ||
API_HOST_CLIENT= | ||
API_HOST_SERVER= | ||
NEXT_PUBLIC_API_HOST_CLIENT= | ||
COOKIE_SECRET= | ||
ADS_SESSION_COOKIE_NAME= | ||
SCIX_SESSION_COOKIE_NAME= | ||
NEXT_PUBLIC_ORCID_CLIENT_ID= | ||
NEXT_PUBLIC_ORCID_API_URL= | ||
NEXT_PUBLIC_ORCID_REDIRECT_URI= | ||
REDIS_HOST= | ||
REDIS_PORT= | ||
REDIS_PASSWORD= | ||
VERIFIED_BOTS_ACCESS_TOKEN= | ||
UNVERIFIABLE_BOTS_ACCESS_TOKEN= | ||
MALICIOUS_BOTS_ACCESS_TOKEN= | ||
NEXT_PUBLIC_GTM_ID= | ||
NEXT_PUBLIC_RECAPTCHA_SITE_KEY= | ||
MAILSLURP_API_TOKEN= |
This file contains 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,11 @@ | ||
name: CI | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
unit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build and Run Unit Tests | ||
run: ./nectar.sh --unit | ||
|
This file contains 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 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 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,63 +1,93 @@ | ||
FROM node:18-alpine AS base | ||
|
||
# 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 add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN npm install -g pnpm | ||
|
||
# Files required by pnpm install | ||
COPY .npmrc.* package.json pnpm-lock.yaml .pnpmfile.cjs.* ./ | ||
|
||
# install deps | ||
RUN pnpm add sharp | ||
RUN pnpm install --frozen-lockfile --ignore-scripts --no-optional | ||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
FROM node:20-slim AS base | ||
ENV PNPM_HOME=/pnpm | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | ||
ENV NODE_ENV=production | ||
|
||
# Add the git commit hash to the environment variables | ||
RUN export GIT_SHA=$(git rev-parse HEAD); echo "GIT_SHA=$GIT_SHA" >> .env.local | ||
|
||
# ensure pnpm is available in the builder | ||
RUN npm install -g pnpm | ||
ENV PATH="$PNPM_HOME:/app/.bin:/app/node_modules/.bin:$PATH" | ||
ARG GIT_SHA | ||
ENV GIT_SHA="$GIT_SHA" | ||
ENV PORT=8000 | ||
ENV SENTRYCLI_SKIP_DOWNLOAD=1 | ||
ENV HOSTNAME="0.0.0.0" | ||
|
||
RUN corepack enable | ||
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
apt update && apt-get --no-install-recommends install -y libc6 | ||
USER $USER_ID | ||
WORKDIR /app | ||
|
||
RUN pnpm run build | ||
FROM base as dev | ||
COPY --link . /app | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --ignore-scripts --no-optional | ||
ENTRYPOINT ["pnpm", "run", "dev"] | ||
|
||
FROM base as unit | ||
COPY --link vitest.config.js /app | ||
COPY --link vitest-setup.ts /app | ||
COPY --link package.json /app | ||
COPY --link tsconfig.json /app | ||
COPY --link logger /app/logger | ||
COPY --link src /app/src | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install vitest | ||
ENTRYPOINT ["vitest"] | ||
|
||
FROM base AS build_prod | ||
COPY --link . /app | ||
RUN mkdir -p /app/dist/cache | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --ignore-scripts --no-optional --prod | ||
RUN --mount=type=cache,id=nextjs,target=/app/dist/cache pnpm run build | ||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
FROM base AS prod | ||
ENV NODE_ENV=production | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/.env.local ./ | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/dist/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/dist/static ./dist/static | ||
COPY --link --from=build_prod --chown=nextjs:nodejs /app/dist/standalone /app | ||
COPY --link --from=build_prod --chown=nextjs:nodejs /app/dist/static /app/dist/static | ||
COPY --link --from=build_prod --chown=nextjs:nodejs /app/public /app/public | ||
COPY --link --from=build_prod --chown=nextjs:nodejs --chmod=777 /app/dist/cache /app/dist/cache | ||
|
||
USER nextjs | ||
|
||
EXPOSE 8000 | ||
ENTRYPOINT ["node", "server.js"] | ||
|
||
ENV PORT 8000 | ||
|
||
CMD ["node", "server.js"] | ||
FROM mcr.microsoft.com/playwright:v1.42.1-jammy as e2e | ||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | ||
ENV PNPM_HOME=/pnpm | ||
ENV PATH="$PNPM_HOME:/app/node_modules/.bin:$PATH" | ||
ARG USER_ID=1001 | ||
ARG GROUP_ID=1001 | ||
ARG GIT_SHA | ||
ENV GIT_SHA="$GIT_SHA" | ||
ENV PORT=8000 | ||
ENV HOSTNAME="0.0.0.0" | ||
|
||
RUN usermod -u "$USER_ID" pwuser | ||
RUN usermod -g "$GROUP_ID" pwuser | ||
|
||
RUN corepack enable | ||
WORKDIR /app | ||
|
||
RUN mkdir /app/screenshots | ||
RUN mkdir /app/test-results | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install @playwright/test playwright @faker-js/faker | ||
|
||
# including src so that we can use the same tsconfig.json to reconcile imports (mostly for typings) | ||
COPY --link src /app/src | ||
COPY --link playwright.config.ts /app | ||
COPY --link --chown="$USER_ID:$GROUP_ID" playwright /app/playwright | ||
COPY --link e2e /app/e2e | ||
COPY --link tsconfig.json /app | ||
COPY --link --from=build_prod /app/dist/standalone /app | ||
COPY --link --from=build_prod /app/dist/static /app/dist/static | ||
COPY --link --from=build_prod /app/public /app/public | ||
COPY --link --from=build_prod /app/dist/cache /app/dist/cache | ||
|
||
ENTRYPOINT ["playwright"] | ||
CMD ["test"] |
Oops, something went wrong.