W
Wasp3mo ago
scorpil

Problem building Dockerfile

Dockerfile Wasp generates contains this line:
EXPOSE ${PORT}
This is not defined as a build arg, so how can I set it? When I try to just build the image with podman build . I get this error:
Error: building at STEP "EXPOSE ${PORT}": EXPOSE requires at least one argument
1 Reply
kapa.ai
kapa.ai3mo ago
Hi @scorpil. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error occurs because the Dockerfile generated by Wasp contains the line:
EXPOSE ${PORT}
EXPOSE ${PORT}
but the PORT variable is not defined as a build argument or environment variable at build time. In Docker, the EXPOSE instruction expects a concrete port number, not a variable, unless that variable is resolved during the build process. How Wasp Handles This: - Wasp expects the PORT environment variable to be set at runtime, not at build time. The EXPOSE instruction in the Dockerfile is meant to document which port the container will listen on at runtime, but Docker does not substitute environment variables in the EXPOSE instruction during build. This is why you get the error when building with podman build .—the variable is not resolved, so the instruction is invalid. How to Fix: - You need to replace ${PORT} with a concrete port number in the Dockerfile before building the image, or ensure that the Dockerfile is generated with a specific port number instead of the variable. - Alternatively, you can set the port directly in the Dockerfile, for example: EXPOSE 3001. Wasp's Approach: - Wasp's documentation and issues indicate that the default port for the server is 3001, but it can be changed by setting the PORT environment variable at runtime, not at build time. The generated Dockerfile uses ${PORT} for flexibility, but this does not work with Docker or Podman build unless the variable is replaced with a concrete value before building the image. This is a known limitation and has been discussed in the Wasp community and issues, but there is no built-in mechanism to resolve ${PORT} at build time in the generated Dockerfile as of now Customizing the Dockerfile. Workaround: - Manually edit the generated Dockerfile to replace EXPOSE ${PORT} with EXPOSE 3001 (or your desired port) before building the image. - Or, create a custom Dockerfile in your project root as described in the docs, which will allow you to override or append to the generated Dockerfile Customizing the Dockerfile. Summary:
You cannot use ${PORT} in the EXPOSE instruction at build time. Replace it with a concrete port number before building, or customize your Dockerfile as needed. This is a known behavior in Wasp's Dockerfile generation. If you need to see the final Dockerfile Wasp generates (including any customizations), you can run:
wasp dockerfile
wasp dockerfile
to inspect and edit it as needed before building your image. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @scorpil, 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?

Did you find this page helpful?