Comments (10)
RUN export METEOR_SETTINGS="$(cat $APP_BUNDLE_FOLDER/bundle/settings.json)"
This was not working for me. π
I found a solution on https://medium.com/p/4bccb26f6ff0/responses/show
in package.json:
"scripts": { "start": "METEOR_SETTINGS=$(cat settings.json) node main.js" }
and in the Dockerfile (after copying package.json and settings.json to $APP_BUNDLE_FOLDER/bundle/):
CMD ["npm", "start"]
π
from meteor-base.
So npm start
or npm start <some command>
tell npm
to spawn the command in a new process. So I would assume that npm
remains process 1, and the spawned process is a different process ID; but Docker is capturing the logs only from process 1, and therefore you see no logs from your app. Hence CMD
should really be the actual node
process that the app runs under and generates logs from, or a shell script that runs node
via the exec
command (and therefore the new node
process takes over PID 1).
The entrypoint.sh
in the latest build already has a hook for you to insert custom code. See https://github.com/disney/meteor-base/blob/master/src/docker/entrypoint.sh and the reference to startup.sh
. You could implement this by creating a startup.sh
that includes
export METEOR_SETTINGS=$(cat settings.json)
and in your Dockerfile add
COPY startup.sh /
from meteor-base.
Yes. As noted in the README, youβre meant to copy the example Dockerfile from this repo into your project. You can then edit it however you need, such as to add support for --settings
.
Per the docs at https://guide.meteor.com/deployment.html#environment you can pass the settings.json
file to production Meteor by setting the stringified JSON as the METEOR_SETTINGS
environment variable. So in the example Dockerfile, you could add a line like this just above the ENTRYPOINT
line:
RUN export METEOR_SETTINGS="$(cat $APP_BUNDLE_FOLDER/bundle/settings.json)"
from meteor-base.
Thanks!
I was already using your docker file, I did not know where to import the settings file.
I got it working now, thanks again.
Wilco
from meteor-base.
@clemenspeters would you mind to share your Dockerfile?
from meteor-base.
I was able to run my application using the @clemenspeters workaround (thanks!). However, I see that the console log gets stuck when running the npm run customCommand
. Actually I thought it wasn't working and I spent hours trying to find the "error" but when I went to http://localhost:80 it turns out that it was up and running.
Connecting to MongoDB...
(node:6) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Starting app...
> [email protected] productionDocker /opt/bundle/bundle
> METEOR_SETTINGS=$(cat settingspdn.json) node main.js
I changed the CMD
command for this: CMD npm run ${START_COMMAND}
@GeoffreyBooth any ideas what it could be? it doesn't log anything
from meteor-base.
@GeoffreyBooth That's quite helpful, I'm gonna try it, thanks a lot!
from meteor-base.
@GeoffreyBooth I tried it but didn't work. I copied the startup.sh
into $SCRIPTS_FOLDER
but it didn't execute it. So I inspected the container and I spotted that the entrypoint.sh
is not the same as this one: https://github.com/disney/meteor-base/blob/master/src/docker/entrypoint.sh. This is the one that my container is using:
#!/bin/bash
set -o errexit
cd $SCRIPTS_FOLDER
# Poll until we can successfully connect to MongoDB
echo 'Connecting to MongoDB...'
node <<- 'EOJS'
const mongoClient = require('mongodb').MongoClient;
setInterval(function() {
mongoClient.connect(process.env.MONGO_URL, function(err, client) {
if (client) {
client.close();
}
if (err) {
console.error(err);
} else {
process.exit(0);
}
});
}, 1000);
EOJS
echo 'Starting app...'
cd $APP_BUNDLE_FOLDER/bundle
exec "$@"
So; I think I'm using the wrong base image, not sure, this is what I have:
FROM geoffreybooth/meteor-base:1.8.1
because I need the 1.8.1 meteor version
from meteor-base.
Ok, I made a custom entrypoint
script which basically does the same as the original + set the settings according to the environment variable.
from meteor-base.
Ok, I made a custom
entrypoint
script
Glad you figured it out. This is general Docker stuff, not specific to Meteor or this image. Look up "override Docker entrypoint" and you'll find lots of articles on best practices on how to do so.
from meteor-base.
Related Issues (20)
- Need help with `canvas` pls HOT 2
- New CVE-2022-0778 HOT 2
- Include 2.5.7-beta.0 HOT 1
- '/root/.meteor' exists, but '/root/.meteor/meteor' is not executable. HOT 32
- Proxy Configuration HOT 1
- Add better minification and obfuscation HOT 1
- Error with Vite bundler for Meteor + Vue 3 app HOT 5
- Missing 2.8.1 tag on docker hub HOT 1
- Missing 2.9.0 & 2.9.1 tags on Docker hub HOT 1
- No ark available HOT 1
- TypeError in docker HOT 1
- Error: Could not get https://warehouse.meteor.com HOT 2
- Add ssh to base image to install dependencies directly from Git/Github HOT 1
- app not available at localhost HOT 1
- Missing 2.8.2 tag on docker hub HOT 1
- build-meteor-bundle.sh error HOT 2
- No version needed in `docker-compose.yml` and updates to reflect latest changes in the docker ecosystem HOT 1
- update.sh adds duplicated lines to support.sh HOT 1
- Missing 2.15 tag on Docker hub HOT 2
- Development version? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-base.