Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
.DS_Store
*.pem
.vscode
.idea

# debug
npm-debug.log*
Expand Down
37 changes: 37 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM docker.io/node:24-slim AS base

# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN corepack enable pnpm && pnpm i --frozen-lockfile


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable pnpm && pnpm run build


# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
# Set all env variables here
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Remove this in the case of kubernetes, probably
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# 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
USER nextjs
EXPOSE 3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
CMD ["node", "server.js"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pnpm install
pnpm dev
```

## Running For Production

Check out the Next.js documentation on options for running this.
https://nextjs.org/docs/pages/getting-started/deploying
Alternatively, use the provided [Containerfile](Containerfile).

## Database (Optional)

Create a `.env.local` file with your `POSTGRES_URL` environment variable to store redirects.
Expand Down
6 changes: 4 additions & 2 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ const nextConfig: NextConfig = {
// the `experimental.mdxRs` flag.
experimental: {
mdxRs: true
}
},

output: 'standalone'
};

const withMDX = createMDX({});

export default withMDX(nextConfig);
export default withMDX(nextConfig);