From ae714729bdcf005c242bcea1599d2616dce40599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o?= <43091603+glazk0@users.noreply.github.com> Date: Wed, 19 Jul 2023 12:32:39 +0200 Subject: [PATCH] chore: Dockerfile & other shits --- .dockerignore | 6 +- .vscode/settings.json | 4 - Dockerfile | 62 +- app/(auth)/sign-up/page.tsx | 1 - app/dashboard/badges/page.tsx | 10 +- app/dashboard/page.tsx | 13 +- app/dashboard/puzzles/[id]/page.tsx | 8 +- app/dashboard/settings/page.tsx | 41 +- {styles => app}/global.css | 0 app/layout.tsx | 16 +- app/page.tsx | 58 - components/ui/Card.tsx | 14 +- components/ui/Dialog.tsx | 2 +- components/ui/Icon.tsx | 2 +- components/ui/Icons.tsx | 16 + components/ui/Label.tsx | 29 +- components/ui/Leaderboard.tsx | 14 +- components/ui/Puzzle.tsx | 124 +- components/ui/Puzzles.tsx | 17 +- components/ui/Separator.tsx | 26 + components/ui/UserAuthForm.tsx | 6 +- components/ui/dashboard/Sidenav.tsx | 17 +- components/ui/dashboard/Usernav.tsx | 20 +- context/user.tsx | 15 +- lib/hooks/use-toast.ts | 187 --- lib/nav-items.ts | 15 +- next.config.js | 83 +- package.json | 74 +- pnpm-lock.yaml | 1707 ++++++++++++++------------- 29 files changed, 1243 insertions(+), 1344 deletions(-) delete mode 100644 .vscode/settings.json rename {styles => app}/global.css (100%) delete mode 100644 app/page.tsx create mode 100644 components/ui/Icons.tsx create mode 100644 components/ui/Separator.tsx delete mode 100644 lib/hooks/use-toast.ts diff --git a/.dockerignore b/.dockerignore index bc9eb56..d32019a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,7 @@ -.git Dockerfile +.dockerignore node_modules +npm-debug.log *.md -.env.* \ No newline at end of file +.next +.git \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 239dab8..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "typescript.tsdk": "node_modules\\.pnpm\\typescript@4.9.5\\node_modules\\typescript\\lib", - "typescript.enablePromptUseWorkspaceTsdk": true -} diff --git a/Dockerfile b/Dockerfile index f677b34..2fccfab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,47 +1,43 @@ -FROM node:16-alpine AS builder +FROM mitchpash/pnpm AS deps RUN apk add --no-cache libc6-compat WORKDIR /app -COPY package.json . -COPY pnpm-lock.yaml . +COPY pnpm-lock.yaml /app -RUN npm install -g pnpm && \ - pnpm install sharp && \ - pnpm install +RUN pnpm fetch + +FROM mitchpash/pnpm AS builder + +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN npm run build +RUN pnpm install -r --offline -ENV NODE_ENV=production +RUN pnpm build + +FROM mitchpash/pnpm AS runner + +WORKDIR /app + +ENV NODE_ENV production + +COPY --from=builder /app/next.config.js ./ +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +# Some things are not allowed (see https://github.com/vercel/next.js/issues/38119#issuecomment-1172099259) +COPY --from=builder --chown=node:node /app/.next/standalone ./ +COPY --from=builder --chown=node:node /app/.next/static ./.next/static EXPOSE 3000 -ENV PORT 3000 +ENV HOST=localhost PORT=3000 NODE_ENV=production -CMD ["pnpm", "start"] - -# FROM node:16-alpine AS builder - -# RUN apk add --no-cache libc6-compat - -# WORKDIR /app - -# COPY package.json . -# COPY pnpm-lock.yaml . - -# ENV NODE_ENV=production \ -# PORT=3000 - -# RUN npm install -g pnpm && \ -# pnpm install - -# COPY . . - -# RUN npm build - -# EXPOSE 3000 - -# CMD ["pnpm", "start"] \ No newline at end of file +CMD ["node", "server.js"] \ No newline at end of file diff --git a/app/(auth)/sign-up/page.tsx b/app/(auth)/sign-up/page.tsx index dc31442..4fe95fd 100644 --- a/app/(auth)/sign-up/page.tsx +++ b/app/(auth)/sign-up/page.tsx @@ -1,5 +1,4 @@ import UserAuthForm from '@/components/ui/UserAuthForm'; -import Link from 'next/link'; export default function Page() { return ( diff --git a/app/dashboard/badges/page.tsx b/app/dashboard/badges/page.tsx index 07431fd..7b64bdc 100644 --- a/app/dashboard/badges/page.tsx +++ b/app/dashboard/badges/page.tsx @@ -1,13 +1,12 @@ 'use client'; -import { useContext } from 'react'; - -import { UserContext } from '@/context/user'; +import { useUser } from '@/context/user'; import Badge from '@/components/ui/Badge'; +import { Separator } from '@/components/ui/Separator'; export default function Page() { - const { data: me } = useContext(UserContext); + const { data: me, isLoading } = useUser(); return (
@@ -16,9 +15,10 @@ export default function Page() { Vos badges sont affichés ici, vous pouvez les partager avec vos amis

+
- {me?.badges ? ( + {!isLoading && me?.badges ? ( me?.badges.map((badge, i) => (
@@ -17,21 +18,21 @@ export default function Page() {
{ const { id } = params; const token = cookies().get('token')?.value; diff --git a/app/dashboard/settings/page.tsx b/app/dashboard/settings/page.tsx index 49bb930..322f377 100644 --- a/app/dashboard/settings/page.tsx +++ b/app/dashboard/settings/page.tsx @@ -1,8 +1,10 @@ 'use client'; +import { zodResolver } from '@hookform/resolvers/zod'; import cookies from 'js-cookie'; +import { Loader2 } from 'lucide-react'; import { useRouter } from 'next/navigation'; -import { useContext, useState } from 'react'; +import { useState } from 'react'; import { useForm } from 'react-hook-form'; import { useSWRConfig } from 'swr'; import { z } from 'zod'; @@ -17,10 +19,10 @@ import { FormMessage } from '@/components/ui/Form'; import { Input } from '@/components/ui/Input'; -import { UserContext } from '@/context/user'; + +import { useUser } from '@/context/user'; import { type Player } from '@/lib/players'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { Loader2 } from 'lucide-react'; +import { Separator } from '@/components/ui/Separator'; type SettingsData = { name: string; @@ -29,16 +31,9 @@ type SettingsData = { }; export default function Page() { - const { data: me } = useContext(UserContext); + const { data: me, isLoading } = useUser(); const { mutate } = useSWRConfig(); const router = useRouter(); - const { register, handleSubmit } = useForm({ - defaultValues: { - name: '', - chapter: undefined, - puzzle: undefined - } - }); const groups = (me?.groups && @@ -79,16 +74,24 @@ export default function Page() { C'est ici que vous pouvez modifier votre profil.

+
- {me && } - {/* {me && me?.groups?.length > 0 ? ( -
+ {!isLoading && } + {/*