backend docker refactor and frontend cleanup
This commit is contained in:
parent
96443b6afe
commit
63e33a45b4
14 changed files with 130 additions and 113 deletions
|
|
@ -1,15 +1,27 @@
|
|||
FROM node:22-slim
|
||||
FROM node:22-slim AS base
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
COPY package*.json tsconfig*.json prisma.config.ts ./
|
||||
COPY prisma ./prisma
|
||||
COPY src ./src
|
||||
|
||||
RUN apt-get update -y && apt-get install -y openssl
|
||||
RUN npm install --omit=dev
|
||||
RUN npm run prisma:generate
|
||||
|
||||
RUN if [ "$NODE_ENV" = "dev" ]; then npm install; else npm install --omit=dev; fi
|
||||
FROM base AS builder
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
|
||||
FROM base
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
# COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY prisma.config.ts /app/
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD npm run $NODE_ENV
|
||||
CMD ["npm", "run", "prod"]
|
||||
|
|
|
|||
13
backend/Dockerfile.dev
Normal file
13
backend/Dockerfile.dev
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
FROM node:22-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN apt-get update -y && apt-get install -y openssl
|
||||
|
||||
RUN npm install
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "run", "dev"]
|
||||
|
|
@ -4,8 +4,9 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon ./src/index.ts",
|
||||
"production": "npx tsc && node ./dist/index.js",
|
||||
"ci": "tsc"
|
||||
"build": "tsc",
|
||||
"prisma:generate": "prisma generate",
|
||||
"prod": "node ./dist/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ export const getRecipeById = async (
|
|||
};
|
||||
|
||||
export const addRecipe = async (req: Request, res: Response): Promise<void> => {
|
||||
if (process.env.NODE_ENV === "demo") {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log(req.body);
|
||||
const createdRecipe = await model.addRecipe(req.body);
|
||||
|
|
@ -73,9 +70,6 @@ export const updateRecipe = async (
|
|||
): Promise<void> => {
|
||||
console.log(req.body);
|
||||
const id = parseInt(req.params.id, 10);
|
||||
if (process.env.NODE_ENV === "demo") {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const updatedRecipe = await model.updateRecipe(req.body, id);
|
||||
res.status(201).json(updatedRecipe);
|
||||
|
|
@ -89,9 +83,6 @@ export const updateRecipe = async (
|
|||
};
|
||||
|
||||
export const setStars = async (req: Request, res: Response): Promise<void> => {
|
||||
if (process.env.NODE_ENV === "demo") {
|
||||
return;
|
||||
}
|
||||
const id = parseInt(req.body.id, 10);
|
||||
const stars = parseInt(req.body.stars, 10);
|
||||
try {
|
||||
|
|
@ -110,9 +101,6 @@ export const deleteRecipe = async (
|
|||
req: Request,
|
||||
res: Response,
|
||||
): Promise<void> => {
|
||||
if (process.env.NODE_ENV === "demo") {
|
||||
return;
|
||||
}
|
||||
const id = parseInt(req.body.id, 10);
|
||||
try {
|
||||
await model.deleteRecipe(id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue