Build once instead of at runtime
All checks were successful
Publish Docker Image / Publish Docker Image (push) Successful in 17s
All checks were successful
Publish Docker Image / Publish Docker Image (push) Successful in 17s
This commit is contained in:
33
Dockerfile
33
Dockerfile
@@ -1,26 +1,41 @@
|
||||
FROM node:lts-alpine AS builder
|
||||
ARG APP_VERSION=dev
|
||||
FROM node:lts-alpine AS deps
|
||||
ARG APP_VERSION
|
||||
ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare yarn@4.9.1 --activate
|
||||
|
||||
COPY package.json yarn.lock .yarnrc.yml ./
|
||||
RUN yarn install --immutable
|
||||
|
||||
COPY . .
|
||||
RUN yarn build
|
||||
|
||||
FROM node:lts-alpine AS runner
|
||||
ARG APP_VERSION=dev
|
||||
ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION \
|
||||
APP_VERSION=$APP_VERSION \
|
||||
NODE_ENV=production \
|
||||
NEXT_TELEMETRY_DISABLED=1 \
|
||||
PORT=3000
|
||||
NEXT_TELEMETRY_DISABLED=1
|
||||
LABEL org.opencontainers.image.version=$APP_VERSION
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare yarn@4.9.1 --activate \
|
||||
&& addgroup -S nodejs -g 1001 \
|
||||
&& adduser -S nextjs -u 1001
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=deps /app/package.json ./package.json
|
||||
COPY . .
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
|
||||
COPY --from=builder /app/yarn.lock ./yarn.lock
|
||||
COPY --from=builder /app/.yarnrc.yml ./.yarnrc.yml
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
|
||||
RUN mkdir -p /app/.yarn && chown -R nextjs:nodejs /app/.yarn
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
CMD ["sh", "-c", "yarn build && yarn start -p $PORT"]
|
||||
|
||||
CMD ["yarn", "start"]
|
||||
|
||||
@@ -5,6 +5,7 @@ import { prettify } from "awesome-ajv-errors";
|
||||
|
||||
export async function register() {
|
||||
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||
console.info(`Portfolio v2 ${process.env.NEXT_PUBLIC_APP_VERSION}`);
|
||||
const phoneRegex = /^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$/;
|
||||
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
|
||||
Reference in New Issue
Block a user