diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..557fbcc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,54 @@ +# Dependencies +node_modules +.pnp +.pnp.js +.yarn/install-state.gz + +# Testing +coverage +.nyc_output + +# Next.js +.next +out + +# Production +build +dist + +# Misc +.DS_Store +*.pem +.git +.gitignore + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Local env files +.env +.env.* +.env.local +.env.development +.env.test +.env.production + +# IDE +.idea +.vscode +*.swp +*.swo + +# Project specific +README.md +dev/ +public/uploads +Dockerfile +.dockerignore +docker-compose*.yml + +# Cache +.eslintcache +*.tsbuildinfo \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4809da9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# modified from https://github.com/leerob/next-self-host + +FROM node:alpine AS base + +# Stage 1: Install dependencies +FROM base AS deps +WORKDIR /app +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +# Stage 2: Build the application +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN yarn run build + +# Stage 3: Production server +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +EXPOSE 3000 +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index 34865e0..e58d27a 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -12,10 +12,12 @@ const nextConfig = { images: { remotePatterns: [ { - hostname: process.env.MINIO_ENDPOINT, + protocol: "https", + hostname: "**", }, ], }, + output: 'standalone', }; export default nextConfig; diff --git a/src/lib/services/minio.ts b/src/lib/services/minio.ts index ea4192a..e33654d 100644 --- a/src/lib/services/minio.ts +++ b/src/lib/services/minio.ts @@ -1,7 +1,7 @@ import * as Minio from 'minio' const minio = new Minio.Client({ - endPoint: process.env.MINIO_ENDPOINT!, + endPoint: process.env.MINIO_ENDPOINT || 'play.min.io', port: parseInt(process.env.MINIO_PORT || '9000'), useSSL: process.env.MINIO_USE_SSL === 'true', accessKey: process.env.MINIO_ACCESS_KEY!,