main-site/Dockerfile

48 lines
1.1 KiB
Docker
Raw Normal View History

2023-12-20 07:19:28 +00:00
## INIT STEP
# 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 ./
2023-12-20 08:54:19 +00:00
RUN yarn add sharp
RUN yarn install --frozen-lockfile
2023-12-20 07:19:28 +00:00
## BUILD STEP
# Rebuild the source code only when needed
FROM node:18-alpine AS builder
WORKDIR /app
# Copy node_modules installed by the deps step
COPY --from=deps /app/node_modules ./node_modules
COPY . .
2023-12-20 09:25:46 +00:00
RUN touch private/portainer_api_secret.json
RUN echo '{"token": ""}' > /app/private/portainer_api_secret.json
2023-12-20 07:19:28 +00:00
RUN yarn build
## RUN STEP
FROM node:18-alpine AS runner
2023-12-20 08:34:23 +00:00
LABEL author="neshura@neshweb.net"
2023-12-20 07:19:28 +00:00
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
# 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" ]