Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Nafeij committed Oct 29, 2023
1 parent d0c91d6 commit c95ca8f
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 16 deletions.
11 changes: 8 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/node_modules
/.next
/npm-debug.log
.env
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
66 changes: 66 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Dockerfile

##### DEPENDENCIES

FROM node:18-alpine AS deps
RUN apk add --no-cache libc6-compat openssl1.1-compat
WORKDIR /app

# Install Prisma Client - remove if not using Prisma
COPY prisma ./prisma

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./

RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi

##### BUILDER

FROM node:18-alpine AS builder

# ARG DATABASE_URL

ARG NEXTAUTH_URL
ARG NEXT_PUBLIC_WS_PORT

WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN \
if [ -f yarn.lock ]; then SKIP_ENV_VALIDATION=1 yarn build; \
elif [ -f package-lock.json ]; then SKIP_ENV_VALIDATION=1 npm run build; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && SKIP_ENV_VALIDATION=1 pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

##### RUNNER

FROM node:18-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json

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

CMD ["node", "server.js"]
13 changes: 13 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ const config = {
locales: ["en"],
defaultLocale: "en",
},
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
output: "standalone",
};

export default config;
1 change: 1 addition & 0 deletions prisma/mongodb/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
generator client {
provider = "prisma-client-js"
output = "../../node_modules/@prisma-db-mongo/client"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}

datasource db {
Expand Down
1 change: 1 addition & 0 deletions prisma/postgres/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
generator client {
provider = "prisma-client-js"
output = "../../node_modules/@prisma-db-psql/client"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}

datasource db {
Expand Down
26 changes: 13 additions & 13 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export const env = createEnv({
* isn't built with invalid env vars.
*/
server: {
POSTGRES_USER: z.string().min(1),
POSTGRES_PASSWORD: z.string().min(1),
POSTGRES_URL: z.string().url(),
MONGO_USER: z.string().min(1),
MONGO_PASSWORD: z.string().min(1),
MONGO_URL: z.string().url(),
// POSTGRES_USER: z.string().min(1),
// POSTGRES_PASSWORD: z.string().min(1),
// POSTGRES_URL: z.string().url(),
// MONGO_USER: z.string().min(1),
// MONGO_PASSWORD: z.string().min(1),
// MONGO_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
NEXTAUTH_SECRET:
process.env.NODE_ENV === "production"
Expand Down Expand Up @@ -46,14 +46,14 @@ export const env = createEnv({
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
POSTGRES_USER: process.env.POSTGRES_USER,
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
POSTGRES_URL: process.env.POSTGRES_URL,
MONGO_USER: process.env.MONGO_USER,
MONGO_PASSWORD: process.env.MONGO_PASSWORD,
MONGO_URL: process.env.MONGO_URL,
// POSTGRES_USER: process.env.POSTGRES_USER,
// POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
// POSTGRES_URL: process.env.POSTGRES_URL,
// MONGO_USER: process.env.MONGO_USER,
// MONGO_PASSWORD: process.env.MONGO_PASSWORD,
// MONGO_URL: process.env.MONGO_URL,
NODE_ENV: process.env.NODE_ENV,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_SECRET: process.env.NEXT_AUTH_SECRET,
NEXT_PUBLIC_WS_PORT: process.env.NODE_ENV === "production" ? process.env.NEXT_PUBLIC_WS_PORT : "3002",
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
S3_BUCKET_NAME: process.env.S3_BUCKET_NAME,
Expand Down

0 comments on commit c95ca8f

Please sign in to comment.