Skip to content
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

💸 QoL - Update docker to align with next setup #2387

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main-build-and-deploy.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8
package_json_file: package.json
- name: Install dependencies
run: pnpm install

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint-code.yml
Expand Up @@ -33,7 +33,7 @@ jobs:

- uses: pnpm/action-setup@v3
with:
version: 8
package_json_file: package.json

- name: Setup node
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-push-deploy.yml
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8
package_json_file: package.json
- name: Install dependencies
run: pnpm install

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-ui-tests.yml
Expand Up @@ -34,7 +34,7 @@ jobs:

- uses: pnpm/action-setup@v3
with:
version: 8
package_json_file: package.json

- name: Setup Node
uses: actions/setup-node@v4
Expand Down
45 changes: 25 additions & 20 deletions Dockerfile
@@ -1,7 +1,7 @@
# Install dependencies only when needed
FROM node:lts-alpine AS deps
RUN corepack enable
FROM node:lts-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
Expand All @@ -16,15 +16,10 @@ RUN \
fi

# Rebuild the source code only when needed
FROM node:lts-alpine AS builder
RUN corepack enable
FROM base AS builder
WORKDIR /app

COPY . .
COPY --from=deps /app/node_modules ./node_modules

# Add env for production
# COPY .docker/production/.env.local .env.local
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
Expand Down Expand Up @@ -85,32 +80,42 @@ ENV DYNAMICS_CLIENT_ID $DYNAMICS_CLIENT_ID
ARG DYNAMICS_CLIENT_SECRET
ENV DYNAMICS_CLIENT_SECRET $DYNAMICS_CLIENT_SECRET

RUN pnpm run build
RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

# Production image, copy all the files and run next
FROM node:lts-alpine AS runner
RUN corepack enable
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# 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

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=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/appInsight-api.js ./

USER nextjs

EXPOSE 3000

ENV NODE_ENV production
ENV PORT 3000

COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/appInsight-api.js ./

CMD ["node", "--require", "./appInsight-api.js", "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 HOSTNAME="0.0.0.0" node --require ./appInsight-api.js server.js
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -25,7 +25,7 @@ This repository is a v3 of the zzSSW.Website. This website uses NextJS with Tina
## Requirements

- Git, [Node.js Active LTS](https://nodejs.org/en/about/releases/)
- pnpm `corepack enable pnpm`
- pnpm `corepack enable` (version is specified in package.json)
- A [TinaCMS](https://app.tina.io) account for live editing.

## Get Started
Expand Down
44 changes: 0 additions & 44 deletions components/socialIcons/phoneButton.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions next-env.d.ts
@@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -97,5 +97,6 @@
},
"resolutions": {
"final-form": "4.20.1"
}
},
"packageManager": "pnpm@8.15.5"
}