Machines are automatically shutting down immediately

Hi! I’m new here. I’m trying to deploy a simple out of the box Vendure backend with Docker and PostresSQL. I don’t know if the recent migration issues are to blame, but I have not had any luck actually pulling up the app. All deployments went through just fine.

exit_code=0,oom_killed=false,requested_stop=false

There probably isn’t enough information in your post for readers to help. Would you show us your Dockerfile and TOML config?

Thank you, I wasn’t sure what would be relevant here.

Fly file:

# fly.toml app configuration file generated for shop-shortfusemusic on 2025-05-21T23:26:27Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'shop-shortfusemusic'
primary_region = 'lax'

[build]

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 1024

When I look at the config on fly.io, it’s slightly different with underscores where commas might be in the numbers

app = "shop-shortfusemusic"
primary_region = "lax"

[http_service]
auto_start_machines = true
auto_stop_machines = true
force_https = true
internal_port = 3_000
min_machines_running = 0
processes = [ "app" ]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory = "1gb"
memory_mb = 1_024

My Dockerfile:

FROM node:20

WORKDIR /usr/src/app

COPY package.json ./
COPY package-lock.json ./
RUN npm install --production
COPY . .

EXPOSE 3000

RUN npm run build

1 Like

Hm… Typically you would have a CMD directive at the tail end of the Dockerfile…

Try looking in the logs (fly logs) for a line of the form Preparing to run: `foo` as root. My guess is that the foo command in your particular case is just an inherited placeholder that is exiting immediately. (But I’m definitely not one of the local Node experts.)

(Maybe look at some of the other Node users’ Dockerfiles in the forum archives and see what they tend to use, :thought_balloon:.)

Thank you that did help! Now the issue I’m seeing is that “concurrently” isn’t found, but it is definitely in my package.json file

2025-05-24T02:22:58.968 proxy[48e2d1ef313ee8] lax [info] Starting machine

2025-05-24T02:22:59.047 app[48e2d1ef313ee8] lax [info] 2025-05-24T02:22:59.047857724 [01JW01AEX6X2V4M753886S6FQM:main] Running Firecracker v1.7.0

2025-05-24T02:22:59.914 app[48e2d1ef313ee8] lax [info] INFO Starting init (commit: a1a45272)...

2025-05-24T02:23:00.030 app[48e2d1ef313ee8] lax [info] INFO Preparing to run: `docker-entrypoint.sh npm run start` as root

2025-05-24T02:23:00.039 app[48e2d1ef313ee8] lax [info] INFO [fly api proxy] listening at /.fly/api

2025-05-24T02:23:00.076 runner[48e2d1ef313ee8] lax [info] Machine started in 1.104s

2025-05-24T02:23:00.078 proxy[48e2d1ef313ee8] lax [info] machine started in 1.110632841s

2025-05-24T02:23:00.423 app[48e2d1ef313ee8] lax [info] 2025/05/24 02:23:00 INFO SSH listening listen_address=[fdaa:19:d0e7:a7b:2b8:3c3c:9830:2]:22

2025-05-24T02:23:01.449 app[48e2d1ef313ee8] lax [info] > shop-shortfusemusic@0.1.0 start

2025-05-24T02:23:01.449 app[48e2d1ef313ee8] lax [info] > concurrently npm:start:*

2025-05-24T02:23:01.455 app[48e2d1ef313ee8] lax [info] sh: 1: concurrently: not found

2025-05-24T02:23:02.041 app[48e2d1ef313ee8] lax [info] INFO Main child exited normally with code: 127

2025-05-24T02:23:02.057 app[48e2d1ef313ee8] lax [info] INFO Starting clean up.

2025-05-24T02:23:02.807 app[48e2d1ef313ee8] lax [info] WARN could not unmount /rootfs: EINVAL: Invalid argument

2025-05-24T02:23:02.807 app[48e2d1ef313ee8] lax [info] [ 3.684659] reboot: Restarting system

