Using input files with a Python app
roymeshulam
FREEOP

8 months ago

Hi team,

I developed a Python CLI app which requires 3 input files to run. Since these files are customized they are not part of the GitHub repository.

How can I install them into the deployed container? Without them, the application won't run.

Roy

Solved

3 Replies

chandrika
EMPLOYEE

8 months ago

You can use a Dockerfile to copy the input files into the container during the build process, please check out our docs on https://docs.railway.com/guides/dockerfiles


Status changed to Awaiting User Response Railway 8 months ago


chandrika

You can use a Dockerfile to copy the input files into the container during the build process, please check out our docs on https://docs.railway.com/guides/dockerfiles

roymeshulam
FREEOP

8 months ago

Thank you for the response and the link. I went through it but I wasn’t sure how should I use this functionality when I need 3 files as an input. So, let’s assume I need a.docx, b.yaml and c.cfg under the ./data folder, how would you implement it using the dockerfile?


Status changed to Awaiting Railway Response Railway 8 months ago


chandrika
EMPLOYEE

8 months ago

You'd have to create a Dockerfile that copies your input files into the container. For example:

# Use the Python 3 official image
FROM python:3

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . .

# Copy your input files into the container
COPY ./path/to/a.docx ./data/a.docx
COPY ./path/to/b.yaml ./data/b.yaml
COPY ./path/to/c.cfg ./data/c.cfg

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Run your application
CMD ["python", "./your_script.py"]

Status changed to Awaiting User Response Railway 8 months ago


Railway
BOT

4 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 4 months ago


Loading...