feature/research-di #1
70
Dockerfile
Normal file
70
Dockerfile
Normal file
@ -0,0 +1,70 @@
|
||||
# syntax=docker.io/docker/dockerfile:1
|
||||
|
||||
FROM node:18-alpine AS base
|
||||
|
||||
# Install dependencies only when needed
|
||||
FROM base AS deps
|
||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||
elif [ -f package-lock.json ]; then npm ci; \
|
||||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Next.js collects completely anonymous telemetry data about general usage.
|
||||
# Learn more here: https://nextjs.org/telemetry
|
||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||
# ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn run build; \
|
||||
elif [ -f package-lock.json ]; then npm run build; \
|
||||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
# Uncomment the following line in case you want to disable telemetry during runtime.
|
||||
# ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Set the correct permission for prerender cache
|
||||
RUN mkdir .next
|
||||
RUN chown nextjs:nodejs .next
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
|
||||
# server.js is created by next build from the standalone output
|
||||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
CMD ["node", "server.js"]
|
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
restart: always
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_PASSWORD: example
|
||||
POSTGRES_USER: admin
|
||||
POSTGRES_DB: nextbp
|
||||
|
||||
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_PORT: 5432
|
||||
POSTGRES_USER: admin
|
||||
POSTGRES_PASS: example
|
||||
POSTGRES_DB: nextbp
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
@ -2,6 +2,7 @@ import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
5724
package-lock.json
generated
5724
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import BaseFailure from "@/feature/common/failures/base-failure";
|
||||
|
||||
/**
|
||||
@ -16,16 +17,19 @@ import BaseFailure from "@/feature/common/failures/base-failure";
|
||||
* )
|
||||
* ```
|
||||
* In this example `failureOr` will return already throwed
|
||||
* instance of `BaseFailure` which is `ValidationFailure`.
|
||||
* instance of `BaseFailure<any>` which is `ValidationFailure`.
|
||||
*
|
||||
*
|
||||
* @param reason is throwed object.
|
||||
* Basically it can be default `Error` or instance of `BaseFailure`.
|
||||
* @param failure instance of `BaseFailure` that will be returned
|
||||
* if reason is not instance of `BaseFailure`.
|
||||
* @returns `BaseFailure`
|
||||
* Basically it can be default `Error` or instance of `BaseFailure<any>`.
|
||||
* @param failure instance of `BaseFailure<any>` that will be returned
|
||||
* if reason is not instance of `BaseFailure<any>`.
|
||||
* @returns `BaseFailure<any>`
|
||||
*/
|
||||
export function failureOr(reason: unknown, failure: BaseFailure): BaseFailure {
|
||||
export function failureOr(
|
||||
reason: unknown,
|
||||
failure: BaseFailure<any>,
|
||||
): BaseFailure<any> {
|
||||
if (reason instanceof BaseFailure) {
|
||||
return reason;
|
||||
}
|
||||
@ -33,16 +37,16 @@ export function failureOr(reason: unknown, failure: BaseFailure): BaseFailure {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a function that maps a BaseFailure instance to a new BaseFailure instance of type IfType using the provided mapping function.
|
||||
* @param f A function that maps an instance of IfType to a new instance of BaseFailure.
|
||||
* Returns a function that maps a BaseFailure<any> instance to a new BaseFailure<any> instance of type IfType using the provided mapping function.
|
||||
* @param f A function that maps an instance of IfType to a new instance of BaseFailure<any>.
|
||||
* @param ctor A constructor function for IfType.
|
||||
* @returns A function that maps a BaseFailure instance to a new BaseFailure instance of type IfType.
|
||||
* @returns A function that maps a BaseFailure<any> instance to a new BaseFailure<any> instance of type IfType.
|
||||
*/
|
||||
export function mapToFailureFrom<IfType extends BaseFailure>(
|
||||
f: (t: IfType) => BaseFailure,
|
||||
export function mapToFailureFrom<IfType extends BaseFailure<any>>(
|
||||
f: (t: IfType) => BaseFailure<any>,
|
||||
ctor: new (...args: never[]) => IfType,
|
||||
): (t: BaseFailure) => BaseFailure {
|
||||
return mapIfInstance<IfType, BaseFailure>(f, ctor);
|
||||
): (t: BaseFailure<any>) => BaseFailure<any> {
|
||||
return mapIfInstance<IfType, BaseFailure<any>>(f, ctor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user