That’s weird!
Here are my full specs!
I’m also using express (^4.18.1), prisma (^3.15.2) and bull (^4.10.1) and my app is working properly, except for the script on console part.
relevant scripts:
"scripts": {
"start": "node dist/server.js",
"worker": "node dist/worker.js",
...
},
server.ts:
const app = express();
...routes and middlewares here...
((port = process.env.PORT || 8080) => {
const server = app.listen(port, () =>
console.log(
`> Listening on port ${port} from environment: ${process.env.NODE_ENV}`,
),
);
process.on('SIGTERM', () => {
console.debug('SIGTERM signal received: closing HTTP server');
server.close(() => {
console.debug('HTTP server closed');
process.exit(0);
});
});
})();
my fly.toml file:
# fly.toml file generated for hippro-backend on 2023-02-08T17:53:54-03:00
app = "hippro-backend"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
builder = "heroku/buildpacks:20"
[env]
PORT = "8080"
NODE_ENV = "production"
[deploy]
release_command = "npx prisma migrate deploy"
[experimental]
auto_rollback = true
[processes]
web = "npm run start"
worker = "npm run worker"
[[services]]
http_checks = []
internal_port = 8080
processes = ["web"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
My Dockerfile now (same as you passed):
FROM debian:bullseye as builder
ARG NODE_VERSION=16.15.1
ARG YARN_VERSION=1.22.19
ENV PATH=/usr/local/node/bin:$PATH
RUN apt-get update; apt install -y curl python-is-python3 pkg-config build-essential && \
curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
npm install -g yarn@$YARN_VERSION && \
rm -rf /tmp/node-build-master
#######################################################################
RUN mkdir /app
WORKDIR /app
# Yarn will not install any package listed in "devDependencies" when NODE_ENV is set to "production"
# to install all modules: "yarn install --production=false"
# Ref: https://classic.yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production-true-false
ENV NODE_ENV production
COPY . .
RUN yarn install && yarn run build
FROM debian:bullseye
LABEL fly_launch_runtime="nodejs"
COPY --from=builder /usr/local/node /usr/local/node
COPY --from=builder /app /app
WORKDIR /app
ENV NODE_ENV production
ENV PATH /usr/local/node/bin:$PATH
CMD [ "yarn", "run", "start" ]
and my dockerignore:
fly.toml
Dockerfile
.dockerignore
node_modules
.github
.git
.env
I’m at the project directory. When I use fly status
, this is what I get:
App
Name = hippro-backend
Owner = personal
Version = 129
Status = running
Hostname = hippro-backend.fly.dev
Platform = nomad
Deployment Status
ID = b2156634-a51c-7b2b-c545-46eb497fab43
Version = v129
Status = successful
Description = Deployment completed successfully
Instances = 2 desired, 2 placed, 2 healthy, 0 unhealthy
Instances
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
bf636055 worker 129 gru run running 0 21m15s ago
d0f0b7ce web 129 gru run running 1 total, 1 passing 0 21m15s ago
And when I try to use fly ssh console -C 'node -v'
, I’m getting:
fly ssh console -C 'node -v'
Connecting to fdaa:1:3e61:a7b:fa:fac0:315f:2... complete
exec: "node": executable file not found in $PATH
When I try fly ssh console
then echo $PATH
:
fly ssh console
Connecting to fdaa:1:3e61:a7b:101:fcc6:6ef6:2... complete
# echo $PATH
/cnb/process:/cnb/lifecycle:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin```