V
V
Vampre2021-05-24 09:31:10
Django
Vampre, 2021-05-24 09:31:10

Why isn't docker running the command?

I want to use pipenv for django project:

# Dockerfile

FROM python:3.8-slim-buster

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

RUN apt-get update && apt-get -y install libpq-dev gcc python3-dev musl-dev netcat
 
COPY . /app

RUN pip install pip --upgrade
RUN pip install pipenv
RUN pipenv lock --keep-outdated --requirements > requirements.txt
RUN sh -c 'if [ "$MODE" = "dev" ]; then pipenv lock --dev --requirements >> requirements.txt; fi'
RUN pip install -r requirements.txt

# run entrypoint.sh
RUN chmod a+x ./shell_scripts/entrypoint.sh

ENTRYPOINT ["/app/shell_scripts/entrypoint.sh"]


I pass the MODE value through docker-compose:
# docker-compose.yml
version: "3"

services:
    app:
        container_name: app
        build: 
            context: .
            dockerfile: Dockerfile
            args:
                MODE: dev
        env_file: .env
        command: python manage.py runserver 0.0.0.0:8000
        ports:
            - 8000:8000
        depends_on:
            - db
    db:
        image: postgres:12.0-alpine
        volumes:
            - postgres_data:/var/lib/postgresql/data/
        env_file:
            - .env
volumes:
    postgres_data:


As a result, the dependencies for the development environment are not installed, that is, this command is not executed
pipenv lock --dev --requirements >> requirements.txt
what is my mistake here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-05-24
@Vampre

After FROM try adding the line ARG MODE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question