Error adding static site for staticfiles with a dockerfile.

Posted April 10, 2021 403 views
PythonDjangoPython FrameworksDevelopmentDigitalOcean App Platform

I was deploying the staticfiles static site and received this error:

when combined with dockerfilepath, outputdir “staticfiles” must be an absolute path

Does anyone know how to determine the absolute path to use?

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

Hello @adamFire

You can set the output directory the same as the “STATIC_ROOT” setting in If you are following the documentation which is linked in your question then you can set the output directory as “staticfiles” and it should work.

If you are experiencing any issues then please reach out to support team.


  • Thanks for the response. I tried various absolute paths like /usr/src/app/staticfiles without any success.

    I also tried to collect statics to a DO space, which almost worked but the urls would not line up correctly and I could not get AWSDEFAULTACL=public-read to work. I was using a combination of these pages as a reference:

    I ended up creating a new git repo to collect my static files into and deployed that as a static html site. This solution is not ideal but it is working.


    • Hi @adamFire,

      Your build is using the Dockerfile that is in your repo, but the tutorial uses the Python buildpack instead. When using a Dockerfile to build a static site, the Dockerfile must compile all assets during the build and you must also provide the full path to the built assets within the container image.

      I assume you actually want to use the Python buildpack like the tutorial. To do that, navigate to your app, click the Settings tab, and then download the App Spec. Remove the dockerfile_path: Dockerfile line from your Django component and then upload the new spec.

      This will instruct App Platform to not use the Dockerfile to build your app but rather the Python buildpack. For more info on the build system please see this page:

      Another option is to rename the Dockerfile in your repo to for example. Then, re-create your component or app. Without a Dockerfile file at the root of the repo, the auto detection process will use buildpacks.

      Let me know if that works!

      • Hey @kamaln7,

        Thanks for the reply. I do want to use my own Dockerfile because I needed some additional packages, like GDAL, that were not available in the buildpak.

        However, you did point me in the right direction. In my dockerfile, I just needed to add a line to run collectstatic during the build process and set the output directory to /usr/src/app/staticfiles

        Thanks for the help!