I have used Dockerfile to deploy a django application.
The below codes I used.
The code of Dockerfile:
ARG PYTHON_VERSION=3.10-slim-buster
ARG DEBIAN_FRONTEND=noninteractive
ARG PORT=8000
FROM python:${PYTHON_VERSION}
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /code
WORKDIR /code
#install the linux packages, since these are the dependencies of some python packages
RUN apt-get update && apt-get install -y \
libpq-dev \
gcc \
cron \
wkhtmltopdf \
&& rm -rf /var/lib/apt/lists/* !
COPY requirements.txt /tmp/requirements.txt
RUN set -ex && \
pip install --upgrade pip && \
pip install -r /tmp/requirements.txt && \
rm -rf /root/.cache/
COPY . /code
EXPOSE ${PORT}
The code of docker-compose.yaml:
version: "3.8"
services:
web:
build: .
volumes:
- .:/code
image: web:django
command: "sh /code/release.sh"
ports:
- "8000:8000"
The code of render.yaml:
services:
- type: web
name: webapp
env: python
startCommand: "sh ./code/release.sh"
The code of release.sh:
#!/usr/bin/env sh
python manage.py migrate
python manage.py collectstatic --noinput
python manage.py runserver 0.0.0.0:8000
But, when I deploy the repo in render.com it only build the image, but not executing the release.sh script. How to run the start-command (i.e., release.sh) to run the server?