i am kind of new to docker and wanted to try it out to deploy my application. The application consists of database, frontend and backend, each in it’s own container.
Everything works fine, but i noticed when i run docker-compose up i will find this in the logs:
There is no offical build of MongoDB for Alpine!
Falling back to legacy MongoDB build!
Downloading MongoDB 4.0.14: 0 % (0mb / 81.3mb)
I am kind of confused on this message as i didn’t specify Alpine anywhere. Is it some kind of implicit default when using docker-compose? How could i avoid this warning and use an “better” image?
And the corresponding Dockerfile, which actually uses Alpine:
FROM node:lts-alpine
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
## Add the wait script to the image
ADD wait /wait
RUN chmod +x /wait
EXPOSE 3000
CMD /wait && node server.mjs
So it makes sense the warning is related to the dev-dependency.
What surprises me tho, that the devDependency is installed at all. In my docker-compose i specify
environment:
NODE_ENV: production
So the dev-dependencies shouldnt be installed at all. Am i doing something wrong about setting the environment variable?
The Dockerfile instructs Docker how to build the image.
Whatever inside docker-compose.yml (apart from build: section) doesn’t affect the image; instead, it instructs how to augment the container.
You ran npm install with Dockerfile, the environment variables set by docker-compose.yml aren’t gonna affect the npm install in any way.
To clarify the last bit of potential misunderstandings.
The wait command was executed inside the container so that it can receive the environment variable set by docker-compose.yml whilst your npm install was executed during image building (no container yet).