fp/d.strapi.dockerfile

57 lines
1.6 KiB
Plaintext
Raw Normal View History

FROM node:20 AS base
2024-07-14 05:20:35 +00:00
## Installing libvips-dev for sharp Compatibility
## (only needed on alpine)
2024-07-04 21:20:29 +00:00
# RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git
2024-07-14 05:20:35 +00:00
RUN corepack enable && corepack prepare pnpm@9.5.0 --activate
2024-07-04 21:20:29 +00:00
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
EXPOSE 1339
ENTRYPOINT ["pnpm"]
2024-07-04 21:20:29 +00:00
FROM base AS build
2024-07-14 05:20:35 +00:00
WORKDIR /app
RUN mkdir -p /prod/strapi
2024-07-14 05:20:35 +00:00
COPY pnpm-workspace.yaml pnpm-lock.yaml .npmrc package.json .
COPY ./packages/types ./packages/types
COPY ./packages/strapi ./packages/strapi
RUN pnpm fetch
2024-07-14 05:20:35 +00:00
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install -g node-gyp --prefer-offline
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --recursive --prefer-offline
RUN pnpm -r build
RUN pnpm deploy --filter=strapi /prod/strapi
2024-07-14 05:20:35 +00:00
RUN ls -lah ./
RUN ls -lah ./packages
RUN ls -lah ./packages/strapi
RUN ls -lah /prod/strapi
2024-07-14 05:20:35 +00:00
# FROM base AS build
# RUN mkdir -p /prod/strapi
# WORKDIR /opt/
# COPY ./packages/strapi/package.json ./packages/strapi/pnpm-lock.yaml ./
# RUN pnpm fetch
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install -g node-gyp
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# ENV PATH /opt/node_modules/.bin:$PATH
# WORKDIR /opt/app
# COPY ./packages/strapi/. .
# RUN pnpm -r build
# RUN pnpm deploy --filter=strapi /prod/strapi
2024-07-14 05:20:35 +00:00
FROM base AS dev
COPY --from=build /prod/strapi .
CMD ["run", "develop"]
FROM base AS strapi
2024-07-12 15:24:30 +00:00
WORKDIR /opt/app
2024-07-04 21:20:29 +00:00
RUN chown -R node:node /opt/app
USER node
COPY --from=build /prod/strapi .
RUN ls -la .
ENTRYPOINT ["pnpm", "start"]