Question

Dockerfile in a Django app on App Platform

Posted March 28, 2021 535 views
DockerDjangoDigitalOcean App Platform

I have a Django app that uses Docker and Docker Compose locally. I am trying to deploy to Digital Ocean App Platform.

When I setup the app the app spec automatically detects my Dockerfile. However, I get an error during deployment because the Dockerfile includes references to my local entrypoint.sh and start.sh files.

What would be the simplest way to resolve this without modifying the local Docker setup?

The deploy error:

Taking snapshot of full filesystem...        
bears-django | 14:43:10 INFO[0112] cmd: /bin/sh                                 
bears-django | 14:43:10 INFO[0112] args: [-c pip install -U pip]                
bears-django | 14:43:10 INFO[0112] Running: [/bin/sh -c pip install -U pip]     
bears-django | 14:43:10 /bin/sh: invalid option -- c
bears-django | 14:43:10 Usage: /bin/sh [option(s)] [file(s)]

Relevant part of my Dockerfile:

COPY ./entrypoint.sh /entrypoint.sh
COPY ./start.sh /start.sh

RUN chmod +x /entrypoint.sh \
    && chmod +x /start.sh

ENTRYPOINT ["/entrypoint.sh"]

###
#   Final Application Image
###
FROM py-base as py-app
RUN rm -rf /root/.cache
CMD ["/start.sh"]

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

Since your Dockerfile relies on local scripts you’ll most likely need to modify the current setup. You could modify your Django app to run natively to app platform using this tutorial. Then you would be able to test locally without docker-compose just by running it with python manage.py runserver. The other option would be to build the Dockerfile locally and upload to a container registry, either DigitalOcean Container Registry (if you want to keep the image private) or to DockerHub. From there you can deploy the container directly to App Platform.

by Mason Egger
Django is a powerful web framework that allows you to deploy your Python applications or websites. Django includes many features such as authentication, a custom database ORM, and an extensible plugin architecture. Django simplifies the complexities of web development, allowing you to focus on writing code. In this tutorial, you'll configure a Django project and deploy it to DigitalOcean's App Platform.
  • Many thanks - I was aware of the tutorial, but I was hoping to be able to modify my existing setup to run on App Platform. I’m wondering if I can just use a minimal production Dockerfile that just handles the pip installs. I’ll give this a try and report back, thanks again.