Skip to content

[Bug]: Deployment fails if deployment is triggered via API (dockerfile build) #7894

@victorDigital

Description

@victorDigital

Error Message and Logs

Image
ERROR: failed to build: failed to solve: process "/bin/sh -c bun run build" did not complete successfully: exit code: 1
exit status 1
Error type: RuntimeException
Error code: 0
Location: /var/www/html/app/Traits/ExecuteRemoteCommand.php:243
Stack trace (first 5 lines):
#0 /var/www/html/app/Traits/ExecuteRemoteCommand.php(104): App\Jobs\ApplicationDeploymentJob->executeCommandWithProcess()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(271): App\Jobs\ApplicationDeploymentJob->{closure:App\Traits\ExecuteRemoteCommand::execute_remote_command():71}()
#2 /var/www/html/app/Traits/ExecuteRemoteCommand.php(71): Illuminate\Support\Collection->each()
#3 /var/www/html/app/Jobs/ApplicationDeploymentJob.php(3154): App\Jobs\ApplicationDeploymentJob->execute_remote_command()
#4 /var/www/html/app/Jobs/ApplicationDeploymentJob.php(861): App\Jobs\ApplicationDeploymentJob->build_image()
========================================
Deployment failed. Removing the new version of your application.
Gracefully shutting down build container: jgo4sgwgocgcg4kowcgkssg0

Steps to Reproduce

  1. Set up API access to Coolify version v4.0.0-beta.460
  2. Deploy a private repo via the GitHub app using dockerfile
  3. All works with manual and webhook deploys, API deploy fails consistently (see above images)

Example Repository URL

No response

Coolify Version

v4.0.0-beta.460

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 24.04.3 LTS

Additional Information

dockerfile from the deployed repo:

# Use Bun's official image
FROM oven/bun:1 AS base
WORKDIR /app

# Install dependencies into temp directory
# This will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lock /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# Install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lock /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# Copy node_modules from temp directory
# Then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# Build the project
ENV NODE_ENV=production
RUN bun run build

# Copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /app/dist dist
COPY --from=prerelease /app/package.json .

# Expose the port the app runs on
EXPOSE 4321

# Set the user to bun for security
USER bun

# Start the application
ENTRYPOINT [ "bun", "run", "dist/server/entry.mjs" ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔍 TriageIssues that need assessment and prioritization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions