Docker error and NIXPACKS django app
henjesus
HOBBYOP

a year 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

107 Replies

henjesus
HOBBYOP

a year ago

a0fdda8e-51c2-475b-a4be-dfc1f3374dc8


a year 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
HOBBYOP

a year ago

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


a year ago

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


a year ago

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


henjesus
HOBBYOP

a year ago

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



henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year ago

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


a year ago

Add this file to your root directory

1334188514849329152


a year ago

.txt


henjesus
HOBBYOP

a year ago

Thank you very much


a year ago

it's a .toml


a year ago

am I missing something


henjesus
HOBBYOP

a year ago

Great service as always, thank you very much


a year ago

.toml.txt

unless discord is appending .txt


a year ago

I'm not seeing that


a year ago

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


a year ago

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


henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year 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
HOBBYOP

a year ago

1334191810863693800


henjesus
HOBBYOP

a year ago

1334192170260889600


a year ago

please send your entire logs


henjesus
HOBBYOP

a year ago

1334192315455242200


henjesus
HOBBYOP

a year ago

1334192562549948400


henjesus
HOBBYOP

a year ago

1334192670335041500


a year ago

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

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



a year ago

their nixpacks.toml was successfully being used already


a year ago

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


a year ago

Dockerfile time


a year ago

how can you tell though?


a year ago

woohoo


a year ago

i can read their full logs


a year ago

cheater


a year ago

yeah 😦


henjesus
HOBBYOP

a year ago

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


a year ago

thats not important


a year ago

You will need to move to a Dockerfile based build


henjesus
HOBBYOP

a year ago

How do I do this?


henjesus
HOBBYOP

a year ago

A fight over a package, python-docx haha


a year ago

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


henjesus
HOBBYOP

a year ago

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


a year ago

its just a text file, nothing scary


henjesus
HOBBYOP

a year ago

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


a year ago

nope, you would want to write your own Dockerfile


henjesus
HOBBYOP

a year ago

Please, is it correct?

1334197609987965000


a year ago

good start, give it to me in text please


henjesus
HOBBYOP

a year ago


a year ago

do you need to be using daphne?


henjesus
HOBBYOP

a year ago

yes, my application has websocket and is based on asgi


henjesus
HOBBYOP

a year ago

is it correct? hahaha


a year ago

close


a year ago

do you use python 3.9 locally?


henjesus
HOBBYOP

a year ago

Python 3.10.7


a year 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
HOBBYOP

a year ago

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


a year ago

just Dockerfile no extention


henjesus
HOBBYOP

a year ago

thanks


henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year ago

'Dockerfile Dockerfile does not exist'


a year ago

looks like your latest build is building now


henjesus
HOBBYOP

a year ago

True, it was my error corrected here


henjesus
HOBBYOP

a year ago

my app on django server is not running


a year 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
HOBBYOP

a year ago

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


a year ago

leave it how i set please


henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year ago

because the app cannot be taken offline hahaha


henjesus
HOBBYOP

a year ago

users almost hit me via message hahaha


a year ago

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


henjesus
HOBBYOP

a year ago

1334206843022606600


a year ago

^


henjesus
HOBBYOP

a year ago

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


a year ago

please look into that


a year ago

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


henjesus
HOBBYOP

a year ago

Even with the necessary asgi and realtime tasks with websockets?


a year ago

i think so


henjesus
HOBBYOP

a year ago

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

1334209292185899300


a year ago

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


henjesus
HOBBYOP

a year ago

Is $PORT defined by default?


a year ago

yes


henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year 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


a year ago

change your start command


henjesus
HOBBYOP

a year 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


a year ago

have you tried gunicorn with a uvicorn event worker?


henjesus
HOBBYOP

a year ago

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


a year ago

looks about right


henjesus
HOBBYOP

a year ago

Unfortunately, I need to keep Daphne.


a year ago

why is that


henjesus
HOBBYOP

a year ago

I will try again later when there are fewer users.


henjesus
HOBBYOP

a year ago

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


a year ago

please describe "didn't work"


henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year ago

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


henjesus
HOBBYOP

a year ago

understand?


henjesus
HOBBYOP

a year ago

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


a year ago

send your start script please


henjesus
HOBBYOP

a year 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


a year ago

thats your dockerfile not the start script


a year ago

and please enclose in a code block


henjesus
HOBBYOP

a year 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
HOBBYOP

a year ago


a year ago

^


Loading...