Update Dockerfile

This commit is contained in:
Lee 2022-11-14 03:31:42 +00:00
parent 27532f4d2e
commit 7c5f636e7c
No known key found for this signature in database
GPG Key ID: 6EA25896ECCB3121
6 changed files with 64 additions and 8341 deletions

@ -1,10 +1,57 @@
FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
# Install dependencies only when needed
FROM node:18.12-alpine 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* ./
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 . .
# 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
RUN chown -R node /usr/src/app
USER node
CMD ["npm", "start"]
ENV PORT 3000
CMD ["node", "server.js"]

@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
//output: "standalone",
output: "standalone",
swcMinify: true,
optimizeFonts: true,

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();
createUser("admin", pass).then((returned) => {
if (returned === true) {
console.log(
`Created admin account. Username: admin, Password: ${pass}, uploadKey: ${returned.uploadKey}`
);
console.log(`Created admin account. Username: admin, Password: ${pass}`);
}
});

@ -38,7 +38,13 @@ export default function File(props) {
contentType = contentType.toLowerCase();
if (contentType.includes("image")) {
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")) {
toShow = <video alt={fileId} src={fileUrl} controls></video>;

@ -33,7 +33,6 @@ export function createFileIO(dir, fileName, bytes) {
}
const fileLocation = dir + path.sep + fileName;
console.log(fileLocation);
fs.writeFile(
fileLocation,
bytes,