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 && } + {/*