Reputation: 367
Pretty much the question. Here's what I have currently:
FROM node:15 as server
WORKDIR /app
ENV NODE_ENV=production
COPY server/package.json ./
RUN npm install
COPY server/ ./
RUN apt-get update
RUN apt-get install -y mongo-tools
EXPOSE 5000
CMD ["node", "src/app.js"]
Which does work however mongo-tools is a really outdated version of the tools and is not fit for my pusposes.
Mongo Docs has instructions for how to install the newer mongodb-database-tools on linux/windows/macos but I can't figure out how to get it to work in a DockerFile.
For anyone wondering, I'm trying to get a node-cron to periodically call mongodump on a mongodb atlas database.
Any help is appreciated :)
Upvotes: 4
Views: 7227
Reputation: 1392
For those using node:alpine
this is how I did it:
FROM node:18.17.1-alpine3.18
WORKDIR /usr/local/app
RUN apk --no-cache add mongodb-tools
...
Upvotes: 1
Reputation: 96
you can download newer version of the tools and install it, just like you do on linux host
example Dockerfile like below:
FROM node:15 as server
WORKDIR /app
ENV NODE_ENV=production
RUN wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian92-x86_64-100.3.1.deb && \
apt install ./mongodb-database-tools-*.deb && \
rm -f mongodb-database-tools-*.deb
COPY server/package.json ./
RUN npm install
COPY server/ ./
EXPOSE 5000
CMD ["node", "src/app.js"]
Upvotes: 8