I have a very simple nodejs app using fastify. I followed the NodeJS Guide for a basic setup, but my app is using Typescript.
My app builds fine locally and builds successfully when deploying to fly.io, but once I attempt to make a request, it ends up failing. I think this is some combination of my fly.toml
or Dockerfile
networking being wonky. Thanks in advance, hopefully this is very straightforward.
Dockerfile
FROM debian:bullseye as builder
ARG NODE_VERSION=16.16.0
RUN apt-get update; apt install -y curl python-is-python3 pkg-config build-essential
RUN curl https://get.volta.sh | bash
ENV VOLTA_HOME /root/.volta
ENV PATH /root/.volta/bin:$PATH
RUN volta install node@${NODE_VERSION}
#######################################################################
RUN mkdir /app
WORKDIR /app
# NPM will not install any package listed in "devDependencies" when NODE_ENV is set to "production",
# to install all modules: "npm install --production=false".
# Ref: https://docs.npmjs.com/cli/v9/commands/npm-install#description
COPY . .
RUN npm install
FROM debian:bullseye
LABEL fly_launch_runtime="nodejs"
COPY --from=builder /root/.volta /root/.volta
COPY --from=builder /app /app
WORKDIR /app
ENV NODE_ENV production
ENV PATH /root/.volta/bin:$PATH
EXPOSE 8080
CMD [ "npm", "run", "start" ]
# fly.toml file generated for dry-frog-7810 on 2023-02-12T19:44:32-05:00
app = "my-app-name"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
[experimental]
auto_rollback = true
private_network = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
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"
Below are some logs of what ends up happening:
2023-02-13T01:09:02.118 app[6e5c9c06] ord [info] {"level":30,"time":1676250542117,"pid":557,"hostname":"6e5c9c06","msg":"Server listening at http://127.0.0.1:8080"}
2023-02-13T01:09:02.120 app[6e5c9c06] ord [info] {"level":30,"time":1676250542120,"pid":557,"hostname":"6e5c9c06","msg":"Server listening at http://[::1]:8080"}
2023-02-13T01:09:56.872 proxy[ee61af66] ord [error] instance refused connection
2023-02-13T01:09:56.991 proxy[6e5c9c06] ord [error] instance refused connection
2023-02-13T01:10:01.420 proxy[6e5c9c06] lax [warn] Could not proxy HTTP request. Retrying in 1000 ms (attempt 10)