I recently switched my meteor app to use Docker as I am trying to create a new microservice. Previously, I would deploy my app locally using meteor run, but I've switched to docker-compose up --build
using a docker-compose.yml
at the root of my project and a Dockerfile
in my Meteor app's directory. I finally got things running, which is great, but I am now trying to build a dev version and I'm running into some trouble.
In my Dockerfile.dev
I am:
/src
directory for the containerpackage*.json
files to /src
npm install
/src
/src
meteor run
The dockerfile is running the app, but then my app exits because it cannot find meteor. Which is weird because shouldn't it have to find meteor to start the app in the first place? Anyways, I'm lost and any help would be greatly appreciated. Thanks in advance :)
docker-compose.yml
version: '3'
services:
myapp:
build:
context: ./js/myapp
dockerfile: Dockerfile.dev
ports:
- '3000:3000'
links:
- mongo
environment:
ROOT_URL: ${APP_ROOT_URL:-http://localhost}
MONGO_URL: mongodb://mongo:27017/meteor
PORT: 3000
mongo:
image: mongo:latest
command:
- --storageEngine=wiredTiger
volumes:
- data:/data/db
volumes:
data:
Dockerfile.dev
# Inspired by: https://github.com/banjerluke/meteor-dockerfile
FROM node:14.17.5 as builder
ENV METEOR_VERSION=2.3.4 \
APP_SRC_FOLDER=.
RUN mkdir -p /opt/src
RUN echo "\n[*] Installing Meteor ${METEOR_VERSION} to ${HOME}"\
&& curl -s https://install.meteor.com/?release=${METEOR_VERSION} | sed s/--progress-bar/-sL/g | sh
FROM node:14.17.5-alpine as runner
ENV NODE_ENV=dev
COPY $APP_SRC_FOLDER/package*.json /opt/src/
RUN echo '\n[*] Installing Meteor server NPM dependencies' \
&& cd /opt/src \
&& npm install
COPY $APP_SRC_FOLDER /opt/src/
WORKDIR /opt/src/
CMD ["meteor", "run"]
Error
myapp_1 | internal/modules/cjs/loader.js:892
myapp_1 | throw err;
myapp_1 | ^
myapp_1 |
myapp_1 | Error: Cannot find module '/opt/src/meteor'
myapp_1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
myapp_1 | at Function.Module._load (internal/modules/cjs/loader.js:745:27)
myapp_1 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
myapp_1 | at internal/main/run_main_module.js:17:47 {
myapp_1 | code: 'MODULE_NOT_FOUND',
myapp_1 | requireStack: []
myapp_1 | }
myapp_myapp_1 exited with code 1
I think the issue was with FROM node:14.17.5-alpine as runner
for some reason, this image was causing issues with the launch. Removing it was the key culprit! I got the app successfully running!
The app does launch more slowly than meteor run
but for now I will take it :)