Difficulty with Docker-compose when packaging Meteor application (npm issues)

Looking for assistance with a persistent npm error while attempting to bundle my Meteor app using docker-compose. Despite all files being clearly visible in the app directory, including package.json, I am encountering many errors during the final build step called by my Dockerfile within the docker-compose.yml file.

Below is the content of my Dockerfile along with the encountered errors:


FROM ubuntu:trusty

# Install NodeJS from Node-Source repo (node 0.10.48).
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs

# Add your app on /Home and install NPM modules. And clean the cache.
RUN mkdir /home/app
COPY app.tar.gz /tmp/app.tar.gz
RUN tar -zxf /tmp/app.tar.gz -C /home/app
RUN apt-get install -y python
RUN cd /home/app/bundle/programs/server

RUN apt-get update
RUN npm install
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Expose port 80, but remember to use PORT=80
EXPOSE 80

# Run the app
WORKDIR /home/app
CMD ["node", "main.js"]

npm ERR! install Couldn't read dependencies
npm ERR! Linux 4.10.0-32-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v0.10.48
npm ERR! npm  v2.15.1
npm ERR! path /package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34

npm ERR! package.json ENOENT, open '/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
ERROR: Service 'app' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 34

Answer №1

Instead of installing node directly in your Dockerfile, consider using a Node docker image as the base image. Check out this Node docker image here

After selecting a Node base image, you can install any additional dependencies you need like python. Utilize the WORKDIR docker directive to set the working directory and then copy your files into it.

FROM node:wheezy

RUN mkdir /home/app

WORKDIR /home/app

COPY app.tar.gz .
RUN tar -zxf app.tar.gz && npm install && apt-get update && apt-get install -y python && cd bundle/programs/server && rm -rf /var/lib/apt/lists/* 

# Expose port 80, but remember to use PORT=80
EXPOSE 80

# Run the app
CMD ["node", "main.js"]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting up a plan for executing Javascript server side scripts

Can JavaScript be executed server-side? If I attempt to access a script , can it be scheduled to run every four hours? Would most web hosts allow this, or is it considered poor webmaster practice? The main goal is to activate my website's webcrawler/ ...

Issue: unable to establish a connection to 127.0.0.1:465 to send an email

When attempting to send smtp alert messages from my site's email account <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="55363a3b2134362115383a3b263c21307b363">[email protected]</a> to the email addresses of m ...

Dealing with Mongoose document version Error: Strategies for resolving version conflicts

While trying to update a document, I encountered an error. The issue arises when continuously receiving data from a socket and attempting to update the same document. Even though the recent data has not been updated yet, new data is being emitted on the so ...

Generating a JSON file using JavaScript amidst the presence of unconventional characters in JSON keys

In my Node Red Function Node, I'm currently facing a challenge of generating a JSON file from JavaScript code. The specific format I need for the JSON file is as follows: [ { "H-Nr.":"1", "Pos.-Nr.":"1" }, { "H-Nr.":"1", ...

Is it feasible to combine CoffeeScript, Node.js, MongoDB, and JasperReports?

Recently, I came across a JSF (web JavaScript application) that interacts with a MongoDB database and creates a report in PDF format using the JasperReports Library through a .java file. I am curious if it is feasible to achieve similar functionality with ...

The Python program continues running after it's created

Executing the all.py program: import subprocess import os scripts_to_run = ['AppFlatForRent.py','AppForSale.py','CommercialForSale.py','LandForSale.py','MultipleUnitsForSale.py','RentalWanted.py&apos ...

Having difficulty accessing the API response accurately

The response from my API is as follows: {"__v":0,"short":"8xdn4a5k","_id":"5404db5ac27408f20440babd","branches":[{"version":1,"code":""}],"ext":"js","language":"javascript"} When I use this code, it works perfectly: console.log(response.short); However ...

accessing past sign-ins with passport.js and express-sessions

I need some assistance with displaying a user's login history on the front-end of my webpage. I am using Express and storing sessions in mongoStore as shown below: app.use(session({ secret: process.env.SECRET, key: process.env.KEY, resave: fals ...

What could be causing the <img src= ' '/> tag to malfunction in Express?

While learning about HTML, I noticed that simply using img src="...." worked fine. However, when working with Express, the same code did not work! The documentation mentioned that I needed to place the images in a folder named public, require(&ap ...

The StreamingTextResponse feature is malfunctioning in the live environment

When I share my code, it's an API route in Next.js. In development mode, everything works as expected. However, in production, the response appears to be static instead of dynamic. It seems like only one part of the data is being sent. I'm puzzl ...

Retrieving the result of a callback function within a nested function

I'm struggling with a function that needs to return a value. The value is located inside a callback function within the downloadOrders function. The problem I'm encountering is that "go" (logged in the post request) appears before "close" (logged ...

Neo4j encounters an error of trying to access properties of an undefined object when the 'get' method is invoked for the second time during the graph update process

In my server setup, I utilize both MongoDB and Neo4j databases. Whenever I update a product record in MongoDB, I also ensure that the corresponding product node and relationship to a category node are updated in Neo4j. To maintain consistency across both d ...

Implement Next.js deployment on NGINX server with a 403 forbidden error

I am currently utilizing Next.js for the frontend and Django for the backend. During development, everything is functioning properly. However, when transitioning to production, I am encountering a 403 Forbidden Error related to /_next/static/chunks. It app ...

Optimal approach for handling user authorizations in a REST API with JWT implementation (Node.js + mongoose)

I am still getting the hang of working with mongoose and mongoDB, and I'm wondering what is the most effective method to prevent users from altering other users' information once they have logged in. Currently, my authentication system uses JWT, ...

The bamboo construction falters as webpack is unable to locate the node_modules

After setting up my Angular project with webpack in version 1.7, everything runs smoothly locally when I execute the npm run build task to launch webpack. However, I encountered an issue when trying to set up a plan for continuous integration using bamboo ...

What sets apart a string constant from a string enclosed in quotation marks? And what techniques exist to transform one into the other?

Calling an asynchronous function: const variable = 'something' await MyAsyncFunction.execute(variable) No output is displayed. But if I change it to: await MyAsyncFunction.execute('something') It works!! Can someone please explain h ...

There seems to be an inconvenience with my npm proxy

Encountering issues with proxy services during the installation of packages is frustrating. An error message like this may appear: C:\Users\ihab\Desktop\myApp\myApp>npm install -g npm@latest npm ERR! code ENOTFOUND npm ERR! errno ...

The error message "Unable to access characteristics of the object (specifically, the 'transformFile' property) due to it being undefined

After updating my node today, I encountered the following error: error: TypeError: Cannot read properties of undefined (reading 'transformFile') at Bundler.transformFile (/Users/.../node_modules/metro/src/Bundler.js:48:30) at runMicrotask ...

Creating unique message formats for communication between a python client and a socket.io node.js server

Currently, I am attempting to establish communication between a Python client and a Node.js server using Socket.io 0.7. My goal is to send a custom event from the client to the server. To achieve this, I have been referencing the Socket.io documentation o ...

How to configure setup for running ES6 tests with Mocha 6 and Babel 7?

Looking to compile a library written in ES6/7 to ES5 and store it in a dist/ folder. Additionally, I need to run tests for this library. The development dependencies listed in my package.json file are as follows: "devDependencies": { "@babel/cli": "^7. ...