Access folder in project root from dockerfile

Hey! I have a folder for certificates /cert where I store certificates. I want to include them in the dockerfile. The issue I have is that after wasp built, this \cert folder is nowhere to be seen inside /.wasp/buildwhich makes it impossible to use inside the docker build process. Is there a way for this to work or do I have to put /cert inside the /srcfolder?
5 Replies
kapa.ai
kapa.ai3d ago
Hi @Joaquim. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To include files or folders from your project root in the Dockerfile during the Wasp build process, you have a couple of options: 1. Use a custom Dockerfile: Wasp allows you to provide your own custom Dockerfile in the project root. This Dockerfile will be used instead of the default one generated by Wasp. You can then include commands to copy your /cert folder into the Docker image. Here's how you can do it: 1. Create a Dockerfile in your project root (same level as main.wasp). 2. Copy the contents of the default Dockerfile (you can view it by running wasp dockerfile). 3. Add a COPY command to include your /cert folder. For example:
# ... (other Dockerfile contents)

COPY ./cert /app/cert

# ... (rest of the Dockerfile)

# ... (other Dockerfile contents)

COPY ./cert /app/cert

# ... (rest of the Dockerfile)

Wasp will use this custom Dockerfile when building your server as mentioned in the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/overview#customizing-the-dockerfile). 2. Move the /cert folder inside /src: If you prefer not to use a custom Dockerfile, you can move your /cert folder inside the /src directory. Wasp automatically copies the contents of the /src directory into the build folder, making it available during the Docker build process. The first option gives you more flexibility and keeps your project structure intact, while the second option is simpler but requires changing your folder structure. Remember that when using a custom Dockerfile, you'll need to ensure it remains compatible with Wasp's build process and includes all necessary steps for your app to function correctly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Joaquim, 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?
Joaquim
JoaquimOP3d ago
I don't think option 1 works because the root folder dockerfile is just appended to the built dockerfile. So, the directory of the docker build will still be .wasp/build
MEE6
MEE63d ago
Wohooo @Joaquim, you just became a Waspeteer level 1!
martinsos
martinsos3d ago
Yup, it will still end up there, in .wasp/build. However, that Dockerfile we generate is just tehre for you as a default Dockerfile -> you don't have to use it, or can use it as you like. This will depend on your deployment process, but you could have your script (e.g. in bash) that will put /certs in the right place (possibly in the folder in generated server that Dockerfile will pick up?), as part of deployment, e.g. before Dockerfile is used to create an image. Additional you could modify that Dockerfile as mentioned above. But this does depend on your dpeloyment method. What is your method, where and how are you deploying?
Joaquim
JoaquimOP2d ago
Deploying to fly.io using wasp deploy fly deploy (not launch). But yeah I guess I can run wasp build, copy the certs to .wasp/build and run wasp deploy fly deploy! This makes sense right? Thanks
Want results from more Discord servers?
Add your server