Skip to content

chore(docker): configure docker build and deployment#24

Open
francescopausellii wants to merge 3 commits intomainfrom
feat/docker
Open

chore(docker): configure docker build and deployment#24
francescopausellii wants to merge 3 commits intomainfrom
feat/docker

Conversation

@francescopausellii
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Docker support for the Next.js application using a multi-stage build and a distroless runtime image. Feedback focuses on ensuring the Dockerfile aligns with the project's Next.js configuration for standalone output, addressing a security risk associated with unverified remote script execution during the build process, and improving image portability by removing hardcoded runtime environment variables.

HOSTNAME=0.0.0.0

# Copy optimized build output
COPY --from=builder --chown=nonroot:nonroot /app/.next/standalone ./
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This COPY command will fail because the .next/standalone directory is only generated when output: 'standalone' is set in next.config.ts. The current project configuration does not include this setting. To fix this, you need to update your next.config.ts to enable standalone output.

Comment on lines +11 to +13
RUN npm run build && \
curl -sf https://gobinaries.com/tj/node-prune | sh && \
node-prune .next/standalone/node_modules
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Piping curl to sh from a URL is a security risk as it executes remote code without verification. For improved security and reproducibility, it's better to download a specific, versioned release of node-prune from its official GitHub repository.

RUN npm run build && \
    (curl -sfL https://github.com/tj/node-prune/releases/download/v1.7.0/node-prune_1.7.0_linux_amd64.tar.gz | tar -xz -C /usr/local/bin) && \
    node-prune .next/standalone/node_modules

Comment on lines +20 to +22
ENV NODE_ENV=production \
PORT=3000 \
HOSTNAME=0.0.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding runtime configuration like PORT and HOSTNAME in the Docker image reduces its portability. It's better to configure these via environment variables at runtime (which you are already doing in docker-compose.yml). I suggest removing them from the Dockerfile and only keeping NODE_ENV=production.

ENV NODE_ENV=production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant