Docker error and NIXPACKS django app

henjesus
HOBBY

5 months ago

error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
:117: SyntaxWarning: invalid escape sequence '.'
Building lxml version 4.9.2.
:67: DeprecationWarning: pkgresources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkgresources.html
Building without Cython.
Error: Please make sure the libxml2 and libxslt development packages are installed.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip. I have an emergency and Docker is giving an error when installing requirements.txt, after I added the python-docx library

0 Replies

henjesus
HOBBY

5 months ago

a0fdda8e-51c2-475b-a4be-dfc1f3374dc8


5 months ago

Looks like python-docx has a few requirements that aren’t installed. You can install them using a nixpacks.toml with the package names in the “setup” step.



henjesus
HOBBY

5 months ago

sorry, I didn't understand the step by step to install


5 months ago

although, you mentioned docker error. Are you building from a Dockerfile?


5 months ago

create a nixpacks.toml file in your root directory, follow the docs to add the two packages to the “setup” section


henjesus
HOBBY

5 months ago

Aonde Where is the documentation? So I know what exactly to add to nixpacks.toml?



henjesus
HOBBY

5 months ago

I put docker error because that's what appeared in debug detail


henjesus
HOBBY

5 months ago

I've never used nicpacks, sorry, I'm lost there lol kk


5 months ago

Add this file to your root directory

1334188514849329152


5 months ago

.txt


henjesus
HOBBY

5 months ago

Thank you very much


5 months ago

it's a .toml


5 months ago

am I missing something


henjesus
HOBBY

5 months ago

Great service as always, thank you very much


5 months ago

.toml.txt

unless discord is appending .txt


5 months ago

I'm not seeing that


5 months ago

also doesn't say that on my pc, I changed the extension


5 months ago

@henriquejesus make sure the extension is .toml before you push, seems like Discord may be acting weird


henjesus
HOBBY

5 months ago

Easy, thank you very much 👏🏽👍🏽🤝🏽


henjesus
HOBBY

5 months ago

I added the file to the project root and deployed it, but I kept getting the same error. Did I forget a process?


henjesus
HOBBY

5 months ago

1334191810863693800


henjesus
HOBBY

5 months ago

1334192170260889600


5 months ago

please send your entire logs


henjesus
HOBBY

5 months ago

1334192315455242200


henjesus
HOBBY

5 months ago

1334192562549948400


henjesus
HOBBY

5 months ago

1334192670335041500


5 months ago

oh, you have a railway.json? add this code to it.

"build": {
"nixpacksConfigPath": "nixpacks.toml"
}



5 months ago

their nixpacks.toml was successfully being used already


5 months ago

Go ahead and take over if you have time Brody, i’m about to get into an hour meeting at work lol


5 months ago

Dockerfile time


5 months ago

how can you tell though?


5 months ago

woohoo


5 months ago

i can read their full logs


5 months ago

cheater


5 months ago

yeah 😦


henjesus
HOBBY

5 months ago

Do I need to keep the line: "builder": "NIXPACKS", in the build key too?


5 months ago

thats not important


5 months ago

You will need to move to a Dockerfile based build


henjesus
HOBBY

5 months ago

How do I do this?


henjesus
HOBBY

5 months ago

A fight over a package, python-docx haha


5 months ago

Writng a Dockerfile for python wouldn't be specific to Railway, so there would be many great guides for it


henjesus
HOBBY

5 months ago

Got it, I don't have any experience with Docker, unfortunately


5 months ago

its just a text file, nothing scary


henjesus
HOBBY

5 months ago

In this case, to avoid bugs, it would be good for me to imitate railway django's default docker configuration, right?


5 months ago

nope, you would want to write your own Dockerfile


henjesus
HOBBY

5 months ago

Please, is it correct?

1334197609987965000


5 months ago

good start, give it to me in text please


henjesus
HOBBY

5 months ago


5 months ago

do you need to be using daphne?


henjesus
HOBBY

5 months ago

yes, my application has websocket and is based on asgi


henjesus
HOBBY

5 months ago

is it correct? hahaha


5 months ago

close


5 months ago

do you use python 3.9 locally?


henjesus
HOBBY

5 months ago

Python 3.10.7


5 months ago

try this -

FROM python:3.10.7

ENV PYTHONFAULTHANDLER=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONHASHSEED=random
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_DEFAULT_TIMEOUT=100

RUN apt-get update && \
    apt-get install -y libxml2-dev libxslt-dev && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt ./

RUN pip install -r requirements.txt

COPY . ./

CMD daphne -b 0.0.0.0 -p $PORT seupedido.asgi:application

henjesus
HOBBY

5 months ago

