Trying to install wasp within a docker image, and it always fail

I am trying to install wasp within a docker image (to subsequently build the client app). But wasp version command keeps failing. Here is my dockerfile for reference. Can someone help me spot my mistake
FROM node:22.6.0-slim AS build

RUN apt-get update -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install npm curl bash -y
RUN node -v

# install wasp
RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh
ENV PATH="$PATH:/root/.local/bin"

# Set working directory
WORKDIR /app

COPY . /app

RUN wasp version

# Same as npm install
RUN REACT_APP_API_URL=http://localhost:3001 npm run build
FROM node:22.6.0-slim AS build

RUN apt-get update -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install npm curl bash -y
RUN node -v

# install wasp
RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh
ENV PATH="$PATH:/root/.local/bin"

# Set working directory
WORKDIR /app

COPY . /app

RUN wasp version

# Same as npm install
RUN REACT_APP_API_URL=http://localhost:3001 npm run build
29 Replies
kapa.ai
kapa.ai5mo ago
Hi @abhinav3295. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The issue might be related to the Node.js version you are using in your Dockerfile. In the knowledge sources, it is mentioned that Wasp is currently specifying Node 14 in their Dockerfile and they have upgraded it to Node 16 (source (https://github.com/wasp-lang/wasp/issues/667)). However, in your Dockerfile, you are using Node 22.6.0-slim. This could potentially be the cause of the issue. Here is the updated Dockerfile with Node 16:
FROM node:16-alpine AS build

RUN apk update && apk add curl bash
RUN node -v

# install wasp
RUN curl -sSL <https://get.wasp-lang.dev/installer.sh> | sh
ENV PATH="$PATH:/root/.local/bin"

# Set working directory
WORKDIR /app

COPY . /app

RUN wasp version

# Same as npm install
RUN REACT_APP_API_URL=<http://localhost:3001> npm run build


# 2. For Nginx setup
FROM nginx:alpine

WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets from builder stage
COPY --from=build /app/build .

# Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]
FROM node:16-alpine AS build

RUN apk update && apk add curl bash
RUN node -v

# install wasp
RUN curl -sSL <https://get.wasp-lang.dev/installer.sh> | sh
ENV PATH="$PATH:/root/.local/bin"

# Set working directory
WORKDIR /app

COPY . /app

RUN wasp version

# Same as npm install
RUN REACT_APP_API_URL=<http://localhost:3001> npm run build


# 2. For Nginx setup
FROM nginx:alpine

WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets from builder stage
COPY --from=build /app/build .

# Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]
Please note that the apk package manager is used instead of apt-get because the base image is now Alpine Linux. If you still encounter issues, it might be helpful to check the installation logs or any error messages that appear during the build process. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @abhinav3295, 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?
abhinav3295
abhinav3295OP5mo ago
What you are referring to is older documentation, in the latest version its recommended to use node version higher than 18 and the code samples in the installation guide uses node v.20
miho
miho5mo ago
Yep, Kapa made a mistake here. Let me see what's up. 😄 Here's what worked for me:
FROM --platform=linux/amd64 node:22.6.0-slim AS build

RUN apt update && apt install -y curl

RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh

ENV PATH="/root/.local/bin:${PATH}"

WORKDIR /app

COPY . /app

RUN wasp build

RUN cd .wasp/build/web-app && npm run build
FROM --platform=linux/amd64 node:22.6.0-slim AS build

RUN apt update && apt install -y curl

RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh

ENV PATH="/root/.local/bin:${PATH}"

WORKDIR /app

COPY . /app

RUN wasp build

RUN cd .wasp/build/web-app && npm run build
I had to add --platform=linux/amd64 because I'm building it on Mac M2.
abhinav3295
abhinav3295OP5mo ago
Thanks @miho can you please also tell me how can I enable debugging for the wasp server content? I am trying to connect (vscode) debugger to server using the processed *processId On server logs I see that the debugger is connected, but none of the breakpoints work Any suggestions (I am fairly new to nodejs)
DaniO
DaniO5mo ago
Hey, I am also trying to run that on my M3. Tried your dockerfile until the COPY part, but i am getting the following error:
root@6b2e2536a024:/app# wasp new MyApp

? --- Creating your project from the "basic" template... -------------------------

Created new Wasp app in ./MyApp directory!

To run your new app, do:
cd MyApp
wasp start

root@6b2e2536a024:/app# cd MyApp/
root@6b2e2536a024:/app/MyApp# wasp start

? --- Starting compilation and setup phase. Hold tight... ------------------------


? --- Compiling wasp project... --------------------------------------------------

/root/.local/bin/wasp: line 2: 40 Segmentation fault waspc_datadir=/root/.local/share/wasp-lang/0.14.0/data /root/.local/share/wasp-lang/0.14.0/wasp-bin "$@"
root@6b2e2536a024:/app# wasp new MyApp

? --- Creating your project from the "basic" template... -------------------------

Created new Wasp app in ./MyApp directory!

To run your new app, do:
cd MyApp
wasp start

root@6b2e2536a024:/app# cd MyApp/
root@6b2e2536a024:/app/MyApp# wasp start

? --- Starting compilation and setup phase. Hold tight... ------------------------


? --- Compiling wasp project... --------------------------------------------------

/root/.local/bin/wasp: line 2: 40 Segmentation fault waspc_datadir=/root/.local/share/wasp-lang/0.14.0/data /root/.local/share/wasp-lang/0.14.0/wasp-bin "$@"
Any idea? 🙂
miho
miho5mo ago
The output doesn't look like you are building the Docker image, how are you running this?
DaniO
DaniO4mo ago
I built a docker image until COPY, then i started a container with that image and did the rest manually (for testing) @miho ping 🙂
MEE6
MEE64mo ago
Wohooo @DaniO, you just became a Waspeteer level 1!
miho
miho4mo ago
Can you provide me with code and command so I can do the same thing as you did? I want to be able to reproduce the issue on my machine so I can help better 🙂
DaniO
DaniO4mo ago
@miho I have the following Dockerfile:
FROM --platform=linux/amd64 node:22.6.0-slim AS build

RUN apt update && apt install -y curl

RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh

ENV PATH="/root/.local/bin:${PATH}"

WORKDIR /app
FROM --platform=linux/amd64 node:22.6.0-slim AS build

RUN apt update && apt install -y curl

RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh

ENV PATH="/root/.local/bin:${PATH}"

WORKDIR /app
Then I ran docker build -t wasp . and docker run --rm -it wasp bash Inside the container i executed:
wasp new MyApp
cd MyApp
wasp start
wasp new MyApp
cd MyApp
wasp start
Which results into the following error:
? --- Starting compilation and setup phase. Hold tight... ------------------------


? --- Compiling wasp project... --------------------------------------------------

/root/.local/bin/wasp: line 2: 37 Segmentation fault waspc_datadir=/root/.local/share/wasp-lang/0.14.0/data /root/.local/share/wasp-lang/0.14.0/wasp-bin "$@"
? --- Starting compilation and setup phase. Hold tight... ------------------------


? --- Compiling wasp project... --------------------------------------------------

/root/.local/bin/wasp: line 2: 37 Segmentation fault waspc_datadir=/root/.local/share/wasp-lang/0.14.0/data /root/.local/share/wasp-lang/0.14.0/wasp-bin "$@"
If I can provide more info just ping me please 🙂 --- Edit: This seems to only be a problem with my Macbook. I started a redhat VM and executed the same commands, there it worked 😄 I built it once with linux/amd64 and once with linux/arm64. With ARM I am getting:
root@5aff1037fe82:/app# wasp new MyApp
rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
/root/.local/bin/wasp: line 2: 10 Trace/breakpoint trap waspc_datadir=/root/.local/share/wasp-lang/0.14.0/data /root/.local/share/wasp-lang/0.14.0/wasp-bin "$@"
root@5aff1037fe82:/app# wasp new MyApp
rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
/root/.local/bin/wasp: line 2: 10 Trace/breakpoint trap waspc_datadir=/root/.local/share/wasp-lang/0.14.0/data /root/.local/share/wasp-lang/0.14.0/wasp-bin "$@"
miho
miho4mo ago
Gotcha! Thanks for the instructions, I'll try it tomorrow on my Mac 👍 Doing the same steps works on my machine 🫠 I ran it like this docker run --rm -p 3000:3000 -p 3001:3001 -it wasp bash to expose the ports. I got this error since Vite can't open the browser automatically:
[ Client!] Error: spawn xdg-open ENOENT
[ Client!] at ChildProcess._handle.onexit (node:internal/child_process:286:19)
[ Client!] at onErrorNT (node:internal/child_process:484:16)
[ Client!] at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
[ Client!] Error: spawn xdg-open ENOENT
[ Client!] at ChildProcess._handle.onexit (node:internal/child_process:286:19)
[ Client!] at onErrorNT (node:internal/child_process:484:16)
[ Client!] at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
but that's okay. I think the trick is in the choice of the Node image:
node:<version>-slim
This image does not contain the common packages contained in the default tag and only contains the minimal packages needed to run node. Unless you are working in an environment where only the node image will be deployed and you have space constraints, we highly recommend using the default image of this repository.
node:<version>-slim
This image does not contain the common packages contained in the default tag and only contains the minimal packages needed to run node. Unless you are working in an environment where only the node image will be deployed and you have space constraints, we highly recommend using the default image of this repository.
Try not using the slim variant maybe?
miho
miho4mo ago
No description
DaniO
DaniO4mo ago
Thanks a lot! But argh - tried it with bookworm, bullseye and alpine - still failing. For some strange reason it fails later, if I rerun it. The logfile is the output from node:22.6.0-bullseye Any other idea? 😬
miho
miho4mo ago
@martinsos how could we debug the waspc next? I'm not sure what to suggest. TLDR: running wasp start in a Docker container results in 310 Segmentation fault
DaniO
DaniO4mo ago
@miho i don't get why it is working for you, but not for me. Do i maybe have some setting set wrong?
miho
miho4mo ago
I'm using MacOS 14 with M2 Pro chip with OrbStack https://orbstack.dev/ (this is just a nicer Docker Desktop, but it might influence the result) and I did the same thing as you did 🤷‍♂️ Why do you want to run Wasp in a Docker container? Can you maybe install Wasp directly on your machine?
OrbStack
OrbStack · Fast, light, simple Docker & Linux on macOS
Say goodbye to slow, clunky containers and VMs. The fast, light, and easy way to run containers and Linux. Develop at lightspeed with our Docker Desktop alternative.
DaniO
DaniO4mo ago
It's a company notebook and I don't wanna pollute it to much 😄 I will start a cloud server and do it with remote development, if we can't find a solution here 🙂 Also tried it now with the raspberry PI - direct install, without docker. Same result 😄
martinsos
martinsos4mo ago
It will likely have to do with some deps missing on the machine it is running on -> either unexpected architecture, or missing/wrong deps (like glibc). Although I wouldnt' neccessarily expect it to manifest as segmentation fault (although it might). The thing is, the Linux binary for Wasp is built on Ubuntu. Which doesn't guarantee it will work on other Linux distributions, although it often does. We will likely want to produce static binary in the future, so it doesn't depends on stuff like glibc, but we are not doing it yet. Or we could produce binaries for different popular dists. What you can do right now @DaniO is try to run it in a docker that is based on Ubuntu, and see if that helps. If not, then it has to be connect to you running this from mac with M3 hm. @miho as for how to get more info from waspc -> here are a couple of general solutions: 1. Run wasp with gdb and then backtrace 2. Add +RTS -xc, like wasp +RTS -xc, it might show more info. (ok this solution is haskell specific) 3. Try gdb wasp core in case there is a core dump generated on the machine.
DaniO
DaniO4mo ago
@martinsos I tried it with the ubuntu baseimage and had the same result.
martinsos
martinsos4mo ago
@DaniO thanks for persisting! Since we had no other complaints so far + @miho wasn't able to replicate it on hiw M2 mac, and you also got it working on RedHat, we concluded this is connected to your Mac, and most likely the fact it uses M3. @miho do we have anybody in the team with M3, so that we can try to reproduce this? And just to be clear, what is the simplest way to try to reproduce this: on M3, trying to run Wasp inside simple Dockerfile. Btw @DaniO , I think I never asked -> did you manage toget Wasp wokring directly on your machine, without Dockerfile? Just wasp start?
DaniO
DaniO4mo ago
@martinsos No problem, happy to help. As I already mentioned, I can work around this by using a ubuntu vm. Yes wasp start is working, without any problems.
miho
miho4mo ago
I would bet that there shouldn't be differences between M2 and M3 macs in this regard. Also, probably we have other users with M3 macs since they are not new new and people got macs with them. I'm not sure where to point my finger next 🤷‍♂️
martinsos
martinsos4mo ago
OK yeah and it does work direclty on M3! Wow that is unusal then indeed.
DaniO
DaniO4mo ago
Maybe it is my mac setup, but i can't remember setting anything different. i also tried to build it with different platforms (amd/arm). Also had the same issue trying it with a raspberry pi 4 (OS: Debian GNU/Linux 12 (bookworm)) and tried to run wasp there directly.
daniel@homelab:~/programming $ wasp new MyApp
/home/daniel/.local/bin/wasp: line 2: /home/daniel/.local/share/wasp-lang/0.14.1/wasp-bin: cannot execute binary file: Exec format error
daniel@homelab:~/programming $ wasp new MyApp
/home/daniel/.local/bin/wasp: line 2: /home/daniel/.local/share/wasp-lang/0.14.1/wasp-bin: cannot execute binary file: Exec format error
MEE6
MEE64mo ago
Wohooo @DaniO, you just became a Waspeteer level 2!
martinsos
martinsos4mo ago
Ok hm. Keep in mind taht we build wasp binaries on Ubuntu (x86_64) and on Mac. Github Actions is here: https://github.com/wasp-lang/wasp/blob/main/.github/workflows/waspc-ci.yaml. So if Raspberry pi uses arm64, taht might be the resason, we probably download the linux binary but it is built for x86_64
martinsos
martinsos4mo ago
Ok actually just found this GH issue of ours, it mentions taht Wasp doesn't work on Raspbian due to this: https://github.com/wasp-lang/wasp/issues/2003
GitHub
Investigate building Wasp for more Linux architectures (i.e. ARM) ·...
Currently (as of 0.13.2), we're releasing Wasp Linux builds only for Ubuntu x86. It works on most of the Linux distribution, but not all of them (e.g., Raspbian). For users that don't run a...
martinsos
martinsos4mo ago
@abhinav3295 maybe I will say something silly now, but what if you ran this Dockerfile on your M3 via Rosetta? Woudl that make sense? I don't have much expreince with Mac so let me know if this makes no sense Ah yes but it works directly on M3, keep forgetting that, ok than probably that won't help hm.
Want results from more Discord servers?
Add your server