Merge pull request #226 from kdurek/fix/husky-on-prod

fix: disable husky only on production
This commit is contained in:
Mauricio Siu
2024-07-17 11:52:04 -06:00
committed by GitHub
4 changed files with 24 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ on:
branches: branches:
- main - main
- canary - canary
env:
HUSKY: 0
jobs: jobs:
build-app: build-app:
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'

6
.husky/install.mjs Normal file
View File

@@ -0,0 +1,6 @@
// Skip Husky install in production and CI
if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
process.exit(0);
}
const husky = (await import("husky")).default;
console.log(husky());

View File

@@ -8,6 +8,10 @@ RUN corepack enable && apt-get update && apt-get install -y python3 make g++ git
WORKDIR /app WORKDIR /app
# Disable husky
ENV HUSKY=0
COPY .husky/install.mjs ./.husky/install.mjs
# Copy package.json and pnpm-lock.yaml # Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
@@ -23,6 +27,9 @@ RUN pnpm run build
# Stage 2: Prepare image for production # Stage 2: Prepare image for production
FROM node:18-slim AS production FROM node:18-slim AS production
# Disable husky
ENV HUSKY=0
# Install dependencies only for production # Install dependencies only for production
ENV PNPM_HOME="/pnpm" ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH" ENV PATH="$PNPM_HOME:$PATH"
@@ -30,6 +37,12 @@ RUN corepack enable && apt-get update && apt-get install -y curl && apt-get inst
WORKDIR /app WORKDIR /app
ENV NODE_ENV production
# Disable husky
ENV HUSKY=0
COPY --from=base /app/.husky/install.mjs ./.husky/install.mjs
# Copy the rest of the source code # Copy the rest of the source code
COPY --from=base /app/.next ./.next COPY --from=base /app/.next ./.next
COPY --from=base /app/dist ./dist COPY --from=base /app/dist ./dist

View File

@@ -31,7 +31,8 @@
"docker:build:canary": "./docker/build.sh canary", "docker:build:canary": "./docker/build.sh canary",
"docker:push:canary": "./docker/push.sh canary", "docker:push:canary": "./docker/push.sh canary",
"version": "echo $(node -p \"require('./package.json').version\")", "version": "echo $(node -p \"require('./package.json').version\")",
"test": "vitest --config __test__/vitest.config.ts" "test": "vitest --config __test__/vitest.config.ts",
"prepare": "node .husky/install.mjs"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "3.515.0", "@aws-sdk/client-s3": "3.515.0",