Deploying Rescript NextJS App

I am trying to deploy a rescript app, which is built (rescript build) on circle ci, and then deployed to fly.io via a Dockerfile.

During the deploy in the Dockerfile, we run a RUN yarn install and a CMD ["yarn", "start"]

I am having issues with rescript being installed on the machine, random python errors, etc.

What I am SUPER confused by is why is rescript being installed, or called, or anything at this point, the app was already built on a prior step, we are simply trying to run the built artifact with next-boost (next with cache). rescript is a devDependency and should not be installed or called at any point when calling “yarn install”, correct?

Overall similar issues to this post: Ninja Install Fail

What is going on?

1 Like

What’s the base docker image?

I have tries a few:

FROM node:15.9.0-alpine is the latest “try”

originally was trying with FROM node:current-alpine

Either way, it makes ZERO sense that ANYTHING rescript is running or being installed during “yarn install” as its a devDependency and the project has already been successfully built on a prior step before deploying via a Dockerfile.

Hi @dan003400, I suspect yarn install installs all dependencies. Would this work?:

yarn install --production

I use plain node images and as @kevanstannard mentioned with production flag on yarn install in my runner step.

RUN yarn install --frozen-lockfile --production

I am still seeing crazy ocaml / rescript errors when using --production flag.

This is crazy, it makes no sense that rescript should be involved at all at this step.

it makes no sense that rescript should be involved at all at this step

It might be that some of your dependencies make rescript dependencies instead of dev-dependencies + alpine distribution does not work with our prebuilt image.

If you use npm, you can add -ignore-scripts to avoid the compiler being built

2 Likes

This may help: https://github.com/ocaml/v3.ocaml.org/blob/master/Dockerfile . I wasn’t involved with producing it, just forwarding it along. The goal of the docker image was to house the static export results (more like a tar ball than a traditional docker service image) which would be served by a generic http server.

1 Like

Also, for an older version of ReScript, I installed the following for an Alpine CI build (not all of these packages are needed):

  build-frontend:
    working_directory: /mnt/ramdisk/app
    # NOTE: we are using xlarge to have enough memory to use ramdisk
    resource_class: xlarge


    docker:
      - image: node:10-alpine3.9

    steps:
      # NOTE: .
      #   python was added because bs-platform needs it to build ninja.
      
      - run:
          name: Install system packages
          command: |
            apk update
            apk add \
              gfortran \
              m4 \
              curl \
              git \
              openssh \
              bash \
              make \
              gcc \
              g++ \
              musl-dev \
              linux-headers \
              perl \
              perl-utils \
              pkgconfig \
              openssl \
              libffi \
              zlib-dev \
              libc-dev \
              libressl-dev \
              tzdata \
              rsync \
              python 
1 Like