I’ve a hunch I’m going to kick myself, but…

Is there a way to commit files to repo but exclude them from being deployed?

I’ve a very simple static site and deployment using Apps works fine.

However, I’d like to document the repo too and exclude those files from being deployed.

I can’t exclude them with .gitignore because I’d like them committed to the repo.

I tried .dockerignore but the files continue to be copied.

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.

Submit an Answer
1 answer

👋 @dazwilkin

Great question, when generating your static site, saving the content you want to deploy to a specific folder, called an output directory, will only deploy those files. Anything not in that folder will not get deployed.

This can be set under the static site component in your apps Components tab.

  • Aha! Great. Thank you

  • I’m unable to get this to work.

    I’ve tried moving the content to ./public (and initially not changing but then setting output_dir in the spec) and to /.www (and specifying this in the spec’s output_dir.

    Regardless of what I try, I receive deployment errors:

    Initializing build
    Retrieving source code to /workspace
    Selecting branch "master"
    Checking out commit "41d5c299..."
    Validating environment
    Building app using buildpacks
    Running buildpack detection
    ERROR: No buildpack groups passed detection.
    ERROR: Please check that you are running against the correct path.
    ERROR: failed to detect: no buildpacks participating

    I reverted to everything in the repo / and removed the output_dir to get the deployment to succeed.

    • Okay, with my first answer I made a (poor) assumption that your app was building the content. It sounds like the content is already built and staticly exists in your repo.

      In that case you’d need to set a source_dir, unfortunately this is not available in our UI yet.

      Here are some steps to get this working, I will post some links at the end with references/api.

      We want to update your existing app spec to explicitly tell App Platform where your static site lives within the repository. Let’s assume it’s in a public directory in the root of your repository.

      1. Get app spec from the settings tab of your app, eg:

        name: my-site
        - github:
        branch: master
        deploy_on_push: true
        repo: my-account/my-site
        name: my-site
        - path: /
      2. Now we will add the source_dir and save it to a file, our app spec now becomes:

        name: my-site
        - github:
        branch: master
        deploy_on_push: true
        repo: my-account/my-site
        name: my-site
        - path: /
        source_dir: public
      3. Now we need to push this change using the doctl CLI tool: doctl apps update <app_id> --spec ./my_app_spec.yaml

      Note: the appid is in the URL of your app as a UUID/GUID format, for example https://cloud.digitalocean.com/apps/1ed39f51-c095-47cc-9dcf-2fe9bda05555 the appid is 1ed39f51-c095-47cc-9dcf-2fe9bda05555

      After this your app should automatically build and deploy using the content that only exists in the public folder of your repository.

      Some links:

      We realize this is a pain and intend to add the ability to both specify a source_dir in the UI as well as update a the spec within the browser in the near future.

      Feel free to reply here if you run into trouble, or submit a support ticket and we can take a look at your particular app.

      Thanks for the great feedback :)