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

TypeError: Cannot read property 'reduce' of null #156

Open
AmauryOrtega opened this issue Aug 26, 2020 · 7 comments
Open

TypeError: Cannot read property 'reduce' of null #156

AmauryOrtega opened this issue Aug 26, 2020 · 7 comments

Comments

@AmauryOrtega
Copy link

When using this Dockerfile with the latest dockerfilelint docker image, an internal error shows up. I checked using /bin/sh to make sure the Dockerfile is accessible, I tried moving the Dockerfile to the working directory of /dockerfilelint/ and using the binary inside /dockerfilelint/bin/ but I got the same error message.

Dockerfile

FROM node:12-alpine as dependencies

# Source directory
WORKDIR /usr/src/app/
RUN chown -R node:node .
USER node

# Dependencies
COPY --chown=node:node package*.json ./
RUN npm ci

# Source code and build configuration
COPY --chown=node:node angular.json tsconfig*.json ./
COPY --chown=node:node ngsw-config.json .
COPY --chown=node:node src/ src/

# Compilation
FROM dependencies as build
RUN npx ng build --prod

FROM nginx:stable-alpine
# hadolint ignore=DL3018
RUN apk --no-cache add curl \
   && rm -rf /var/cache/apk/*
HEALTHCHECK CMD curl -f http://localhost/ || exit 1

COPY --chown=nginx:nginx --from=build /usr/src/app/dist/bouwmapp-frontend/ /usr/share/nginx/app/
COPY --chown=nginx:nginx nginx/app.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

Command

docker run --rm -v "$PWD"/Dockerfile:/Dockerfile:ro replicated/dockerfilelint:latest /Dockerfile

Output

/dockerfilelint/lib/checks.js:194
      if (!options.reduce((valid, item) => valid &&
                   ^
TypeError: Cannot read property 'reduce' of null
    at Object.is_valid_healthcheck (/dockerfilelint/lib/checks.js:194:20)
    at runLine (/dockerfilelint/lib/index.js:287:16)
    at Object.module.exports.run (/dockerfilelint/lib/index.js:63:18)
    at processContent (/dockerfilelint/bin/dockerfilelint:92:50)
    at argv._.forEach (/dockerfilelint/bin/dockerfilelint:86:3)
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/dockerfilelint/bin/dockerfilelint:65:8)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
@a16bitsysop
Copy link

I think I am getting the same error, have you tried deleting healthcheck and see if error stops

@AmauryOrtega
Copy link
Author

@a16bitsysop To give more details, when I originally created this issue, the latest docker image I was using had this image ID ea3ff6887d47.

Using the same image ID and the same Dockerfile without the healthcheck produces this output:

File:   /Dockerfile
Issues: None found 👍

I see that there is a new latest docker image with image ID 24b7b3aae3ac. I've tried both scenarios (with and without healthcheck) but the behavior is the same when the healthcheck is there but the call stack is just slightly different:

/dockerfilelint/lib/checks.js:194
      if (!options.reduce((valid, item) => valid &&
                   ^

TypeError: Cannot read property 'reduce' of null
    at Object.is_valid_healthcheck (/dockerfilelint/lib/checks.js:194:20)
    at runLine (/dockerfilelint/lib/index.js:287:16)
    at Object.module.exports.run (/dockerfilelint/lib/index.js:63:18)
    at processContent (/dockerfilelint/bin/dockerfilelint:92:50)
    at /dockerfilelint/bin/dockerfilelint:86:3
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/dockerfilelint/bin/dockerfilelint:65:8)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)

I'm willing to continue testing new versions so let me know if I can assist in anyway

@a16bitsysop
Copy link

@AmauryOrtega I am not a developer, I am a user as well. I am trying to find out what is causing it also.

@a16bitsysop
Copy link

@AmauryOrtega if you add an option like:
HEALTHCHECK --start-period=60s CMD curl -f http://localhost/ || exit 1
It should work, it has to have an option before the command and has to end in || exit 1

lvjp added a commit to lvjp/dockerfilelint that referenced this issue Jul 29, 2021
@lvjp
Copy link

lvjp commented Jul 29, 2021

I made a simple fix to this null pointer...

@AmauryOrtega
Copy link
Author

Thanks @lvjp 🎉

@marccampbell Is the fix acceptable?

@szaimen
Copy link

szaimen commented Jun 3, 2023

I am having the same issue... #184 looks good to me as a fix...

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

No branches or pull requests

4 participants