Update Dockerfile
Browse files- Dockerfile +11 -59
Dockerfile
CHANGED
@@ -1,69 +1,21 @@
|
|
1 |
-
#
|
|
|
2 |
|
3 |
-
#
|
4 |
-
# For more information, see https://nextjs.org/docs/pages/building-your-application/deploying#docker-image
|
5 |
-
|
6 |
-
FROM node:18 AS base
|
7 |
-
|
8 |
-
# Install dependencies only when needed
|
9 |
-
FROM base AS deps
|
10 |
WORKDIR /app
|
11 |
|
12 |
-
# Install dependencies
|
13 |
-
COPY
|
14 |
-
RUN
|
15 |
-
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
16 |
-
elif [ -f package-lock.json ]; then npm ci; \
|
17 |
-
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
|
18 |
-
else echo "Lockfile not found." && exit 1; \
|
19 |
-
fi
|
20 |
-
|
21 |
-
|
22 |
-
# Rebuild the source code only when needed
|
23 |
-
FROM base AS builder
|
24 |
-
WORKDIR /app
|
25 |
-
COPY --from=deps --link /app/node_modules ./node_modules
|
26 |
-
COPY --link . .
|
27 |
|
28 |
-
#
|
29 |
-
|
30 |
-
# Uncomment the following line in case you want to disable telemetry during the build.
|
31 |
-
# ENV NEXT_TELEMETRY_DISABLED 1
|
32 |
|
|
|
33 |
RUN npm run build
|
34 |
|
35 |
-
#
|
36 |
-
# RUN yarn build
|
37 |
-
|
38 |
-
# Production image, copy all the files and run next
|
39 |
-
FROM base AS runner
|
40 |
-
WORKDIR /app
|
41 |
-
|
42 |
-
ENV NODE_ENV production
|
43 |
-
# Uncomment the following line in case you want to disable telemetry during runtime.
|
44 |
-
# ENV NEXT_TELEMETRY_DISABLED 1
|
45 |
-
|
46 |
-
RUN \
|
47 |
-
addgroup --system --gid 1001 nodejs; \
|
48 |
-
adduser --system --uid 1001 nextjs
|
49 |
-
|
50 |
-
COPY --from=builder --link /app/public ./public
|
51 |
-
|
52 |
-
# Automatically leverage output traces to reduce image size
|
53 |
-
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
54 |
-
COPY --from=builder --link --chown=1001:1001 /app/.next/standalone ./
|
55 |
-
COPY --from=builder --link --chown=1001:1001 /app/.next/static ./.next/static
|
56 |
-
|
57 |
-
USER nextjs
|
58 |
-
|
59 |
EXPOSE 3000
|
60 |
|
61 |
-
|
62 |
-
ENV HOSTNAME 0.0.0.0
|
63 |
-
|
64 |
-
# Allow the running process to write model files to the cache folder.
|
65 |
-
# NOTE: In practice, you would probably want to pre-download the model files to avoid having to download them on-the-fly.
|
66 |
-
RUN mkdir -p /app/node_modules/@xenova/.cache/
|
67 |
-
RUN chmod 777 -R /app/node_modules/@xenova/
|
68 |
-
|
69 |
CMD ["npm", "start"]
|
|
|
1 |
+
# Use Node.js image
|
2 |
+
FROM node:18-alpine
|
3 |
|
4 |
+
# Create app directory
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Install app dependencies
|
8 |
+
COPY package*.json ./
|
9 |
+
RUN npm install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
# Bundle app source
|
12 |
+
COPY . .
|
|
|
|
|
13 |
|
14 |
+
# Build the app
|
15 |
RUN npm run build
|
16 |
|
17 |
+
# Expose port
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
EXPOSE 3000
|
19 |
|
20 |
+
# Start the app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
CMD ["npm", "start"]
|