Django Channels with Daphne using a Dockerfile, getting 502

2 years 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

2 years ago

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


2 years ago

HTTP logs showing 502 only

1340538131442827295


2 years ago

Hello,

Perhaps this docs page will help -


2 years ago

thanks, will check it out


2 years ago

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

1340541120211587093

1340541120429424700

1340541120714772591


2 years ago

Do you have a PORT variable set? y/n


2 years ago

in my service? no


2 years ago

let me redeploy with it set


2 years ago

1340542941617459310


2 years ago

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


2 years ago

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


2 years ago

1340543767215603773


2 years ago

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


2 years ago

alright, thanks


2 years ago

your app isnt running, it says completed


2 years ago

oh


2 years ago

1340547289458020412


2 years ago

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


2 years ago

i see


2 years ago

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


2 years ago

i see. Alright


2 years ago

thank you, everything works now


2 years ago

sweet!


2 years ago

!s


Status changed to Solved brody • over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...