In my package.json

  "scripts": {
    "dev:server": "ts-node ./src/index.ts",
    "dev:worker": "ts-node ./src/index-worker.ts",
    "dev": "concurrently npm:dev:*",
    "build": "tsc",
    "start:server": "node ./dist/index.js",
    "start:worker": "node ./dist/index-worker.js",
    "start": "concurrently npm:start:*"
  },
  "dependencies": {
    "@vendure/admin-ui-plugin": "3.3.1",
    "@vendure/asset-server-plugin": "3.3.1",
    "@vendure/core": "3.3.1",
    "@vendure/email-plugin": "3.3.1",
    "@vendure/graphiql-plugin": "3.3.1",
    "dotenv": "16.5.0",
    "pg": "8.16.0",
    "concurrently": "^9.1.2"
  },

Hmm, I can’t see the problem. I just did this in Docker:

halfer@VirtualBox:~/Development/$ docker run -it node:20-bookworm-slim bash
root@24d36e875f8e:/# apt update
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8793 kB]
Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [512 B]                                                                                                                                                              
Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [261 kB]                                                                                                                                                   
Fetched 9309 kB in 11s (886 kB/s)                                                                                                                                                                                                            
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
9 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@24d36e875f8e:/# apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  base-files bash debian-archive-keyring gcc-12-base libcap2 libgcc-s1 libstdc++6 login passwd
9 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 4055 kB of archives.
After this operation, 15.4 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 base-files amd64 12.4+deb12u11 [70.9 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 bash amd64 5.2.15-2+b8 [1491 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 login amd64 1:4.13+dfsg1-1+deb12u1 [616 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 passwd amd64 1:4.13+dfsg1-1+deb12u1 [972 kB]
Get:5 http://deb.debian.org/debian bookworm/main amd64 debian-archive-keyring all 2023.3+deb12u2 [179 kB]
Get:6 http://deb.debian.org/debian bookworm/main amd64 gcc-12-base amd64 12.2.0-14+deb12u1 [37.6 kB]
Get:7 http://deb.debian.org/debian bookworm/main amd64 libstdc++6 amd64 12.2.0-14+deb12u1 [613 kB]
Get:8 http://deb.debian.org/debian bookworm/main amd64 libgcc-s1 amd64 12.2.0-14+deb12u1 [49.9 kB]
Get:9 http://deb.debian.org/debian bookworm/main amd64 libcap2 amd64 1:2.66-4+deb12u1 [27.2 kB]
Fetched 4055 kB in 4s (1137 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 6091 files and directories currently installed.)
Preparing to unpack .../base-files_12.4+deb12u11_amd64.deb ...
Unpacking base-files (12.4+deb12u11) over (12.4+deb12u10) ...
Setting up base-files (12.4+deb12u11) ...
Installing new version of config file /etc/debian_version ...
(Reading database ... 6091 files and directories currently installed.)
Preparing to unpack .../bash_5.2.15-2+b8_amd64.deb ...
update-alternatives: warning: alternative /usr/share/man/man7/bash-builtins.7.gz (part of link group builtins.7.gz) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/builtins.7.gz is dangling; it will be updated with best choice
Unpacking bash (5.2.15-2+b8) over (5.2.15-2+b7) ...
Setting up bash (5.2.15-2+b8) ...
update-alternatives: error: alternative path /usr/share/man/man7/bash-builtins.7.gz doesn't exist
(Reading database ... 6091 files and directories currently installed.)
Preparing to unpack .../login_1%3a4.13+dfsg1-1+deb12u1_amd64.deb ...
Unpacking login (1:4.13+dfsg1-1+deb12u1) over (1:4.13+dfsg1-1+b1) ...
Setting up login (1:4.13+dfsg1-1+deb12u1) ...
(Reading database ... 6090 files and directories currently installed.)
Preparing to unpack .../passwd_1%3a4.13+dfsg1-1+deb12u1_amd64.deb ...
Unpacking passwd (1:4.13+dfsg1-1+deb12u1) over (1:4.13+dfsg1-1+b1) ...
Setting up passwd (1:4.13+dfsg1-1+deb12u1) ...
(Reading database ... 6089 files and directories currently installed.)
Preparing to unpack .../debian-archive-keyring_2023.3+deb12u2_all.deb ...
Unpacking debian-archive-keyring (2023.3+deb12u2) over (2023.3+deb12u1) ...
Setting up debian-archive-keyring (2023.3+deb12u2) ...
Removing obsolete conffile /etc/apt/trusted.gpg.d/debian-archive-buster-stable.asc ...
Removing obsolete conffile /etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.asc ...
Removing obsolete conffile /etc/apt/trusted.gpg.d/debian-archive-buster-automatic.asc ...
(Reading database ... 6089 files and directories currently installed.)
Preparing to unpack .../gcc-12-base_12.2.0-14+deb12u1_amd64.deb ...
Unpacking gcc-12-base:amd64 (12.2.0-14+deb12u1) over (12.2.0-14) ...
Setting up gcc-12-base:amd64 (12.2.0-14+deb12u1) ...
(Reading database ... 6089 files and directories currently installed.)
Preparing to unpack .../libstdc++6_12.2.0-14+deb12u1_amd64.deb ...
Unpacking libstdc++6:amd64 (12.2.0-14+deb12u1) over (12.2.0-14) ...
Setting up libstdc++6:amd64 (12.2.0-14+deb12u1) ...
(Reading database ... 6089 files and directories currently installed.)
Preparing to unpack .../libgcc-s1_12.2.0-14+deb12u1_amd64.deb ...
Unpacking libgcc-s1:amd64 (12.2.0-14+deb12u1) over (12.2.0-14) ...
Setting up libgcc-s1:amd64 (12.2.0-14+deb12u1) ...
(Reading database ... 6089 files and directories currently installed.)
Preparing to unpack .../libcap2_1%3a2.66-4+deb12u1_amd64.deb ...
Unpacking libcap2:amd64 (1:2.66-4+deb12u1) over (1:2.66-4) ...
Setting up libcap2:amd64 (1:2.66-4+deb12u1) ...
Processing triggers for debianutils (5.7-0.5~deb12u1) ...
Processing triggers for libc-bin (2.36-9+deb12u10) ...
root@24d36e875f8e:/# apt-cache search concurrently
node-copy-concurrently - Copy files, directories and symlinks concurrently
node-move-concurrently - Move files and directories concurrently
node-p-map - Map over promises concurrently
librust-concread-dev - Concurrently Readable Data-Structures for Rust - Rust source code
root@24d36e875f8e:/# mkdir project
root@24d36e875f8e:/# cd project
root@24d36e875f8e:/project# npm install --save-dev concurrently

added 26 packages in 4s

6 packages are looking for funding
  run `npm fund` for details
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.4.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.4.1
npm notice To update run: npm install -g npm@11.4.1
npm notice
root@24d36e875f8e:/project# ls
node_modules  package-lock.json  package.json
root@24d36e875f8e:/project# ls node_modules/
ansi-regex   chalk  color-convert  concurrently  escalade	  has-flag		   lodash	      rxjs	   string-width  supports-color  tslib	    y18n   yargs-parser
ansi-styles  cliui  color-name	   emoji-regex	 get-caller-file  is-fullwidth-code-point  require-directory  shell-quote  strip-ansi	 tree-kill	 wrap-ansi  yargs
root@24d36e875f8e:/project# ls node_modules/concurrently/
LICENSE  README.md  dist  docs	index.d.mts  index.d.ts  index.js  index.mjs  package.json
root@24d36e875f8e:/project# ls node_modules/concurrently/dist/
bin  src
root@24d36e875f8e:/project# ls node_modules/concurrently/dist/bin/
concurrently.d.ts  concurrently.js  read-package.d.ts  read-package.js
root@24d36e875f8e:/project# apt install -y nano
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libgpm2 libncursesw6
Suggested packages:
  gpm hunspell
The following NEW packages will be installed:
  libgpm2 libncursesw6 nano
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 838 kB of archives.
After this operation, 3339 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 libncursesw6 amd64 6.4-4 [134 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 nano amd64 7.2-1+deb12u1 [690 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 libgpm2 amd64 1.20.7-10+b1 [14.2 kB]
Fetched 838 kB in 1s (925 kB/s)   
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libncursesw6:amd64.
(Reading database ... 6089 files and directories currently installed.)
Preparing to unpack .../libncursesw6_6.4-4_amd64.deb ...
Unpacking libncursesw6:amd64 (6.4-4) ...
Selecting previously unselected package nano.
Preparing to unpack .../nano_7.2-1+deb12u1_amd64.deb ...
Unpacking nano (7.2-1+deb12u1) ...
Selecting previously unselected package libgpm2:amd64.
Preparing to unpack .../libgpm2_1.20.7-10+b1_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.7-10+b1) ...
Setting up libgpm2:amd64 (1.20.7-10+b1) ...
Setting up libncursesw6:amd64 (6.4-4) ...
Setting up nano (7.2-1+deb12u1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group editor) doesn't exist
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pico.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group pico) doesn't exist
Processing triggers for libc-bin (2.36-9+deb12u10) ...
root@24d36e875f8e:/project# nano package.json 
root@24d36e875f8e:/project# npm start

> start
> concurrently npm:start:*

root@24d36e875f8e:/project# cat package.json 
{
  "scripts": {
    "start": "concurrently npm:start:*"
  },
  "devDependencies": {
    "concurrently": "^9.1.2"
  }
}
root@24d36e875f8e:/project# 

I looked for a repo-level package called concurrently, but it is definitely only a Node package.

So this works, at least in the sense that errors are not produced.

I wonder, could you put CMD ["npm", "start"] at the end of your Dockerfile? I don’t know what this command is within the parent image, but personally I like to make it explicit at the application level.

Also, consider trying your app locally in Docker; it’s worth discounting any Fly magic :sparkles:

I don’t see anything wrong with your setup. Since you have a hand crafted Dockerfile, perhaps check your .dockerignore. Make sure it has node_modules in it.

I also would suggest is try running fly console. This will create an ephemeral machine with your image and ssh into it as root. You can look around and see what you find. You should find concurrently in node_modules/.bin/concurrently. npm knows to look there for executables. If by chance you are uploading your node_modules, you may have an executable for a different operating system or instruction set architecture there.

In an empty directory I ran:

npm init -y
npm install http-server
npm install concurrently

I modified my package.json to look like this:

{
  "name": "nodeserver",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "concurrently npm:server",
    "server": "http-server --port 3000"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "concurrently": "^9.1.2",
    "http-server": "^14.1.1"
  }
}

I then ran fly launch. This will create a fly.toml, a Dockerfile and a .dockerignore file.

What I tried worked:

Do you mean that the OP should ensure that node_modules is not in the .dockerignore?

No, you want it to be present. What npm install does is populate node_modules with files that are appropriate for your operating system and instruction set architecture. The Docker image is probably running a different operating system and possibly even a different instruction set architecture. So you want to ignore these files as they exist on your machine and include npm install in your Dockerfile.

The .dockerignore file for the example I gave (as generated by fly launch) looks like this:

/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
1 Like

Ah, yes, that makes sense, thank you; I found this answer to understand things a bit more.

I had incorrectly thought .dockerignore stops an artifact going into an image build, but in fact it just removes that artifact from the Docker context, which affects build speed and layer caching. npm install is still writing a new layer in the image. :+1:

I just looked up a Node project I deploy to Fly, and I put node_modules in .dockerignore, so I must have understood this at one point :laughing:

Adding the CMD line at the end of the Dockerfile and using the fly command line instead of deploying thru git worked for me. Thank you everyone!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.