persistent error with building docker application
mingenbache
PROOP

9 months ago

I am unable to run my application successfully , to seed my database, or to get the authentication to work and demo my app. I have tried what i know, including using the railway CLI on my local device, to debug but i'm not able to understand what the problem is because the docker container runs locally, so does the seeding.
right now i'm getting the error

Jun 26 10:32:51

Jun 26 10:32:51

The executable bash could not be found.

Attachments

$10 Bounty

Pinned Solution

8 months ago

Replace the setup install block with this:

# Install necessary build dependencies including OpenSSL and bash
RUN apk add --no-cache \
    bash \
    python3 \
    make \
    g++ \
    git \
    openssh-client \
    openssl \
    openssl-dev

9 Replies

9 months ago

Hey there! Are you able to share any of your dockerfile here? Would like to see what its doing


9 months ago

Also depending on that, you might want to swap bash to sh


mingenbache
PROOP

8 months ago

# Use Node 20 as the base image
FROM --platform=linux/amd64 node:20-alpine

# Set working directory
WORKDIR /app

# Install necessary build dependencies including OpenSSL
RUN apk add --no-cache \
    python3 \
    make \
    g++ \
    git \
    openssh-client \
    openssl \
    openssl-dev

# Copy package files
COPY package*.json ./

# Copy prisma files first
COPY prisma ./prisma/

# Install dependencies (without postinstall script)
RUN npm install --ignore-scripts

# Generate Prisma client
RUN npx prisma generate

# Install global dependencies
RUN npm install -g typescript @types/node

# Copy the rest of the application
COPY . .

# Add this before RUN npm run build
ENV SKIP_REDIS_CONNECTION=true
ENV SKIP_ENV_VALIDATION=true

# Build the application
RUN npm run build

# Create start script
COPY <<-"EOF" /app/start.sh
#!/bin/sh
if [ -z "$DATABASE_URL" ]; then
  echo "Error: DATABASE_URL environment variable is not set"
  exit 1
fi

echo "🗄️ Checking database migrations..."
npx prisma migrate status

echo "🗄️ Applying database migrations..."
npx prisma migrate deploy || {
  echo "⚠️ Migration failed, checking if columns already exist..."
  echo "ℹ️ This might be due to columns already existing in the database"
  echo "ℹ️ Continuing with application startup..."
}

echo "⚠️ Database seeding temporarily disabled - will be run manually"
echo "ℹ️ After deployment, run: curl -X POST https://ubhubumr-production.up.railway.app/api/fix-database"
echo "ℹ️ Then run: railway run npx prisma db seed"

echo "🚀 Starting the application..."
npm start
EOF

RUN chmod +x /app/start.sh

# Expose port
EXPOSE 3000

# Start the application using the startup script
CMD ["/app/start.sh"] 

8 months ago

Replace the setup install block with this:

# Install necessary build dependencies including OpenSSL and bash
RUN apk add --no-cache \
    bash \
    python3 \
    make \
    g++ \
    git \
    openssh-client \
    openssl \
    openssl-dev

8 months ago

Hey wanted to follow up, were you able to get this working?


noahd

Replace the setup install block with this:# Install necessary build dependencies including OpenSSL and bash RUN apk add --no-cache \ bash \ python3 \ make \ g++ \ git \ openssh-client \ openssl \ openssl-dev

sim
FREE

8 months ago

Yes this looks correct to me just add bash line to the file as @error says

Accept his answer if this fixes your issue


sim
FREE

8 months ago

Alternatively use an image that already has bash
FROM --platform=linux/amd64 node:20

Non-alpine version probably has bash


sim
FREE

8 months ago

If you might want to keep it skinny

Try change the run command - this is the last line of your dockerfile to CMD ["sh", "/app/start.sh"]


Status changed to Solved chandrika 8 months ago


mingenbache
PROOP

8 months ago

Works great! thanks folks!


Status changed to Awaiting Railway Response Railway 8 months ago


Loading...