From 0bdfc7bd56f8b2576e64b70228906d83104fa6a9 Mon Sep 17 00:00:00 2001 From: jdgjsag67251 <88368191+jdgjsag67251@users.noreply.github.com> Date: Tue, 30 May 2023 13:42:39 +0200 Subject: [PATCH 1/2] Implemented 'docker.restartPolicy' --- CONTRIBUTING.md | 2 +- src/plugins/meteor/assets/templates/start.sh | 4 ++-- src/plugins/meteor/index.js | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f85fba6..7eaca97b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,7 +77,7 @@ cd .. npm run docs ``` -The webiste will now be running at [http://localhost:8080/](http://localhost:8080/). +The website will now be running at [http://localhost:8080/](http://localhost:8080/). ## Financial contributions diff --git a/src/plugins/meteor/assets/templates/start.sh b/src/plugins/meteor/assets/templates/start.sh index bea847a6..960d262b 100644 --- a/src/plugins/meteor/assets/templates/start.sh +++ b/src/plugins/meteor/assets/templates/start.sh @@ -72,7 +72,7 @@ fi sudo docker run \ -d \ - --restart=always \ + --restart=<%= docker.restartPolicy %> \ $VOLUME \ <% if((sslConfig && typeof sslConfig.autogenerate === "object") || (typeof proxyConfig === "object" && !proxyConfig.loadBalancing)) { %> \ --expose=<%= docker.imagePort %> \ @@ -157,7 +157,7 @@ EOT set -e sudo docker run \ -d \ - --restart=always \ + --restart=<%= docker.restartPolicy %> \ --volume=/opt/$APPNAME/config/bundle.crt:/bundle.crt \ --volume=/opt/$APPNAME/config/private.key:/private.key \ --link=$APPNAME:backend \ diff --git a/src/plugins/meteor/index.js b/src/plugins/meteor/index.js index 14cdc1a8..d014545f 100644 --- a/src/plugins/meteor/index.js +++ b/src/plugins/meteor/index.js @@ -49,6 +49,8 @@ export function prepareConfig(config, api) { config.app.buildOptions.cleanBuildLocation = true; } + config.app.docker.restartPolicy = config.app.docker.restartPolicy || 'always'; + return config; } From b6cd1c436c88f23e9b1b11e73c8350e24ff30ae9 Mon Sep 17 00:00:00 2001 From: jdgjsag67251 <88368191+jdgjsag67251@users.noreply.github.com> Date: Tue, 30 May 2023 13:42:46 +0200 Subject: [PATCH 2/2] Updated documentation --- docs/docs.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 0bc98ce8..3d42cf85 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -162,7 +162,11 @@ module.exports = { // (runs docker network connect for each network listed here) networks: [ 'net1' - ] + ], + + // Change the container's restart policy + // See https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policy + restartPolicy: 'always' }, // list of servers to deploy to, from the 'servers' list @@ -390,7 +394,7 @@ Meteor Up uses Docker to run and manage your app. It uses [MeteorD](https://gith * Your currently running meteor bundle lives at `/opt//current` * We have a demonized docker container running the above bundle -* The docker container is started with `--restart=always` flag and it'll re-spawn the container if it dies +* The docker container is started with `--restart=always` flag (by default) and it'll re-spawn the container if it dies * Logs are maintained via Docker * If you decided to use MongoDB, it will be running as its own Docker container. It's bound to the local interface and to port `27017` (you cannot access it from the outside) * The database is named `` @@ -560,6 +564,20 @@ And then add a docker setup hook to login to your private registry on the server You can set `app.docker.imagePort` to the port to expose from the container. This does not affect the port the app is accessed on, only the port the app runs on inside the docker container. It defaults to 3000. +### Restart policy + +You can change the default ('always') [Docker restart policy](https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policy) by specifying `restartPolicy` in the 'docker' section of the config: + +``` +app: { + ... + docker: { + ... + restartPolicy: 'no' + } +} +``` + ## Reverse Proxy Meteor Up can create a nginx reverse proxy that will handle SSL, and, if you are running multiple apps on the server, it will route requests to the correct app. The proxy is shared between all apps on the servers.