Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile to newest guideline image. #80

Closed
wants to merge 1 commit into from

Conversation

WilmsJochen
Copy link
Contributor

@WilmsJochen WilmsJochen commented Oct 29, 2024


💡 Summary generated by FirstMate:

  • Updated base image in Dockerfile from node:19-alpine to node:20-alpine
  • Set environment variable PORT to 8080
  • Defined working directory as /usr/src/app

Copy link

firstmatebot bot commented Oct 29, 2024

PR Review

⚠️ It seems that you can still improve the quality of your PR. Have a look into this:

   

❌ Docker & helm guidelines: Use multi-stage builds in Dockerfile to enhance security and reduce image size.

These are the improvements you should make:

  • Dockerfile should use multi-stage builds: Consider using multi-stage builds to separate the build environment from the runtime environment, which can help reduce the final image size and improve security.

Dockerfile should use multi-stage builds

You are currently using a single-stage Dockerfile, which can lead to larger image sizes and potential security vulnerabilities. Implementing multi-stage builds will help separate the build environment from the runtime environment. Here's how you can refactor your Dockerfile:

# Build Stage
FROM node:20-alpine AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .

# Production Stage
FROM node:20-alpine
ENV PORT 8080
WORKDIR /usr/src/app
COPY --from=build /usr/src/app ./
RUN addgroup -S usergroup && adduser -S -D -h /usr/app/src appuser usergroup
RUN chown -R appuser:usergroup /usr/app
USER appuser

EXPOSE 8080
CMD ["npm", "start", "--no-update-notifier"]

To improve your PR. Please make changes to these files:

  • Dockerfile

Generated by Firstmate to make sure you can focus on coding new features.

Copy link

firstmatebot bot commented Oct 29, 2024

Some of the pipelines in this PR crashed. I did a quick analysis:

Failure Analysis

The pipeline crashed during the Docker build step due to the following error in the logs:

/bin/sh: apt-get: not found

This indicates that the apt-get command is not available in the Alpine-based Docker image (node:20-alpine). Alpine Linux uses apk for package management, not apt-get. The change in the PR that introduced apt-get update is the likely cause of the failure.

Suggested Fix

To resolve the issue, remove the line that attempts to use apt-get and ensure that all necessary packages are installed using apk. Update the Dockerfile as follows:

# Remove this line
# RUN apt-get update

# Ensure all necessary packages are installed with apk
RUN apk add --no-cache git

This change will allow the Docker build to proceed without errors.

@vincentdecl
Copy link
Contributor

@firstmade can you fix it for me?

@vincentdecl
Copy link
Contributor

@firstmate can you fix it?

@wvl94 wvl94 closed this Nov 5, 2024
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.

3 participants