-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 🔧 Migrate to use pnpm (#288)
* refactor: 🔧 Migrate to use pnpm * chore: 💚 Use pnpm instead of npx * chore: ♻️ Update dockerfile to use pnpm, run actions on push * chore: 💚 Update Docker image build
- Loading branch information
Showing
11 changed files
with
3,679 additions
and
5,591 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 |
---|---|---|
@@ -1,26 +1,21 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use the latest stable Node.js | ||
uses: actions/setup-node@v4 | ||
- uses: pnpm/action-setup@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'node' | ||
cache: 'npm' | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
run: pnpm install | ||
|
||
- name: Run Build | ||
run: npm run build | ||
run: pnpm run build |
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,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit "$1" | ||
pnpm --no-install commitlint --edit "$1" |
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,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged | ||
pnpm lint-staged |
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,4 +1 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run build | ||
pnpm build |
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,34 +1,51 @@ | ||
# Stage 1: Building the app | ||
# Build stage | ||
FROM node:20-alpine AS builder | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
# Set the working directory in the Docker container | ||
WORKDIR /app | ||
|
||
# Copy the package.json and package-lock.json (or yarn.lock) files | ||
COPY package*.json ./ | ||
# Copy package.json and pnpm-lock.yaml | ||
COPY package.json pnpm-lock.yaml* ./ | ||
|
||
# Install dependencies | ||
RUN npm ci | ||
# Install dependencies (including devDependencies) | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
|
||
# Copy the rest of your app's source code from your host to your image filesystem. | ||
# Copy all files | ||
COPY . . | ||
|
||
# Build the Next.js application | ||
RUN npm run build | ||
# Build the application | ||
RUN pnpm run build | ||
|
||
# Stage 3: Run the app in production mode | ||
# Production stage | ||
FROM node:20-alpine AS runner | ||
WORKDIR /app | ||
|
||
# Copy the build output from the builder stage | ||
ENV NODE_ENV=production | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
# Copy necessary files from the builder stage | ||
COPY --from=builder /app/next.config.mjs ./ | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/.next/standalone ./ | ||
COPY --from=builder /app/.next/static ./.next/static | ||
|
||
# Set correct permissions for the .next directory | ||
RUN chown nextjs:nodejs .next | ||
|
||
# Switch to nextjs user | ||
USER nextjs | ||
|
||
# Create cache directory with correct permissions | ||
RUN mkdir -p .next/cache | ||
|
||
# Expose the port Next.js runs on | ||
EXPOSE 3000 | ||
|
||
# Command to run the app | ||
CMD ["npm", "start"] | ||
ENV PORT=3000 | ||
ENV HOSTNAME="0.0.0.0" | ||
|
||
CMD ["node", "server.js"] |
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
Oops, something went wrong.