Django Channels with Daphne using a Dockerfile, getting 502

a year ago

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 wasinga_be.asgi:application

This is my Dockerfile

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

This is my railway.json file

Project ID
b8c2b744-36bf-47c1-9da1-b810adfbb6a8

Solved

24 Replies

a year ago

I feel like it's my lack of experience with Docker


a year ago

HTTP logs showing 502 only

1340538131442827300


a year ago

Hello,

Perhaps this docs page will help -


a year ago

thanks, will check it out


a year ago

It seems like I have done as instructed in the docs for the port problem

1340541120211587000
1340541120429424600
1340541120714772500


a year ago

Do you have a PORT variable set? y/n


a year ago

in my service? no


a year ago

let me redeploy with it set


a year ago

1340542941617459200


a year ago

I have set a port variable. The error still persists.


a year ago

what is the error reason? you can click the 502's to expand them


a year ago

1340543767215603700


a year ago

I'll give your project a quick look over when I'm back at the laptop


a year ago

alright, thanks


a year ago

your app isnt running, it says completed


a year ago

oh


a year ago

1340547289458020400


a year ago

the part about the wrapping the command in a shell is applicable now -


a year ago

i see


a year ago

also, for future reference these ultra cropped screenshots do not make it easy to help, please send full browser window screenshots


a year ago

i see. Alright


a year ago

thank you, everything works now


a year ago

sweet!


a year ago

!s


Status changed to Solved brody about 1 year ago


Loading...