Update Dockerfile
This commit is contained in:
parent
27532f4d2e
commit
7c5f636e7c
63
Dockerfile
63
Dockerfile
@ -1,10 +1,57 @@
|
|||||||
FROM node:lts-alpine
|
# Install dependencies only when needed
|
||||||
ENV NODE_ENV=production
|
FROM node:18.12-alpine AS deps
|
||||||
WORKDIR /usr/src/app
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN npm install --production --silent && mv node_modules ../
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 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 --frozen-lockfile; \
|
||||||
|
else echo "Lockfile not found." && exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Rebuild the source code only when needed
|
||||||
|
FROM node:18.12-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
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 yarn build
|
||||||
|
|
||||||
|
# If using npm comment out above and use below instead
|
||||||
|
# RUN npm run build
|
||||||
|
|
||||||
|
# Production image, copy all the files and run next
|
||||||
|
FROM node:18.12-alpine 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
|
||||||
|
|
||||||
|
# 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
|
EXPOSE 3000
|
||||||
RUN chown -R node /usr/src/app
|
|
||||||
USER node
|
ENV PORT 3000
|
||||||
CMD ["npm", "start"]
|
|
||||||
|
CMD ["node", "server.js"]
|
@ -1,7 +1,7 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
//output: "standalone",
|
output: "standalone",
|
||||||
swcMinify: true,
|
swcMinify: true,
|
||||||
optimizeFonts: true,
|
optimizeFonts: true,
|
||||||
|
|
||||||
|
8327
package-lock.json
generated
8327
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,9 +11,7 @@ import { createUser, getUser } from "../../../utils/helpers/userHelpers";
|
|||||||
const pass = generateRandomPassword();
|
const pass = generateRandomPassword();
|
||||||
createUser("admin", pass).then((returned) => {
|
createUser("admin", pass).then((returned) => {
|
||||||
if (returned === true) {
|
if (returned === true) {
|
||||||
console.log(
|
console.log(`Created admin account. Username: admin, Password: ${pass}`);
|
||||||
`Created admin account. Username: admin, Password: ${pass}, uploadKey: ${returned.uploadKey}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,7 +38,13 @@ export default function File(props) {
|
|||||||
contentType = contentType.toLowerCase();
|
contentType = contentType.toLowerCase();
|
||||||
if (contentType.includes("image")) {
|
if (contentType.includes("image")) {
|
||||||
toShow = (
|
toShow = (
|
||||||
<Image alt={fileId} src={fileUrl} width={width} height={height}></Image>
|
<Image
|
||||||
|
alt={fileId}
|
||||||
|
src={fileUrl}
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
unoptimized
|
||||||
|
></Image>
|
||||||
);
|
);
|
||||||
} else if (contentType.includes("video")) {
|
} else if (contentType.includes("video")) {
|
||||||
toShow = <video alt={fileId} src={fileUrl} controls></video>;
|
toShow = <video alt={fileId} src={fileUrl} controls></video>;
|
||||||
|
@ -33,7 +33,6 @@ export function createFileIO(dir, fileName, bytes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fileLocation = dir + path.sep + fileName;
|
const fileLocation = dir + path.sep + fileName;
|
||||||
console.log(fileLocation);
|
|
||||||
fs.writeFile(
|
fs.writeFile(
|
||||||
fileLocation,
|
fileLocation,
|
||||||
bytes,
|
bytes,
|
||||||
|
Reference in New Issue
Block a user