1
resposta

Docker compose up não funciona

Após a execução do build, o comando docker-compose up dá o seguinte erro:

app_1  | Traceback (most recent call last):
app_1  |   File "manage.py", line 21, in <module>
app_1  |     main()
app_1  |   File "manage.py", line 17, in main
app_1  |     execute_from_command_line(sys.argv)
app_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
app_1  |     utility.execute()
app_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 325, in execute
app_1  |     settings.INSTALLED_APPS
app_1  |   File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__
app_1  |     self._setup(name)
app_1  |   File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup
app_1  |     self._wrapped = Settings(settings_module)
app_1  |   File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__
app_1  |     mod = importlib.import_module(self.SETTINGS_MODULE)
app_1  |   File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
app_1  |     return _bootstrap._gcd_import(name[level:], package, level)
app_1  |   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
app_1  |   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
app_1  |   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
app_1  |   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
app_1  |   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
app_1  |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
app_1  |   File "/src/controle_estoque/settings.py", line 12, in <module>
app_1  |     ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[], cast=Csv())
app_1  |   File "/usr/local/lib/python3.7/site-packages/decouple.py", line 199, in __call__
app_1  |     return self.config(*args, **kwargs)
app_1  |   File "/usr/local/lib/python3.7/site-packages/decouple.py", line 83, in __call__
app_1  |     return self.get(*args, **kwargs)
app_1  |   File "/usr/local/lib/python3.7/site-packages/decouple.py", line 77, in get
app_1  |     return cast(value)
app_1  |   File "/usr/local/lib/python3.7/site-packages/decouple.py", line 234, in __call__
app_1  |     return self.post_process(transform(s) for s in splitter)
app_1  |   File "/usr/local/lib/python3.7/site-packages/decouple.py", line 234, in <genexpr>
app_1  |     return self.post_process(transform(s) for s in splitter)
app_1  |   File "/usr/local/lib/python3.7/shlex.py", line 299, in __next__
app_1  |     token = self.get_token()
app_1  |   File "/usr/local/lib/python3.7/shlex.py", line 109, in get_token
app_1  |     raw = self.read_token()
app_1  |   File "/usr/local/lib/python3.7/shlex.py", line 140, in read_token
app_1  |     nextchar = self.instream.read(1)
app_1  | AttributeError: 'list' object has no attribute 'read'
controle-de-estoque-docker_app_1 exited with code 1

Segue o código:

DOCKERFILE:

FROM python:3.7-slim

LABEL maintainer='Raphael Mendonça'

ENV PYTHONUNBEFFERED 1

ARG SECRET_KEY_ARG
ARG ALLOWED_HOST_ARG
ARG DEBUG_ARG
ARG REQUIREMENTS_ARG=requirements.txt

ENV SECRET_KEY=${SECRET_KEY_ARG}
ENV ALLOWED_HOST=${ALLOWED_HOST_ARG}
ENV DEBUG=${DEBUG_ARG}

COPY ./requirements.txt /requirements.txt
COPY ./requirements-dev.txt /requirements-dev.txt

RUN apt update && apt install -y libjpeg-dev python3-dev build-essential

RUN mkdir /src
WORKDIR /src

RUN pip install pip --upgrade && pip install -r /${REQUIREMENTS_ARG}

DOCKER COMPOSE:

version : '3'

services:
  app:
    build:
      context: .
      args:
        - DEBUG_ARG=true
        - ALLOWED_HOSTS_ARGS=127.0.0.1,localhost
        - SECRET_KEY_ARG=CHAVENAOSEGURA
        - REQUIREMENTS_ARG=requirements-dev.txt
    ports:
    - 8000:8000
    command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
    volumes:
    - ./src:/src
1 resposta

Oi Raphael desculpe a demora,

Aparentemente ele não reconheceu o seu argumento, tente executar o comando abaixo primeiro:

docker-compose build --no-cache