Skip to content

@nx/docker Dockerfile Example #33261

@marc-wilson

Description

@marc-wilson

Documentation issue

  • Reporting a typo
  • Reporting a documentation bug
  • Documentation improvement
  • Documentation feedback

Is there a specific documentation page you are reporting?

https://nx.dev/docs/technologies/build-tools/docker/introduction

Additional context or description

Prior to @nx/docker, we would run nx g @nx/node:setup-docker and it would generate a Dockerfile like this:

FROM docker.io/node:lts-alpine

ENV HOST=0.0.0.0
ENV PORT=80
EXPOSE 80

WORKDIR /app

RUN addgroup --system addresses-api && \
          adduser --system -G addresses-api addresses-api

COPY dist addresses-api/
RUN chown -R addresses-api:addresses-api .

RUN npm --prefix addresses-api --omit=dev -f install

CMD [ "node", "addresses-api" ]

This still works but with the new typescript workspaces, and even moreso, pnpm repo's, it would be preferred to not have to run npm install or pnpm install again. nx build has already ran and nx build wouldn't have worked unless you did npm install or pnpm install

What's the Nx recommended structure for "todays" Dockerfile? It would be great to provide examples for both pnpm and npm and others.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions