vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Cannot build with docker buildkit on arm64 #3716

Open polRk opened 1 month ago

polRk commented 1 month ago

Describe the bug

Infinite loading during docker build

#15 [build 6/6] RUN npm run build
#15 1.187 
#15 1.187 > pkg@0.0.0 build
#15 1.187 > vitepress build
#15 1.187 
#15 2.044 
#15 2.044   vitepress v1.0.1
#15 2.044 
#15 2.072 - building client + server bundles...

Reproduction

ARG NODE_IMAGE=node
ARG NODE_VERSION=20.11.1-alpine

ARG NGINX_IMAGE=nginx
ARG NGINX_VERSION=1.25.1-alpine

FROM $NODE_IMAGE:$NODE_VERSION as build
WORKDIR /app

COPY .npmrc package.json package-lock.json ./
RUN --mount=type=secret,id=TOKEN NPM_REGISTRY_TOKEN=$(cat /run/secrets/TOKEN) npm ci

COPY .vitepress content ./
RUN npm run build <<< **INFINITE PROGRESS**

FROM $NGINX_IMAGE:$NGINX_VERSION as final

# Настройка Nginx
RUN touch /var/run/nginx.pid \
    && chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid
COPY nginx.conf /etc/nginx/nginx.conf

COPY --from=build /app/.vitepress/dist/ /usr/share/nginx/html

USER nginx

EXPOSE 8080

ENTRYPOINT ["nginx", "-g", "daemon off;"]

Expected behavior

The build phase should be completed quickly

System Info

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M1
    Memory: 143.84 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.6.1 - /opt/homebrew/opt/node@20/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - /opt/homebrew/opt/node@20/bin/npm
    bun: 1.0.25 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 17.3.1

Additional context

No response

Validations

brc-dd commented 1 month ago

Install git or disable lastUpdated. alpine doesn't have that installed by default.

polRk commented 1 month ago

Install git or disable lastUpdated. alpine doesn't have that installed by default.

It solved problem with git ENOET, but But that's not the problem

polRk commented 1 month ago

@brc-dd Reopen please, you are wrong

polRk commented 1 month ago
image
brc-dd commented 1 month ago

Please share a minimal reproducible example.

polRk commented 1 month ago

@brc-dd github.com:polRk/vitpress-101-docker-bug.git

Run on Apple Silicon

polRk commented 1 month ago

I think the problem is that I am building an image for amd64 on arm64.

FROM --platform=linux/amd64. I need it line.

brc-dd commented 1 month ago

works fine on my mac:

 => [final 2/4] RUN touch /var/run/nginx.pid  && chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid                                                                                    0.1s
 => [final 3/4] COPY nginx.conf /etc/nginx/nginx.conf                                                                                                                                        0.0s
 => [build 5/6] COPY .vitepress content ./                                                                                                                                                   0.0s
 => [build 6/6] RUN npm run build                                                                                                                                                            4.6s
 => [final 4/4] COPY --from=build /app/.vitepress/dist/ /usr/share/nginx/html                                                                                                                0.0s

Preview kind of breaks but you'll need to adjust CSP headers added by nginx for that.