github ci/cd for fly.io
i have a github ci/cd for fly.io but it's having an issue with node version and sharp
but when i deploy it locally same command is working fine
14 Replies
Hi @silent. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It sounds like your GitHub CI/CD pipeline for deploying to Fly.io is encountering issues with the Node.js version and the sharp package, while local deployment works fine. Based on the knowledge sources, here are some key points and suggestions:
1. Node.js Version Mismatch:
Wasp requires a specific Node.js version (historically Node 18 LTS, but from Wasp 0.12, Node >=18 is supported). If your CI/CD environment uses a different Node version (e.g., Node 20 or 21), you may encounter errors that you don't see locally if your local environment matches Wasp's requirements.
Make sure your CI/CD workflow explicitly sets the Node.js version to match Wasp's requirements. For example, in your GitHub Actions workflow, use: This ensures consistency between your local and CI environments regarding Node.js version requirements.
Node version requirement issue
CI Node version discussion 2. Sharp Package Issues:
The sharp package is a native Node.js module and is sensitive to the Node.js version and the environment in which it is built. If your CI/CD uses a different OS, architecture, or Node version than your local machine, sharp may fail to build or run.
Ensure that your Dockerfile or build environment in CI matches your local environment as closely as possible. If you are customizing the Dockerfile, you can copy it to your project root and adjust it as needed for your dependencies.
Custom Dockerfile for deployment 3. Fly.io Build Differences:
By default, Wasp uses remote builders on Fly.io, which may have different environments than your local machine. If you want to ensure the build environment matches your local setup, you can use the
Wasp requires a specific Node.js version (historically Node 18 LTS, but from Wasp 0.12, Node >=18 is supported). If your CI/CD environment uses a different Node version (e.g., Node 20 or 21), you may encounter errors that you don't see locally if your local environment matches Wasp's requirements.
Make sure your CI/CD workflow explicitly sets the Node.js version to match Wasp's requirements. For example, in your GitHub Actions workflow, use: This ensures consistency between your local and CI environments regarding Node.js version requirements.
Node version requirement issue
CI Node version discussion 2. Sharp Package Issues:
The sharp package is a native Node.js module and is sensitive to the Node.js version and the environment in which it is built. If your CI/CD uses a different OS, architecture, or Node version than your local machine, sharp may fail to build or run.
Ensure that your Dockerfile or build environment in CI matches your local environment as closely as possible. If you are customizing the Dockerfile, you can copy it to your project root and adjust it as needed for your dependencies.
Custom Dockerfile for deployment 3. Fly.io Build Differences:
By default, Wasp uses remote builders on Fly.io, which may have different environments than your local machine. If you want to ensure the build environment matches your local setup, you can use the
--build-locally
flag with Wasp's deploy commands:
Building locally for Fly.io
Summary of Actions:
- Ensure your CI/CD workflow uses the correct Node.js version.
- Match your build environment (OS, architecture, Node version) between local and CI/CD.
- Consider building locally if remote builders cause issues with native modules like sharp.
If you continue to have issues, please provide the specific error messages from your CI/CD logs for more targeted help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @silent, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai i was using wasp 0.16.7
Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for specifying that you are using Wasp 0.16.7. According to the knowledge sources, Wasp versions prior to 0.12 (and for some time after) required Node.js 18 specifically, and would not accept Node.js 20 or higher—even though the error message might suggest otherwise. This has been a common source of confusion, as users running Node 20.x.x would see errors stating that their Node version does not meet Wasp's requirements, even though the message says ">= 18"[^1][^2].
For Wasp 0.16.7, it is likely that only Node.js 18 is officially supported, and using Node 20 or higher in your CI/CD (or Fly.io builder) will cause issues, especially with native modules like sharp. Locally, if you are using Node 18, things will work, but in CI/CD, if the Node version is different, you will encounter errors.
What you should do:
- Ensure your GitHub Actions workflow or Fly.io builder uses Node.js 18 (not 20 or higher) for Wasp 0.16.7.
- You can set this in your GitHub Actions workflow with:
- If you are using a Dockerfile, make sure the base image is also Node 18.
If you upgrade to a newer Wasp version (>= 0.12), Node.js >= 18 should be supported, including Node 20, but for 0.16.7, stick with Node 18 for compatibility.
[^1]: Node version requirement issue
[^2]: Node 20.x.x isn't compatible with Wasp?
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @silent, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
@kapa.ai here the error in fly.io server
throw new Error(help.join('\n'));
Error: Could not load the "sharp" module using the linuxmusl-x64 runtime
Possible solutions:
Please upgrade Node.js:
Found 20.0.0
Requires ^18.17.0 ^20.3.0 >=21.0.0
Consult the installation documentation:
See https://sharp.pixelplumbing.com/install
Let me check the knowledge base for you again. One moment! :books:
----------------------
The error message from Fly.io indicates that the sharp module requires a Node.js version of ^18.17.0, ^20.3.0, or >=21.0.0, but the environment is using Node 20.0.0, which is not compatible with sharp's requirements.
Based on the knowledge sources, Wasp 0.16.7 expects Node.js 18.x (specifically >=18.12.0), and there have been frequent issues when using Node 20.x.x, both with Wasp itself and with native modules like sharp. The error you are seeing is due to a mismatch between the Node.js version required by sharp and the version available in the Fly.io build environment.
What you should do:
- Ensure that your Fly.io deployment uses Node.js 18.17.0 or higher (but still within the Node 18 LTS line), or Node 20.3.0 or higher, as required by sharp.
- For Wasp 0.16.7, Node 18.x is the safest choice, as this is the version Wasp expects and is tested with, according to the knowledge sources.
- If you are using a custom Dockerfile, explicitly set the Node.js version to 18.17.0 or higher (but not 20.0.0, as that is not supported by sharp or Wasp in your version).
- In your GitHub Actions workflow, set up Node.js 18.17.0 or higher using the setup-node action. There is no information in the knowledge sources about sharp specifically, but the Node.js version compatibility issues are well documented for Wasp and are likely the root cause of your deployment problem. If you continue to have issues, you may need to upgrade your Node.js version in the deployment environment or consider upgrading Wasp if you want to use newer Node.js versions. If you need to customize the Dockerfile for your deployment, you can copy the Dockerfile from
- For Wasp 0.16.7, Node 18.x is the safest choice, as this is the version Wasp expects and is tested with, according to the knowledge sources.
- If you are using a custom Dockerfile, explicitly set the Node.js version to 18.17.0 or higher (but not 20.0.0, as that is not supported by sharp or Wasp in your version).
- In your GitHub Actions workflow, set up Node.js 18.17.0 or higher using the setup-node action. There is no information in the knowledge sources about sharp specifically, but the Node.js version compatibility issues are well documented for Wasp and are likely the root cause of your deployment problem. If you continue to have issues, you may need to upgrade your Node.js version in the deployment environment or consider upgrading Wasp if you want to use newer Node.js versions. If you need to customize the Dockerfile for your deployment, you can copy the Dockerfile from
.wasp/build
to your project root and modify it as needed to ensure the correct Node.js version is used during the build and runtime process. This approach is described in the knowledge sources for advanced deployment scenarios on Fly.ioCustom Dockerfile for deployment.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @silent, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai already have docker file
FROM node:21.7.0-bullseye-slim AS base
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y \
python3 build-essential libtool autoconf automake \
openssl libssl-dev \
libvips-dev \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /workspace
FROM base AS builder
WORKDIR /app
COPY src ./src
COPY package.json package-lock.json ./
COPY server .wasp/build/server
COPY sdk .wasp/out/sdk
COPY db/schema.prisma .wasp/build/db/
RUN rm -f package-lock.json && npm install
WORKDIR /app/.wasp/build/server
RUN rm -f package-lock.json && npm install
RUN npm uninstall sharp || true
RUN npm install sharp --platform=linux --arch=x64 --libc=musl
RUN node --version && npm list sharp
RUN npx prisma generate --schema=../db/schema.prisma
RUN npm rebuild @node-rs/argon2 --build-from-source
RUN npm run bundle
FROM base AS prod
ENV NODE_ENV=production
ARG PORT=8080
ENV PORT=${PORT}
ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1
ENV SHARP_DIST_BASE_URL=https://github.com/lovell/sharp-libvips/releases/download/
ENV GOOGLE_APPLICATION_CREDENTIALS=/workspace/gcp-key.json
EXPOSE ${PORT}
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.wasp/build/server/node_modules .wasp/build/server/node_modules
COPY --from=builder /app/.wasp/build/server/bundle .wasp/build/server/bundle
COPY --from=builder /app/.wasp/build/server/package*.json .wasp/build/server/
COPY --from=builder /app/.wasp/build/db/ .wasp/build/db/
WORKDIR /app/.wasp/build/server
CMD ["bash", "-c", "echo "$GCP_SERVICE_ACCOUNT_B64" | base64 -d > "$GOOGLE_APPLICATION_CREDENTIALS" && exec npm run start-production"]
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on your Dockerfile and the error message, the root issue is a Node.js version mismatch:
- The sharp module requires Node.js ^18.17.0, ^20.3.0, or >=21.0.0, but your Fly.io environment is using Node 20.0.0, which is not compatible. - Your Dockerfile uses Node 21.7.0, which should be compatible with sharp, but the error suggests that the runtime on Fly.io is not using this image as expected, or there is a mismatch between build and runtime environments. Relevant Wasp context:
Wasp 0.16.7 is designed to work with Node.js 18.x (>=18.12.0), and only more recent Wasp versions (from 0.12 onward) officially support Node.js >=18, including 20 and above. If you use a newer Node version (like 21.x) with Wasp 0.16.7, you may encounter compatibility issues, as Wasp itself may expect Node 18.x in some parts of the build or runtime process. This is a known source of deployment issues, especially with native modules like sharp, and is discussed in the knowledge sources Node version requirement issue. What you should do: - For Wasp 0.16.7, use Node 18.17.0 or higher (but still within Node 18 LTS) in your Dockerfile to ensure compatibility with both Wasp and sharp. - Change your Dockerfile base image to: This version satisfies both Wasp and sharp requirements. - Make sure your Fly.io deployment is actually using your Dockerfile and not a default builder or a cached image with a different Node version. Summary:
- Wasp 0.16.7 expects Node 18.x. - sharp requires Node ^18.17.0, ^20.3.0, or >=21.0.0. - Your Dockerfile uses Node 21.7.0, but the error suggests the runtime is Node 20.0.0. - Use Node 18.18.0 in your Dockerfile for best compatibility with both Wasp 0.16.7 and sharp. If you continue to see the error, double-check that Fly.io is building and running your app with the Dockerfile you provided, and not using a remote builder with a different Node version. The knowledge sources do not provide more specific troubleshooting steps for sharp, but the Node version alignment is a well-documented requirement for Wasp deployments Node version requirement issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @silent, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
- The sharp module requires Node.js ^18.17.0, ^20.3.0, or >=21.0.0, but your Fly.io environment is using Node 20.0.0, which is not compatible. - Your Dockerfile uses Node 21.7.0, which should be compatible with sharp, but the error suggests that the runtime on Fly.io is not using this image as expected, or there is a mismatch between build and runtime environments. Relevant Wasp context:
Wasp 0.16.7 is designed to work with Node.js 18.x (>=18.12.0), and only more recent Wasp versions (from 0.12 onward) officially support Node.js >=18, including 20 and above. If you use a newer Node version (like 21.x) with Wasp 0.16.7, you may encounter compatibility issues, as Wasp itself may expect Node 18.x in some parts of the build or runtime process. This is a known source of deployment issues, especially with native modules like sharp, and is discussed in the knowledge sources Node version requirement issue. What you should do: - For Wasp 0.16.7, use Node 18.17.0 or higher (but still within Node 18 LTS) in your Dockerfile to ensure compatibility with both Wasp and sharp. - Change your Dockerfile base image to: This version satisfies both Wasp and sharp requirements. - Make sure your Fly.io deployment is actually using your Dockerfile and not a default builder or a cached image with a different Node version. Summary:
- Wasp 0.16.7 expects Node 18.x. - sharp requires Node ^18.17.0, ^20.3.0, or >=21.0.0. - Your Dockerfile uses Node 21.7.0, but the error suggests the runtime is Node 20.0.0. - Use Node 18.18.0 in your Dockerfile for best compatibility with both Wasp 0.16.7 and sharp. If you continue to see the error, double-check that Fly.io is building and running your app with the Dockerfile you provided, and not using a remote builder with a different Node version. The knowledge sources do not provide more specific troubleshooting steps for sharp, but the Node version alignment is a well-documented requirement for Wasp deployments Node version requirement issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @silent, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
@Wasp Expert let me know if theres any known solution for this.
We can't get fly to listen to what node version we want when deploying with the github action
Could you please summarise what you tried so far? Did you try providing a custom Dockerfile?
@miho Custom dockerfile, and setting node in the GitHub action.
It works manually deploying it with the fly terminal command, but not with the GitHub action
So you are using the Wasp deploy action to deploy your application and trying to set a custom Node.js in the Github action?
@miho
The github action:
The github action:
- Is the custom
Dockerfile
in the root of the Wasp project?
- Can you confirm it's in the correct place by running wasp build && ls .wasp/build -lah && cat .wasp/build/Dockerfile
in the Github Action?sorry ive been taking so long on this @miho
do i have to add that command to my github action ?
I just ran it locally and got:
ls: -lah: No such file or directory
.wasp/build:
Dockerfile package-lock.json server
db package.json src
installedNpmDepsLog.json sdk web-app