Skip to content

Commit

Permalink
build: update Dockerfiles
Browse files Browse the repository at this point in the history
- bump node to 22
- use nginx as static http server

Signed-off-by: Guillaume Bonnet <[email protected]>
  • Loading branch information
MrSquaare committed Nov 30, 2024
1 parent 5359733 commit 7f972fb
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 143 deletions.
31 changes: 9 additions & 22 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,29 @@
FROM node:20-alpine AS base
FROM node:22-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV APP_DIRECTORY="/usr/src/app"

ENV PATH="${PATH}:${PNPM_HOME}"
ENV PATH="${PATH}:${APP_DIRECTORY}/node_modules/.bin/"
ENV PATH="${PATH}:${APP_DIRECTORY}/docs/node_modules/.bin/"
ENV TURBO_TELEMETRY_DISABLED="1"
ENV ASTRO_TELEMETRY_DISABLED="1"

RUN corepack enable pnpm

WORKDIR ${APP_DIRECTORY}
WORKDIR "/usr/src/app"

COPY ./package.json ./pnpm-lock.yaml ./pnpm-workspace.yaml ./
RUN corepack enable pnpm
COPY ./docs/package.json ./docs/

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile


FROM base AS build

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

COPY ./turbo.json ./turbo.json
COPY ./docs ./docs
RUN pnpm build


FROM base

COPY --from=build ${APP_DIRECTORY}/docs/dist/ ./docs/dist/

ENV NODE_ENV="production"

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

RUN apk add --no-cache dumb-init

EXPOSE 4321
FROM nginx:stable-alpine AS production

ENTRYPOINT ["dumb-init", "--"]
COPY --from=build /usr/src/app/docs/dist/ /usr/share/nginx/html

CMD ["pnpm", "-F", "@sandwich-ui/docs", "preview", "--host"]
EXPOSE 80
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "@sandwich-ui/root",
"scripts": {
"dev": "turbo dev",
"build": "turbo build --continue",
"build": "turbo build",
"preview": "turbo preview",
"lint": "turbo lint --continue",
"lint:fix": "turbo lint:fix --continue",
Expand Down
34 changes: 12 additions & 22 deletions packages/react-storybook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
FROM node:20-alpine AS base
FROM node:22-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV APP_DIRECTORY="/usr/src/app"

ENV PATH="${PATH}:${PNPM_HOME}"
ENV PATH="${PATH}:${APP_DIRECTORY}/node_modules/.bin/"
ENV PATH="${PATH}:${APP_DIRECTORY}/storybook/node_modules/.bin/"
ENV TURBO_TELEMETRY_DISABLED="1"
ENV STORYBOOK_DISABLE_TELEMETRY="1"

RUN corepack enable pnpm

WORKDIR ${APP_DIRECTORY}
WORKDIR "/usr/src/app"

COPY ./package.json ./pnpm-lock.yaml ./pnpm-workspace.yaml ./
RUN corepack enable pnpm
COPY ./packages/core/package.json ./packages/core/
COPY ./packages/react/package.json ./packages/react/
COPY ./packages/react-storybook/package.json ./packages/react-storybook/

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile


FROM base AS build

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

COPY ./turbo.json ./turbo.json
COPY ./packages/core ./packages/core
COPY ./packages/react ./packages/react
COPY ./packages/react-storybook ./packages/react-storybook
RUN pnpm build


FROM base

COPY --from=build ${APP_DIRECTORY}/packages/react-storybook/storybook-static/ ./packages/react-storybook/storybook-static/

ENV NODE_ENV="production"

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

RUN apk add --no-cache dumb-init

EXPOSE 4173
FROM nginx:stable-alpine AS production

ENTRYPOINT ["dumb-init", "--"]
COPY --from=build /usr/src/app/packages/react-storybook/storybook-static/ /usr/share/nginx/html

CMD ["pnpm", "-F", "@sandwich-ui/react-storybook", "preview", "--host"]
EXPOSE 80
Loading

0 comments on commit 7f972fb

Please sign in to comment.