-
Notifications
You must be signed in to change notification settings - Fork 64
Fix pnpm + docker #1385
Fix pnpm + docker #1385
Changes from 5 commits
f8359cb
e673080
9b1ee5f
59442d0
8d06968
ccf8bc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.32.11 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,101 +1,33 @@ | ||||||
# == | ||||||
# builder | ||||||
# == | ||||||
FROM node:16-alpine | ||||||
|
||||||
# application builder | ||||||
FROM node:16 AS builder | ||||||
ARG PNPM_VERSION | ||||||
|
||||||
WORKDIR /usr/app | ||||||
RUN npm install -g pnpm@${PNPM_VERSION} | ||||||
|
||||||
ARG API_URL | ||||||
USER node | ||||||
|
||||||
# Install pnpm | ||||||
RUN npm install -g pnpm | ||||||
WORKDIR /home/node/app | ||||||
|
||||||
# copy package.json and package-lock.json files | ||||||
COPY package.json . | ||||||
COPY pnpm-lock.yaml . | ||||||
COPY .npmrc . | ||||||
krysal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
# install dependencies including local development tools | ||||||
RUN pnpm install --store=pnpm-store | ||||||
RUN pnpm fetch | ||||||
|
||||||
# copy the rest of the content | ||||||
COPY . /usr/app | ||||||
|
||||||
# disable telemetry when building the app | ||||||
ENV NUXT_TELEMETRY_DISABLED=1 | ||||||
|
||||||
# build the application and generate a distribution package | ||||||
RUN pnpm build | ||||||
|
||||||
# == | ||||||
# development | ||||||
# == | ||||||
# application for development purposes | ||||||
FROM node:16 AS dev | ||||||
COPY --chmod=777 . /home/node/app | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does BuildKit conflict with using a non-root user? Do you mean non-root user in the image or running rootless docker? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant the option to change permissions with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like chmod can be replaced with chown without requiring BuildKit. |
||||||
|
||||||
WORKDIR /usr/app | ||||||
|
||||||
# Install pnpm | ||||||
RUN npm install -g pnpm | ||||||
|
||||||
ENV NODE_ENV=development | ||||||
ENV CYPRESS_INSTALL_BINARY=0 | ||||||
|
||||||
# copy files from local machine | ||||||
COPY . /usr/app | ||||||
|
||||||
COPY --from=builder /usr/app/pnpm-store /usr/app/pnpm-store | ||||||
RUN pnpm install -r --offline | ||||||
krysal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
# disable telemetry when building the app | ||||||
ENV NUXT_TELEMETRY_DISABLED=1 | ||||||
|
||||||
# install dependencies (development dependencies included) | ||||||
RUN pnpm install --store=pnpm-store | ||||||
|
||||||
# expose port 8443 | ||||||
EXPOSE 8443 | ||||||
|
||||||
# run the application in development mode | ||||||
ENTRYPOINT [ "pnpm", "run", "dev" ] | ||||||
|
||||||
# == | ||||||
# production | ||||||
# == | ||||||
# application package (for production) | ||||||
FROM node:16-alpine AS app | ||||||
|
||||||
WORKDIR /usr/app | ||||||
|
||||||
# Install pnpm | ||||||
RUN npm install -g pnpm | ||||||
|
||||||
ENV NODE_ENV=production | ||||||
ENV PLAYWRIGHT_SKIP_BROWSER_GC=1 | ||||||
|
||||||
# copy package.json and package-lock.json files | ||||||
COPY package.json . | ||||||
COPY pnpm-lock.yaml . | ||||||
COPY .npmrc . | ||||||
|
||||||
# copy the nuxt configuration file | ||||||
COPY --from=builder /usr/app/nuxt.config.ts . | ||||||
|
||||||
# copy distribution directory with the static content | ||||||
COPY --from=builder /usr/app/.nuxt /usr/app/.nuxt | ||||||
|
||||||
# copy publically-accessible static assets | ||||||
COPY --from=builder /usr/app/src/static /usr/app/src/static | ||||||
|
||||||
# Copy over files needed by Nuxt's runtime process | ||||||
COPY --from=builder /usr/app/src/locales /usr/app/src/locales | ||||||
COPY --from=builder /usr/app/src/utils /usr/app/src/utils | ||||||
COPY --from=builder /usr/app/src/constants /usr/app/src/constants | ||||||
COPY --from=builder /usr/app/src/server-middleware /usr/app/src/server-middleware | ||||||
COPY --from=builder /usr/app/pnpm-store /usr/app/pnpm-store | ||||||
ARG API_URL | ||||||
|
||||||
RUN pnpm install --frozen-lockfile --store=pnpm-store | ||||||
RUN pnpm i18n | ||||||
# build the application and generate a distribution package | ||||||
RUN pnpm build:only | ||||||
|
||||||
# set app serving to permissive / assigned | ||||||
ENV NUXT_HOST=0.0.0.0 | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
ARG PLAYWRIGHT_VERSION | ||
ARG PNPM_VERSION | ||
|
||
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-focal | ||
|
||
RUN npm install -g pnpm | ||
RUN npm install -g pnpm@${PNPM_VERSION} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the user here it fails in my case due to "EACCES: permission denied". We can move this sentence just before the
ENTRYPOINT
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move it before the entrypoint without
chmod
ing the copied files, how would thenode
user have access to the files copied into its home directory?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't it have access to its own directory? I tried these changes and the app runs normally as far as I've seen. Otherwise, I think it needs to be pointed out in the Docker section of the README that BuildKit is required, it did not work for me as it is currently.