Question

Possible to use more than one buildpack for static site in App Platform?

Posted October 23, 2020 225 views
DigitalOcean App Platform

I was trying out App Platform to build my Jekyll blog : http://github.com/cupnoodle/mountain_goat , it requires npm to run the Gulpfile , but App Platform auto detects my repository as Jekyll site (which is correct), but I can’t add additional nodeJS buildpack and it can’t run npm command like npm run build.

Is it possible to add additional buildpack? Did I miss some configuration?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

@soulchild đź‘‹

This is possible to do today, but you’ll need to build using a Dockerfile, since we don’t yet support configuring multiple or overriding buildpacks on the App Platform.

I forked your repo and added a Dockerfile.build that looks like this:

FROM starefossen/ruby-node

ENV BUNDLER_VERSION=2.1.4
RUN gem install bundler -v ${BUNDLER_VERSION}

COPY . /app
WORKDIR /app
RUN bundle install && npm install && npm run build

We’re currently missing support in the UI for including an output_dir field that’s required for Dockerfile-based static builds, so you’ll need to submit using doctl and a spec YAML directly in the meantime. I added a .do/app.yaml file to the repo; you’ll want to use a similar one that looks like this:

name: mountain-goat
static_sites:
- name: site
  github:
    repo: cupnoodle/mountain_goat
    branch: master
    deploy_on_push: true
  dockerfile_path: Dockerfile.build
  output_dir: /app/_site

You can then create the app using doctl with:

doctl apps create --spec .do/app.yaml
  • Thanks a lot of the help and the sample code! Really appreciate it!

    I have managed to create an app using doctl apps create --spec .do/app.yaml as you said, and from the UI, the app spec is following this yaml.

    I have enabled auto-deploy on push on the UI, does it work the same way when I git push next time? or do I have to use the doctl to create-deployment for it to work for subsequent update?

Submit an Answer