31 lines
850 B
Docker
31 lines
850 B
Docker
# Creating multi-stage build for production
|
|
FROM node:18-alpine as build
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1
|
|
ENV NODE_ENV=production
|
|
WORKDIR /opt/
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --prod
|
|
ENV PATH /opt/node_modules/.bin:$PATH
|
|
WORKDIR /opt/app
|
|
COPY . .
|
|
RUN pnpm run build
|
|
|
|
# Creating final production image
|
|
FROM node:18-alpine
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
RUN apk add --no-cache vips-dev
|
|
ENV NODE_ENV=production
|
|
WORKDIR /opt/
|
|
COPY --from=build /opt/node_modules ./node_modules
|
|
WORKDIR /opt/app
|
|
COPY --from=build /opt/app ./
|
|
ENV PATH /opt/node_modules/.bin:$PATH
|
|
RUN chown -R node:node /opt/app
|
|
USER node
|
|
EXPOSE 1337
|
|
CMD ["pnpm", "start"] |