Deployment appears to work then fails at the end after web service has gone live

mjboothaus
HOBBY

a year ago

https://github.com/DataBooth/camino-forgotten (though private)

I have successfully deployed this Python web app / repo on render.com multiple times (including the latest version that I am trying to deploy here).

Dockerfile:

```

# Use a specific tag for a more deterministic build

FROM python:3.11-slim-bullseye AS base

# Install dependencies in a single RUN and clean up apt cache to reduce image size

RUN apt-get update && apt-get install -y \

&& rm -rf /var/lib/apt/lists/*

# Create a virtual environment

ENV VIRTUAL_ENV=/opt/venv

ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install uv using pip then uv install packages in a virtual environment

RUN python -m venv $VIRTUAL_ENV \

&& $VIRTUAL_ENV/bin/pip install -U pip \

&& $VIRTUAL_ENV/bin/pip install uv

COPY requirements.txt .

RUN $VIRTUAL_ENV/bin/uv pip install --no-cache -r requirements.txt

# Use a non-root user for better security

RUN useradd -m appuser

# Create app directory and ensure appuser has full access to it

RUN mkdir /app && chown appuser:appuser /app

# Set the working directory to /app

WORKDIR /app

# Now copy the application files into /app with the correct ownership

COPY --chown=appuser:appuser .streamlit .streamlit

COPY --chown=appuser:appuser docs docs

COPY --chown=appuser:appuser app app

COPY --chown=appuser:appuser app_config.toml app_config.toml

COPY --chown=appuser:appuser COPYRIGHT.md COPYRIGHT.md

COPY --chown=appuser:appuser RELEASE_NOTES.md RELEASE_NOTES.md

# Switch to non-root user

USER appuser

EXPOSE 8080

ENTRYPOINT ["streamlit", "run", "app/camino.py", "--server.port=8080", "--server.address=0.0.0.0"]

```

31 Replies

a year ago

What's the state of the deployment when it "fails"?


mjboothaus
HOBBY

a year ago

https://docs.railway.app/guides/public-networking

Maybe I need to define the PORT variable?

Sorry I have deleted the deploy (to avoid consuming trial resources)


a year ago

Try changing the ENTRYPOINT to -

CMD exec streamlit run app/camino.py --server.port=${PORT} --server.address=0.0.0.0

mjboothaus
HOBBY

a year ago

I will try re-deploying it -- but I suspect I need to define PORT (and / or modify my code with something like):port=os.getenv("PORT", default=5000)?


a year ago

Manually defining a PORT is not the recommended method.


mjboothaus
HOBBY

a year ago

ENTRYPOINT ["streamlit", "run", "app/camino.py", "--server.port=${PORT}", "--server.address=0.0.0.0"]

Should this also work?


a year ago

No it wouldn't.


mjboothaus
HOBBY

a year ago

Trying your suggestion now - so if I wanted this to run on another service I would need to set the PORT environment variable (if I use this approach)? I am trialing Railway vs Render for now.


a year ago

You do not need to set a PORT environment variable with my proposed solution.


mjboothaus
HOBBY

a year ago

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 42)

Anything of concern?


a year ago

Where are you seeing that?


mjboothaus
HOBBY

a year ago

In the build - assume it relates to the new CMD line added to Dockerfile.


mjboothaus
HOBBY

a year ago

Starting Container

You can now view your Streamlit app in your browser.

URL: http://0.0.0.0:8080

Starting Container

You can now view your Streamlit app in your browser.

URL: http://0.0.0.0:8080

Stopping Container

Stopping...


mjboothaus
HOBBY

a year ago

Also this hasn't fixed the deploy :(


a year ago

Send your new Dockerfile, attach it as a file.


mjboothaus
HOBBY

a year ago

I'm also not clear on what the public URL for my app should be once deployed?

Ok - sending file.


a year ago

You create one in the service settings.


mjboothaus
HOBBY

a year ago

Dockerfile attached.

Do I have to change the visibility to public first before creating a public URL?

Attachments


a year ago

No you do not.


a year ago

At this point I suspect you are running into resource limitations on the trial plan.


mjboothaus
HOBBY

a year ago

It's not that I need to remove

EXPOSE 8080

from the Dockerfile?


a year ago

It makes no difference, the Railway platform does not do anything with that EXPOSE keyword.


mjboothaus
HOBBY

a year ago

Hmmm... anyway to understand the TRIAL limitations? It is a fairly small + simple app (I think)


a year ago

The main limitation would be the 500MB of memory.


mjboothaus
HOBBY

a year ago

Is there any way to test this using a less constrained machine? In my deployment on render.com it fits on the free tier happily.


mjboothaus
HOBBY

a year ago

The Railway web UI is really nice!


a year ago

You would need to upgrade to the Hobby plan for access to 8GB of memory.


mjboothaus
HOBBY

a year ago

Is there a way to know how much memory my app needs?


a year ago

Not really because your app could allocate spikes of memory that attempt to use more than what the trial plan allows for.


mjboothaus
HOBBY

a year ago

Anyway thanks so much for your responsive help today - I need to get back to my consulting work now. I'll hopefully get back to trialling later in the week. Cheers.


a year ago

Cheers.


Deployment appears to work then fails at the end after web service has gone live - Railway Help Station