replace bun with pnpm and added dockerfile for web
This commit is contained in:
47
apps/web/Dockerfile
Normal file
47
apps/web/Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
||||
FROM node:20-slim AS base
|
||||
|
||||
ARG DATABASE_URL
|
||||
ENV DATABASE_URL=$DATABASE_URL
|
||||
|
||||
ARG NEXTAUTH_SECRET
|
||||
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
|
||||
|
||||
ARG NEXTAUTH_URL
|
||||
ENV NEXTAUTH_URL=$NEXTAUTH_URL
|
||||
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
ARG NODE_VERSION=18
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y curl \
|
||||
&& curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
|
||||
&& bash n $NODE_VERSION \
|
||||
&& rm n \
|
||||
&& npm install -g n
|
||||
|
||||
FROM base AS build
|
||||
COPY . /app
|
||||
WORKDIR /app/apps/web
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --ignore-scripts
|
||||
RUN pnpm dlx prisma generate
|
||||
RUN pnpm run build
|
||||
|
||||
FROM base AS prod
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod --ignore-scripts
|
||||
|
||||
FROM base AS runner
|
||||
COPY --from=build /app/package.json /app/package.json
|
||||
COPY --from=prod /app/node_modules /app/node_modules
|
||||
COPY --from=build /app/apps/web /app/apps/web
|
||||
COPY --from=prod /app/apps/web/node_modules /app/apps/web/node_modules
|
||||
WORKDIR /app/apps/web
|
||||
RUN pnpm dlx prisma generate
|
||||
EXPOSE 3000
|
||||
CMD [ "pnpm", "start" ]
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "web",
|
||||
"name": "@mixan/web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
@@ -41,7 +41,7 @@
|
||||
"cmdk": "^0.2.0",
|
||||
"lucide-react": "^0.286.0",
|
||||
"mitt": "^3.0.1",
|
||||
"next": "^13.5.4",
|
||||
"next": "13.4",
|
||||
"next-auth": "^4.23.0",
|
||||
"ramda": "^0.29.1",
|
||||
"random-animal-name": "^0.1.1",
|
||||
@@ -81,6 +81,5 @@
|
||||
},
|
||||
"ct3aMetadata": {
|
||||
"initVersion": "7.21.0"
|
||||
},
|
||||
"packageManager": "npm@9.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
import { validateSdkRequest } from '@/server/auth'
|
||||
import { db } from '@/server/db'
|
||||
import { createError, handleError } from '@/server/exceptions'
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import randomAnimalName from 'random-animal-name'
|
||||
|
||||
import { validateSdkRequest } from "@/server/auth";
|
||||
import { db } from "@/server/db";
|
||||
import { createError, handleError } from "@/server/exceptions";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import randomAnimalName from "random-animal-name";
|
||||
|
||||
interface Request extends NextApiRequest {
|
||||
body: {
|
||||
id: string
|
||||
properties?: Record<string, any>
|
||||
}
|
||||
id?: string;
|
||||
properties?: Record<string, any>;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
req: Request,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
if(req.method !== 'POST') {
|
||||
return handleError(res, createError(405, 'Method not allowed'))
|
||||
export default async function handler(req: Request, res: NextApiResponse) {
|
||||
if (req.method !== "POST") {
|
||||
return handleError(res, createError(405, "Method not allowed"));
|
||||
}
|
||||
|
||||
try {
|
||||
// Check client id & secret
|
||||
const projectId = await validateSdkRequest(req)
|
||||
const projectId = await validateSdkRequest(req);
|
||||
|
||||
const { id, properties } = req.body
|
||||
await db.profile.create({
|
||||
const { id, properties } = req.body ?? {};
|
||||
const profile = await db.profile.create({
|
||||
data: {
|
||||
id,
|
||||
external_id: null,
|
||||
@@ -37,10 +34,10 @@ export default async function handler(
|
||||
},
|
||||
project_id: projectId,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
res.status(200).end()
|
||||
res.status(200).json({ id: profile.id });
|
||||
} catch (error) {
|
||||
handleError(res, error)
|
||||
handleError(res, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user