Another "Can't Deploy a New Remix App" post

Node: v16.14.2

Following

npx create-remix@latest

and choosing the blues stack.

Thanks.

The Error:

 start

2022-04-01T06:14:28.562 app[be322e4c] dfw [info] > cross-env NODE_ENV=production node ./build/server.js

2022-04-01T06:14:28.931 app[be322e4c] dfw [info] /app/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]         throw new Error(prefix);

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]               ^

2022-04-01T06:14:28.931 app[be322e4c] dfw [info] Error: Invariant failed

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at invariant (/app/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10:15)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at getClient (/app/build/index.js:405:37)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Object. (/app/build/index.js:396:12)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Module._compile (node:internal/modules/cjs/loader:1103:14)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Module.load (node:internal/modules/cjs/loader:981:32)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Function.Module._load (node:internal/modules/cjs/loader:822:12)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Module.require (node:internal/modules/cjs/loader:1005:19)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at require (node:internal/modules/cjs/helpers:102:18)

2022-04-01T06:14:28.931 app[be322e4c] dfw [info]     at Object. (/app/build/server.js:59:89) 

The toml file:

# fly.toml file generated for hovertrail on 2022-03-31T23:08:09-07:00

app = "hovertrail"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = 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"

Dockerfile:

# base node image
FROM node:16-bullseye-slim as base

# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl

# Install all node_modules, including dev dependencies
FROM base as deps

RUN mkdir /app
WORKDIR /app

ADD package.json package-lock.json ./
RUN npm install --production=false

# Setup production node_modules
FROM base as production-deps

RUN mkdir /app
WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules
ADD package.json package-lock.json ./
RUN npm prune --production

# Build the app
FROM base as build

ENV NODE_ENV=production

RUN mkdir /app
WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules

# If we're using Prisma, uncomment to cache the prisma schema
# ADD prisma .
# RUN npx prisma generate

ADD . .
RUN npm run build

# Finally, build the production image with minimal footprint
FROM base

ENV NODE_ENV=production

RUN mkdir /app
WORKDIR /app

COPY --from=production-deps /app/node_modules /app/node_modules

# Uncomment if using Prisma
# COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma

COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
ADD . .

CMD ["npm", "run", "start"]

Did you set the SESSION_SECRET with fly secrets set?

No, I followed this guide: Deploy a Remix Application

Is setting secrets something that should be added to that guide? Thanks!

The Remix Blues stack does require secrets. The stacks have their own guides: GitHub - remix-run/blues-stack: The Remix Stack for deploying to Fly with PostgreSQL, authentication, testing, linting, formatting, etc.

Ayup - I just greped for fly secrets in the codebase and stumbled across it.

We might want to drop a note on the guide to this effect - “Using one of the stack installers? Check out the README.md on the given stack”

Thanks! I’ll give this a try.

[hacker voice] I’m in.

Website launched following the stack-specific README.md directions!

1 Like

Yeah we should link to the stack READMEs from our guide, that would make a lot of sense.

1 Like