3 months ago
I need help deploying my python reflex application. It uses no database just something that makes a get and patch requests
I have my Dockerfile like so
`FROM python:3.11-slim
WORKDIR /app
ARG NODE_VERSION=20.x
Install necessary tools, Node.js, and unzip
RUN apt-get update && apt-get install -y \
curl \
gnupg \
unzip \
&& curl -fsSL https://deb.nodesource.com/setup${NODEVERSION} | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Create reflex user
RUN adduser --disabled-password --home /app reflex
Set up Python environment
RUN python -m venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH"
Copy the application files
COPY --chown=reflex:reflex . /app
Set permissions
RUN chown -R reflex:reflex /app
Switch to reflex user
USER reflex
Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
Initialize Reflex
RUN reflex init
Ensure all environment variables are set
ENV PATH="/app/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
ENV NODEPATH="/usr/lib/nodemodules"
Add health check endpoint
RUN echo 'import reflex as rx; @rx.page("/api/health"); def health(): return {"status": "ok"}' >> reflexlearning/reflexlearning.py
Expose ports for Reflex (frontend and backend)
EXPOSE 3000
EXPOSE 8000
Needed until Reflex properly passes SIGTERM on backend
STOPSIGNAL SIGKILL
Run the app in production mode
CMD ["reflex", "run", "--env", "prod"]`
the error I get is `
====================
Starting Healthcheck
====================
Path: /api/health
Retry window: 1m40s
Attempt #1 failed with service unavailable. Continuing to retry for 1m29s
Attempt #2 failed with service unavailable. Continuing to retry for 1m18s
Attempt #3 failed with service unavailable. Continuing to retry for 1m6s
Attempt #4 failed with service unavailable. Continuing to retry for 1m1s
Attempt #5 failed with service unavailable. Continuing to retry for 50s
Attempt #6 failed with service unavailable. Continuing to retry for 24s
1/1 replicas never became healthy!
Healthcheck failed!`
ⓘ Deployment information is only viewable by project members and Railway employees.
3 Replies
3 months ago
You have Healthchecks configured on your service. Healthchecks work by Railway querying your defined endpoint until it receives an HTTP 200
response.
Your service does not have Public Networking enabled and is therefore not reachable from the public internet, including by the Healthcheck, and therefore it will fail.
If you want your service to be accessible online, set up Public Networking. Alternatively, you will want to disable Healthchecks.
Read more about Public Networking and Healtchecks in the Docs.
Status changed to Awaiting User Response railway[bot] • 2 months ago
christian
You have Healthchecks configured on your service. Healthchecks work by Railway querying your defined endpoint until it receives an HTTP 200 response.Your service does not have Public Networking enabled and is therefore not reachable from the public internet, including by the Healthcheck, and therefore it will fail.If you want your service to be accessible online, set up Public Networking. Alternatively, you will want to disable Healthchecks.Read more about Public Networking and Healtchecks in the Docs.
2 months ago
Thank for this.
I don't want to set up the health checks actually I just want to build and push like that.
How do I go about that?
Status changed to Awaiting Railway Response railway[bot] • 2 months ago
2 months ago
I just checked out your latest deployment. It failed because you have not configured a start command to start the app.
Please head over to the settings of your service and specify a custom start command in the Deploy section.
Status changed to Awaiting User Response railway[bot] • 2 months ago