diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 97379020e..e405a0094 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: [siumauricio] patreon: # open_collective: dokploy ko_fi: # Replace with a single Ko-fi username diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 278059732..30e43be3d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,17 +1,16 @@ name: Pull request + on: pull_request: branches: - main - canary - push: - branches: - - main - - canary +env: + HUSKY: 0 + jobs: build-app: - if: github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: matrix: @@ -19,11 +18,11 @@ jobs: steps: - name: Check out the code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup pnpm uses: pnpm/action-setup@v4 - with: - version: 8 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 @@ -34,6 +33,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: Run commitlint + run: pnpm commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose + - name: Run format and lint run: pnpm biome ci @@ -45,28 +47,3 @@ jobs: - name: Run Tests run: pnpm run test - - build-and-push-docker-on-push: - if: github.event_name == 'push' - runs-on: ubuntu-latest - steps: - - name: Check out the code - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Prepare .env file - run: | - cp .env.production.example .env.production - - - name: Build and push Docker image using custom script - run: | - chmod +x ./docker/push.sh - ./docker/push.sh ${{ github.ref_name == 'canary' && 'canary' || '' }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 000000000..1534e6d28 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,35 @@ +name: Push + +on: + push: + branches: + - main + - canary + +env: + HUSKY: 0 + +jobs: + build-and-push-docker-on-push: + runs-on: ubuntu-latest + steps: + - name: Check out the code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Prepare .env file + run: | + cp .env.production.example .env.production + + - name: Build and push Docker image using custom script + run: | + chmod +x ./docker/push.sh + ./docker/push.sh ${{ github.ref_name == 'canary' && 'canary' || '' }} diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 000000000..cfe751017 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +pnpm commitlint --edit $1 diff --git a/.husky/install.mjs b/.husky/install.mjs new file mode 100644 index 000000000..9b13ce1f9 --- /dev/null +++ b/.husky/install.mjs @@ -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()); diff --git a/Dockerfile b/Dockerfile index 6d3e58758..8075325cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,48 +1,65 @@ -# Etapa 1: Prepare image for building FROM node:18-slim AS base -# Install dependencies +# Disable husky +ENV HUSKY=0 + +# Set pnpm home ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable && apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/* +# Enable corepack +RUN corepack enable + +# Set workdir WORKDIR /app +FROM base AS base-deps +# Install dependencies only for production +RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/* + +# Copy install script for husky +COPY .husky/install.mjs ./.husky/install.mjs + # Copy package.json and pnpm-lock.yaml COPY package.json pnpm-lock.yaml ./ +FROM base-deps AS prod-deps + +# Set production +ENV NODE_ENV=production + +# Install dependencies only for production +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile + +FROM base-deps AS build + # Install dependencies only for building RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile # Copy the rest of the source code COPY . . -# Build the application -RUN pnpm run build +# Build the application +RUN pnpm build -# Stage 2: Prepare image for production -FROM node:18-slim AS production +FROM base AS production + +# Set production +ENV NODE_ENV=production # Install dependencies only for production -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable && apt-get update && apt-get install -y curl && apt-get install -y apache2-utils && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y curl apache2-utils && rm -rf /var/lib/apt/lists/* -WORKDIR /app - -# Copy the rest of the source code -COPY --from=base /app/.next ./.next -COPY --from=base /app/dist ./dist -COPY --from=base /app/next.config.mjs ./next.config.mjs -COPY --from=base /app/public ./public -COPY --from=base /app/package.json ./package.json -COPY --from=base /app/drizzle ./drizzle -COPY --from=base /app/.env.production ./.env -COPY --from=base /app/components.json ./components.json - -# Install dependencies only for production -COPY package.json pnpm-lock.yaml ./ -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile +# Copy the rest of the source code +COPY --from=build /app/.next ./.next +COPY --from=build /app/dist ./dist +COPY --from=build /app/next.config.mjs ./next.config.mjs +COPY --from=build /app/public ./public +COPY --from=build /app/package.json ./package.json +COPY --from=build /app/drizzle ./drizzle +COPY --from=build /app/.env.production ./.env +COPY --from=build /app/components.json ./components.json +COPY --from=prod-deps /app/node_modules ./node_modules # Install docker RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh && rm get-docker.sh @@ -54,11 +71,10 @@ RUN curl -sSL https://nixpacks.com/install.sh -o install.sh \ && ./install.sh \ && pnpm install -g tsx - # Install buildpacks RUN curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.32.1/pack-v0.32.1-linux.tgz" | tar -C /usr/local/bin/ --no-same-owner -xzv pack # Expose port EXPOSE 3000 -CMD ["pnpm", "start"] \ No newline at end of file +CMD ["pnpm", "start"] diff --git a/components/shared/toggle-visibility-input.tsx b/components/shared/toggle-visibility-input.tsx index aef09880e..bb11eeaef 100644 --- a/components/shared/toggle-visibility-input.tsx +++ b/components/shared/toggle-visibility-input.tsx @@ -1,10 +1,13 @@ -import { EyeIcon, EyeOffIcon } from "lucide-react"; -import { useState } from "react"; +import copy from "copy-to-clipboard"; +import { Clipboard, EyeIcon, EyeOffIcon } from "lucide-react"; +import { useRef, useState } from "react"; +import { toast } from "sonner"; import { Button } from "../ui/button"; import { Input, type InputProps } from "../ui/input"; export const ToggleVisibilityInput = ({ ...props }: InputProps) => { const [isPasswordVisible, setIsPasswordVisible] = useState(false); + const inputRef = useRef(null); const togglePasswordVisibility = () => { setIsPasswordVisible((prevVisibility) => !prevVisibility); @@ -13,7 +16,16 @@ export const ToggleVisibilityInput = ({ ...props }: InputProps) => { const inputType = isPasswordVisible ? "text" : "password"; return (
- + +