title: Docker-Compose + Command
body: <p>It seems my docker-compose commands only execute the last command. In this case runserver.</p>
  
  <pre><code>command: python3 manage.py collectstatic --noinput
  command: python3 manage.py migrate --noinput
  command: python3 manage.py runserver 0.0.0.0:8000
  </code></pre>
  
  <p>I tried to move these commands into an entrypoint.sh file. However, I can't figure out how to implement this into my dockerfile &amp; docker-compose. </p>
  
  <p>The following is my dockerfile:</p>
  
  <pre><code># Pull base image
  FROM python:3
  
  # Set environment varibles
  ENV PYTHONUNBUFFERED 1
  
  # Set work directory
  RUN mkdir /code
  WORKDIR /code
  
  # Install dependencies
  RUN pip install --upgrade pip
  RUN pip install pipenv
  COPY ./Pipfile /code/Pipfile
  RUN pipenv install --deploy --system --skip-lock --dev
  
  # Copy project
  COPY . /code/
  </code></pre>
  
  <p>My docker-compose:</p>
  
  <pre><code>version: '3'
  
  services:
    db:
      image: postgres
      ports:
        - "5432:5432"
    web:
      build: .
      command: python3 manage.py collectstatic --noinput
      command: python3 manage.py migrate --noinput
      command: python3 manage.py runserver 0.0.0.0:8000
      env_file: .env
      volumes:
        - .:/code
      ports:
        - "8000:8000"
      depends_on:
        - db
  </code></pre>
  
  <p>entrypoint.sh</p>
  
  <pre><code>#!/bin/bash
  
  # Collect static files
  echo "Collect static files"
  python manage.py collectstatic --noinput
  
  # Apply database migrations
  echo "Apply database migrations"
  python manage.py migrate
  
  # Start server
  echo "Starting server"
  python manage.py runserver 0.0.0.0:8000
  </code></pre>