10 months 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
10 months 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)
10 months ago
Try changing the ENTRYPOINT to -
CMD exec streamlit run app/camino.py --server.port=${PORT} --server.address=0.0.0.0
10 months 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)?
10 months ago
ENTRYPOINT ["streamlit", "run", "app/camino.py", "--server.port=${PORT}", "--server.address=0.0.0.0"]
Should this also work?
10 months 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.
10 months ago
You do not need to set a PORT environment variable with my proposed solution.
10 months ago
JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 42)
Anything of concern?
10 months ago
In the build - assume it relates to the new CMD line added to Dockerfile.
10 months 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...
10 months ago
Also this hasn't fixed the deploy :(
10 months ago
I'm also not clear on what the public URL for my app should be once deployed?
Ok - sending file.
10 months ago
Dockerfile attached.
Do I have to change the visibility to public first before creating a public URL?
Attachments
10 months ago
At this point I suspect you are running into resource limitations on the trial plan.
10 months ago
It's not that I need to remove
EXPOSE 8080
from the Dockerfile?
10 months ago
It makes no difference, the Railway platform does not do anything with that EXPOSE keyword.
10 months ago
Hmmm... anyway to understand the TRIAL limitations? It is a fairly small + simple app (I think)
10 months 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.
10 months ago
Is there a way to know how much memory my app needs?
10 months ago
Not really because your app could allocate spikes of memory that attempt to use more than what the trial plan allows for.
10 months 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.