Thanks. I place it in the root folder with what name and file extension?


5 months ago

just Dockerfile no extention


henjesus
HOBBY

5 months ago

thanks


henjesus
HOBBY

5 months ago

Do I need to change railway json from nixpacks to dockerfile?


henjesus
HOBBY

5 months ago

'Dockerfile Dockerfile does not exist'


5 months ago

looks like your latest build is building now


henjesus
HOBBY

5 months ago

True, it was my error corrected here


henjesus
HOBBY

5 months ago

my app on django server is not running


5 months ago

use this railway.json file -

{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "DOCKERFILE"
  },
  "deploy": {
    "preDeployCommand": "python manage.py migrate",
    "startCommand": "python manage.py collectstatic --noinput && daphne -b 0.0.0.0 -p $PORT seupedido.asgi:application",
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10
  }
}

henjesus
HOBBY

5 months ago

I exchanged $PORT for 8000 now. Is it correct?


5 months ago

leave it how i set please


henjesus
HOBBY

5 months ago

I tested with the new settings but it didn't work. Then I need to go back to an older version


henjesus
HOBBY

5 months ago

because the app cannot be taken offline hahaha


henjesus
HOBBY

5 months ago

users almost hit me via message hahaha


5 months ago

something you are doing in code is causing anything ran with manage.py to prematurely exit


henjesus
HOBBY

5 months ago

1334206843022606600


5 months ago

^


henjesus
HOBBY

5 months ago

But my manage.py code is the same as always. It appears that the daphne server is simply not starting


5 months ago

please look into that


5 months ago

i think you can use gunicorn with a uvicorn event worker for this instead of daphne


henjesus
HOBBY

5 months ago

Even with the necessary asgi and realtime tasks with websockets?


5 months ago

i think so


henjesus
HOBBY

5 months ago

Could the error be related to the app/ folder? This is my structure

1334209292185899300


5 months ago

i dont see any issues, please try gunicorn with a uvicorn event worker


henjesus
HOBBY

5 months ago

Is $PORT defined by default?


5 months ago

yes


henjesus
HOBBY

5 months ago

I don't know how to do what you told me, wouldn't there be another way I could keep using daphne?


henjesus
HOBBY

5 months ago

I'm sorry for all this inconvenience, but I'm simply very worried about what to do, since I'm having to change the structural part


5 months ago

change your start command


henjesus
HOBBY

5 months ago

In the past I needed to switch to daphne, after trying several others without success. I'm worried about needing something like this again


5 months ago

have you tried gunicorn with a uvicorn event worker?


henjesus
HOBBY

5 months ago

gunicorn seupedido.asgi:application --bind 0.0.0.0:$PORT --workers 3 --worker-class uvicorn.workers.UvicornWorker?


5 months ago

looks about right


henjesus
HOBBY

5 months ago

Unfortunately, I need to keep Daphne.


5 months ago

why is that


henjesus
HOBBY

5 months ago

I will try again later when there are fewer users.


henjesus
HOBBY

5 months ago

I put unicorn and gunicorn on and it didn't work unfortunately


5 months ago

please describe "didn't work"


henjesus
HOBBY

5 months ago

It gave the same error as last time, the server did not start


henjesus
HOBBY

5 months ago

I don't understand why the first command to start the server is not being executed


henjesus
HOBBY

5 months ago

understand?


henjesus
HOBBY

5 months ago

no error appears but it simply doesn't start the server


5 months ago

send your start script please


henjesus
HOBBY

5 months ago

Base image

FROM python:3.10.7-slim

Definir o diretório de trabalho

WORKDIR /app

Instalar dependências de sistema necessárias

RUN apt-get update && apt-get install -y \
build-essential \
libxml2-dev \
libxslt-dev \
libpq-dev \
&& apt-get clean

Copiar os arquivos de requisitos para o contêiner

COPY requirements.txt /app/

Instalar as dependências do Python

RUN pip install --no-cache-dir -r requirements.txt

COPY . /app/
RUN python manage.py collectstatic --noinput

Copiar o script de inicialização e adicionar permissão de execução

COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh

EXPOSE 8000

CMD ["./start.sh"], I solved it with a start code outside


5 months ago

thats your dockerfile not the start script


5 months ago

and please enclose in a code block


henjesus
HOBBY

5 months ago

!/bin/bash

Rodar migrações do Django

python manage.py migrate

Coletar arquivos estáticos

python manage.py collectstatic --noinput

Iniciar o servidor Daphne

daphne -b 0.0.0.0 -p 8000 seupedido.asgi:application


henjesus
HOBBY

5 months ago


5 months ago

^


Docker error and NIXPACKS django app - Railway Help Station