10 months ago
Hi everyone,
I'm experiencing issues with building my Docker container on Railway.app, which works perfectly on my local machine. I would greatly appreciate any assistance or insights from the community.
Project Details:
Base Image: Ubuntu 24.04
Python Version: 3.10
Additional Tools: Homebrew, GCC, FFmpeg
Issue Description:
The Docker build process fails when deploying to Railway.app. The same Dockerfile builds successfully on my local machine without any issues. Below is the Dockerfile I am using:
***** dockerfile ******
# Use the official Ubuntu 24.04 as the base image
FROM ubuntu:24.04
# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Set Python environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
gettext \
software-properties-common \
procps \
telnet \
wget \
gnupg \
curl \
unzip \
fonts-noto-cjk \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y \
python3.10 \
python3.10-dev \
python3.10-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Uninstall cryptography package installed by apt-get
RUN apt-get remove -y python3-cryptography
# Ensure pip is installed for Python 3.10
RUN python3.10 -m ensurepip --upgrade \
&& python3.10 -m pip install --upgrade pip
# Create a symbolic link for python3.10 as python
RUN ln -s /usr/bin/python3.10 /usr/bin/python
# Copy and install Python requirements
COPY ./requirements.txt /requirements.txt
RUN python -m pip install -r /requirements.txt
# Install Homebrew
RUN apt-get update && apt-get install -y build-essential curl file git \
&& git clone https://github.com/Homebrew/brew /home/linuxbrew/.linuxbrew \
&& mkdir -p /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core \
&& git clone https://github.com/Homebrew/homebrew-core /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core \
&& /home/linuxbrew/.linuxbrew/bin/brew config \
&& eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" \
&& echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /root/.profile
# Ensure Homebrew is in the PATH
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}"
# Install additional packages with Homebrew
RUN eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) \
&& brew install gcc ffmpeg
************************************************************************************
Error Details:
The build process fails during the execution of the Dockerfile on Railway.app with
the following error message:
************************************************************************************|
#15 1280.4 Please report this issue:
#15 1280.4 https://docs.brew.sh/Troubleshooting
#15 ERROR: process "/bin/sh -c eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) && brew install ffmpeg" did not complete successfully: exit code: 1
-----
> [11/20] RUN eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) && brew install ffmpeg:
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:411:in `install'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/upgrade.rb:237:in `install_formula'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/install.rb:350:in `install_formula'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/install.rb:301:in `block in install_formulae'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/install.rb:300:in `each'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/install.rb:300:in `install_formulae'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:297:in `run'
1280.4 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:92:in `<main>'
1280.4 Please report this issue:
1280.4 https://docs.brew.sh/Troubleshooting
-----
Dockerfile.web:88
-------------------
87 | # Install ffmpeg using Homebrew
88 | >>> RUN eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) \
89 | >>> && brew install ffmpeg
90 |
-------------------
ERROR: failed to solve: process "/bin/sh -c eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) && brew install ffmpeg" did not complete successfully: exit code: 1
************************************************************************************|
Steps Taken:
Verified the Dockerfile builds successfully on my local machine.
Reviewed the build logs on Railway.app but could not identify the exact issue.
Simplified the Dockerfile to the minimal necessary steps, yet the issue persists.
Request:
Could anyone please review the provided Dockerfile and error details and provide guidance on how to resolve the build issues on Railway.app? Any insights or recommendations would be highly appreciated.
6 Replies
10 months ago
https://bookmarklets.up.railway.app/log-downloader/
Please attach your build logs, and your Dockerfile as a file.
10 months ago
Respectfully, this Dockerfile does a lot of things suboptimally.
Using a Ubuntu image instead of a python image.
Installing python via apt-get because a Ubuntu image was used.
Running apt-get as a command multiple times when it accepts multiple packages as arguments to a single command.
Using apt-get to install the same package in different places in the Dockerfile.
Installing homebrew just to install gcc and ffmpeg when those can be installed with apt-get.
Installing Chrome and Chromedriver instead of using our browserless template.
Installing fonts and other dependencies for Chrome instead of using the browserless template.
Fix all this stuff, and your builds will work, and will be much faster.
10 months ago
Thank you for your detailed feedback !. I understand the points you've raised and appreciate the suggestions for optimization. However, I have a specific requirement to use ffmpeg from Homebrew due to certain features and compatibility issues that are critical for my project.
Would it be possible to retain the Homebrew installation for ffmpeg while implementing the other optimizations you suggested?
Thank you again for your help and understanding.
10 months ago
I'm sure there are many better ways to install your needed version of ffmpeg that don't involve homebrew, please look into that because I can not recommend you install homebrew just for ffmpeg.
10 months ago
i see. thank you so much !