Erro ao fazer deploy com django, preciso de ajuda

22.25 note: This error originates from a subprocess, and is likely not a problem with pip.
22.25 error: subprocess-exited-with-error
22.25
22.25 × Getting requirements to build wheel did not run successfully.
22.25 │ exit code: 1
22.25 ╰─> See above for output.
22.25
22.25 note: This error originates from a subprocess, and is likely not a problem with pip.

Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c set -ex && pip install --upgrade pip && pip install -r /tmp/requirements.txt && rm -rf /root/.cache/]: exit code: 1

Added Django

@Luizisrael você pode compartilhar o seu arquivo fly.toml? Você consegue construir o container localmente (docker build...)?

Oi Katia

Encaminho em anexo os arquivos solicitados

Fly.toml e Dockerfile

ARG PYTHON_VERSION=3.11-slim-bullseye

FROM python:${PYTHON_VERSION}

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN mkdir -p /code

WORKDIR /code

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

ENV SECRET_KEY “XFO1YIFyLskODoxdxTgasJ8ndhoEjmbGBgoGbp9hQPNmItBAYJ”

RUN python manage.py collectstatic --noinput

EXPOSE 8000

CMD [“gunicorn”, “–bind”, “:8000”, “–workers”, “2”, “setup.wsgi”]

Luiz Carlos Ferreira

Luizisrael2015@gmail.com

Telefone (14) 99103-3911.

(Attachment fly.toml is missing)

(Attachment Dockerfile is missing)

Oi Katia

Encaminho em anexo os arquivos solicitados

Fly.toml e Dockerfile

ARG PYTHON_VERSION=3.11-slim-bullseye

FROM python:${PYTHON_VERSION}

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN mkdir -p /code

WORKDIR /code

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

ENV SECRET_KEY “XFO1YIFyLskODoxdxTgasJ8ndhoEjmbGBgoGbp9hQPNmItBAYJ”

RUN python manage.py collectstatic --noinput

EXPOSE 8000

CMD [“gunicorn”, “–bind”, “:8000”, “–workers”, “2”, “setup.wsgi”]

Luiz Carlos Ferreira

Luizisrael2015@gmail.com

Telefone (14) 99103-3911.

(Attachment Container.rar is missing)

Oi Katia

Estou mandando os arquivos citados.

Arquivo fly.toml

fly.toml app configuration file generated for projetointegrador2024 on 2024-03-15T08:28:07-03:00

Oi Katia, tudo bem.

Fiz um deploy no site da fly.io, de um aplicativo django com banco de dados sqlite3, mas quando inicia o aplicativo não aparece a imagem da tela inicial e depois quando aparece a tela para colocar o login e senha, dá erro, dando a impressão que o aplicativo não encontra o banco de dados sqlite3. Pode me ajudar.

Luiz Carlos Ferreira

Luizisrael2015@gmail.com

Telefone (14) 99103-3911.

Oi Katia, tudo bem?

Quando login e senha, aparece estes erros. Pode me ajudar.

Preciso confirmar também se o banco de dados sqlite3 foi copiado para o fly.io. No banco de dados é que estão todos os dados de login e senha.

Proibido (403)

Verificação CSRF falhou. Pedido cancelado.

Help

Reason given for failure:

    Origin checking failed - [https://biblioteca2024.fly.dev](https://biblioteca2024.fly.dev) does not match any trusted origins.
    

In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django’s CSRF mechanism has not been used correctly. For POST forms, you need to ensure:

  • Your browser is accepting cookies.
  • The view function passes a request to the template’s render method.
  • In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.
  • If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.
  • The form has a valid CSRF token. After logging in in another browser tab or hitting the back button after a login, you may need to reload the page with the form, because the token is rotated after a login.

You’re seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.

You can customize this page using the CSRF_FAILURE_VIEW setting.

Arquivo dockerfile

ARG PYTHON_VERSION=3.11-slim-bullseye

FROM python:${PYTHON_VERSION}

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN mkdir -p /code

WORKDIR /code

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

ENV SECRET_KEY “9X798LmLMnDEXqDqa1Tu53xibMP7mAK3DqAVrBZVKujU4KrVXn”

RUN python manage.py collectstatic --noinput

EXPOSE 8000

CMD [“gunicorn”, “–bind”, “:8000”, “–workers”, “2”, “setup.wsgi”]

OperationalError at /admin/login/

no such table: auth_user

Oi, @Luizisrael , tudo bem?

O fórum, que é aberto a todos os usuários do Fly.io, é a única maneira de obter suporte com o plano Hobby. Você já enviou algumas coisas aqui, então vou te dar algumas recomendações:

  • Como a maior parte das pessoas que utilizam e leem o fórum falam inglês, talvez você receba mais ajuda escrevendo em inglês ou tentando traduzir.
  • Por ser um fórum público, tenha cuidado com as informações enviadas para cá. Incluindo alguns dos dados que você forneceu nas mensagens acima.

Eu não sei te ajudar sobre Django, vim mandar a mensagem para te auxiliar nas coisas que falei acima mesmo. Espero que consiga resolver.

Oi @Luizisrael !

Obrigada por compartilhar o Dockerfile!

Como o @Nigro comentou, cuidado ao compartilhar secrets (por exemplo, ENV SECRET_KEY “9X798LmLMnDEXqDqa1Tu53xibMP7mAK3DqAVrBZVKujU4KrVXn”). Tente sempre ocultar esse tipo de informação quando for compartilhar por aqui ou em qualquer outro lugar público. Se estiver usando essa secret em produção (ou mesmo local), recomendo gerar uma SECRET_KEY nova.

Bom, vamos lá.

O que quer dizer com dados do sqlite3 foram copiados para o Fly.io? Vc migrou dados de algum lugar para produção?
Se sim, como fez isso?

Parece que as tabelas não foram geradas. Como você está aplicando as migrações? Automaticamente ou manualmente a cada deploy?
Não consegui encontrar o seu fly.toml file.

Você adicionou no seu settings.py o CSRF_TRUSTED_ORIGINS?

CSRF_TRUSTED_ORIGINS = ['https://biblioteca2024.fly.dev']

Recomendo dar uma olhada nesse blog post com várias dicas importantes de como preparar todo o seu projeto Django antes de fazer o deploy. :slightly_smiling_face:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.