aws / apprunner-roadmap

This is the public roadmap for AWS App Runner.
https://aws.amazon.com/apprunner/
Other
298 stars 14 forks source link

Monorepo support for code deploy #162

Closed unlistedhenri closed 1 year ago

unlistedhenri commented 1 year ago

Community Note

It would be excellent to have better monorepo support - in other words, allowing us to specify a subfolder when configuring a new app runner service. While it's true that you can simply specify to cd into the folder in the configuration file before running build/start commands, I'd rather have this step set up beforehand so only that specific folder is touched.

Apologies if this has been mentioned somewhere, but haven't found anything in documentation or this roadmap. Thanks!

os1ma commented 1 year ago

It would be very useful if we could specify working directory!

As a workaround, I tried several settings. But some of the settings I could easily come up with did not work.

First, when I set cd myapp && npm start as the start command, the health check failed and I could not check the application log.

Since && may not be interpreted, next I tried sh -c 'cd myapp && npm start' as the start command. But this still resulted in a health check error. The application log showed unexpected EOF while looking for matching `''. Similarly, sh -c "cd myapp && npm start" also resulted error with unexpected EOF while looking for matching `"'.

The only way that succeeded was mv . /myapp/*; npm ci as the build command with npm start as the start command.

hariohmprasath commented 1 year ago

Hi @os1ma, I can confirm App Runner in its current state this is not possible. I understand one of the usecase here is to perform cd to a sub directory and then execute the actual start command (like npm start) specifically to support mono repo, have you come across any other usecases that can benefit by allowing this in future? If so we would love to hear about it. Thanks

unlistedhenri commented 1 year ago

We ended up not being able to use any kind of cd subfolder && start technique successfully - our build would fail every time. Instead, our "workaround" ended up being that we created a barebones Docker container for our API and deployed it separately. I would imagine having better subfolder support could potentially eliminate some of these complications. While we're more than happy with the Docker solution, I would imagine some users have a good reason for needing an alternative.

os1ma commented 1 year ago

Hi @hariohmprasath, Changing to sub directory would only help in the case of mono repo. Certainly, it is possible to create our own Docker container image as a workaround. But one of the advantage of App Runner is that we don't have to write a Dockerfile to use it. So it would be wonderful if changing to sub directory were supported. Temporarily, it would be nice if the documentation mentioned that we can't use cd with the start command, as it was difficult to troubleshoot that cd myapp && npm start didn't work.

karltaylor commented 1 year ago

Following this after a day of trying to get up and running with Source code repository. Would be extremely useful to be able to set a working dir in for monorepos / yarn workspaces. Any mention of this in the docs would also be useful, as it can't be done at the moment.

curran commented 1 year ago

I was able to get a monorepo working in App Runner with the following scripts in my package.json:

  "scripts": {
    "build": "cd app; npm run build",
    "serve": "cd app; npm run serve",
  },

Using cd in the npm scripts essentially sets the CWD.

snnles commented 1 year ago

Hello everyone, Thank you for your feedback. We are actively looking into supporting this capability in App Runner. We have some follow-up questions that will help us design this capability in a way that meets your use cases and requirements. Looking forward to your responses.

  1. What are the use cases you are using a mono-repo for?
  2. What source code repository do you use?
  3. Where do you want to deploy and run different sub-folders? All sub-folders (micro-service/app) on App Runner or some on App Runner and others on a different compute service? For example, front-end on Amplify and back-end on App Runner.
  4. How do you manage dependencies required by different sub-folders?
  5. How do you want to manage App Runner services’ update (deploy) operation when a sub-folder is updated, or a dependency is updated, or a commit is made to the repository?
  6. What is the maximum size of your mono-repos?
  7. Do you specify build, pre-build, and post-build commands that runs outside the context of the specified source folder?
  8. Where does the build command generate the compiled binaries? Is it always inside the specified source folder?
  9. How frequently are these mono repositories updated with new code across all the sub folders?
snnles commented 1 year ago

Hello everyone, Thank you for your feedback. App Runner now supports the ability to define source directory to execute build and run commands. See the What's New blog post and the deep dive blog post for more details.