Fix Dockerfile
This commit is contained in:
parent
74ab3328d2
commit
b2afbe35ec
1 changed files with 8 additions and 37 deletions
45
Dockerfile
45
Dockerfile
|
@ -1,48 +1,19 @@
|
||||||
## INIT STEP
|
FROM node:20 as build
|
||||||
# Install dependencies only when needed
|
|
||||||
FROM node:18-alpine AS deps
|
|
||||||
|
|
||||||
RUN apk add --no-cache libc6-compat
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the files needed to install deps
|
|
||||||
COPY package.json yarn.lock ./
|
|
||||||
RUN yarn add sharp
|
|
||||||
RUN yarn install --frozen-lockfile
|
|
||||||
|
|
||||||
## BUILD STEP
|
|
||||||
# Rebuild the source code only when needed
|
|
||||||
FROM node:18-alpine AS builder
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy node_modules installed by the deps step
|
COPY . ./
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
RUN yarn install
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN mkdir /app/private
|
|
||||||
RUN echo '{"token": ""}' > /app/private/portainer_api_secret.json
|
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
## RUN STEP
|
|
||||||
FROM node:18-alpine AS runner
|
|
||||||
|
|
||||||
LABEL author="neshura@neshweb.net"
|
FROM node:20-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY --from=build /app .
|
||||||
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|
||||||
COPY --from=builder /app/public ./public
|
EXPOSE 8000
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
CMD ["yarn", "preview"]
|
||||||
|
|
||||||
# Automatically leverage output traces to reduce image size
|
|
||||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
|
||||||
COPY --from=builder /app/.next/standalone ./
|
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
|
||||||
|
|
||||||
# expose port 3000
|
|
||||||
ENV PORT 3000
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
CMD [ "yarn", "start" ]
|
|
Loading…
Reference in a new issue