Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENOENT: No such file or directory error during build in docker in github actions #122

Closed
IslamZaoui opened this issue May 18, 2024 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@IslamZaoui
Copy link

Hello, Im currently facing this issue in my sveltekit project

#17 [frontend 4/6] RUN bun install
#17 0.064 bun install v1.1.8 (89d25807)
#17 0.067  Resolving dependencies
#17 0.110  Resolved, downloaded and extracted [2]
#17 4.296  Saved lockfile
#17 4.296 
#17 4.296 $ paraglide-js compile --project ./project.inlang --outdir ./locales/paraglide
#17 4.534 ℹ [paraglide] Compiling inlang project at "./project.inlang".
#17 4.536 ENOENT: No such file or directory
#17 4.536    errno: -2
#17 4.536  syscall: "stat"
#17 4.536 
#17 4.536 
#17 4.536 Bun v1.1.8 (Linux x64 baseline)
#17 4.539 error: postinstall script from "myblogv2" exited with 1
#17 ERROR: process "/bin/sh -c bun install" did not complete successfully: exit code: 1

github repo of my project

@LorisSigrist LorisSigrist self-assigned this May 21, 2024
@LorisSigrist LorisSigrist added the bug Something isn't working label May 21, 2024 — with Linear
Copy link
Collaborator

Could you share the dockerfile you used for this? I can't reproduce this at the moment

@IslamZaoui
Copy link
Author

I delete the code from my repo
but here is what I wrote in that docker file:

FROM alpine:latest as downloader
ARG VERSION=0.19.4
ARG ARCH=linux_amd64
RUN wget https://github.com/pocketbase/pocketbase/releases/download/v${VERSION}/pocketbase_${VERSION}_${ARCH}.zip \
    && unzip pocketbase_${VERSION}_${ARCH}.zip -d /tmp/ \
    && chmod +x /tmp/pocketbase

FROM alpine:latest as base
WORKDIR /app
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY --from=downloader /tmp/pocketbase /app/pocketbase
EXPOSE 8090
CMD ["./pocketbase", "serve", "--http=0.0.0.0:8090"]

FROM oven/bun:1.0 as frontend
WORKDIR /app
COPY ./ ./
RUN bun install
RUN bun run build

FROM base as prod
COPY ./pocketbase/pb_hooks /app/pb_hooks
COPY ./pocketbase/pb_migrations /app/pb_migrations
COPY --from=frontend /app/build /app/pb_public

The error occurs after install

@dihmeetree
Copy link

Also have this issue. Here is my Dockerfile

# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.8
FROM oven/bun:${BUN_VERSION}-slim as base

LABEL fly_launch_runtime="SvelteKit"

# SvelteKit app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY --link bun.lockb package.json ./
RUN bun install

# Copy application code
COPY --link . .

# Build application
RUN bun --bun run build

# Remove development dependencies
RUN rm -rf node_modules && \
    bun install --ci

# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app/build /app/build
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/package.json /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "bun", "run", "start" ]

And here's the error I get
image

@LorisSigrist
Copy link
Collaborator

Everyone seems to be using bun which also doesn't run properly outside of a docker file. Does the issue still occur if you use node?

@dihmeetree
Copy link

Everyone seems to be using bun which also doesn't run properly outside of a docker file. Does the issue still occur if you use node?

Yes the issue also exists when using a node runtime as well.

@janfjohannes
Copy link

@dihmeetree can you try without the --link ?

@LorisSigrist
Copy link
Collaborator

I can only reproduce this when using bun in order to install or build. The following docker file using node directly works as expected with a SvelteKit project.

# Use the official Node.js image as a base image
FROM node:18

WORKDIR /app
COPY . .

RUN npm install
RUN npm run build

CMD ["npm", "run", "preview"]

@dihmeetree
Copy link

I can only reproduce this when using bun in order to install or build. The following docker file using node directly works as expected with a SvelteKit project.

# Use the official Node.js image as a base image
FROM node:18

WORKDIR /app
COPY . .

RUN npm install
RUN npm run build

CMD ["npm", "run", "preview"]

Thanks Loris.. gave Node another shot. It does indeed work. I maybe have been misconfiguring the Dockerfile so it couldn't find the ./project.inlang folder. Here's the final Dockerfile I ended up using for SvelteKit

FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./project.inlang .
RUN apk add --no-cache curl
RUN npm ci
COPY . .
RUN npm run build
RUN npm prune --production

FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
EXPOSE 3000
ENV NODE_ENV=production
CMD [ "node", "build" ]

@TheKinng96
Copy link

try the dockerfile below
add CMD if needed, I am having the command on docker-compose so not going to have the CMD in dockerfile

this is the workaround because paraglide js needs some APIs that bun doesnt provide and alpine image has other missing libraries that bun package needs, so ended up having the full size node image to install bun and use bun

# Step 1: Use an official Node.js image as the base image
FROM node:22 AS builder

# Install Bun
RUN npm install -g bun

# Set the working directory in the container
WORKDIR /app

# Copy package.json and bun.lockb files
COPY package.json bun.lockb ./

# Install project dependencies using Bun
RUN npx bun install

# Copy the rest of the application source code
COPY . .

# Expose the port the application will run on
EXPOSE 8080

@timootten
Copy link

Hey, is there any update for that issue?

This is my Dockerfile, that doesnt work

# Stage 1: Base image
FROM oven/bun:alpine as base

WORKDIR /usr/src/app

# Stage 2: Install dependencies
FROM base AS install
COPY package.json bun.lockb ./
RUN bun install && \
    mkdir -p /temp/dev && cp -r node_modules /temp/dev/

RUN bun install --production && \
    mkdir -p /temp/prod && cp -r node_modules /temp/prod/

# Stage 3: Prepare the release
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules ./node_modules
RUN apk add --no-cache curl
COPY . .
RUN apk add --no-cache libstdc++
RUN bun test
RUN bun run build

# Stage 4: Final release image
FROM base AS release
COPY --from=prerelease /usr/src/app/build .
RUN apk add --no-cache wget libstdc++

USER bun
EXPOSE 3000/tcp
ENTRYPOINT ["bun", "run", "start"]

@karisDev
Copy link

did anyone manage to fix it using bun?

@TheKinng96
Copy link

did anyone manage to fix it using bun?

I have my dockerfile working, see above

The bun official image doesn't have some node API that paraglide needs, a workaround is to use node image and install bun then use bun as worker

Copy link
Member

Hey everyone, I am taking over Paraglide JS again this week. I am closing this issue as the 2.0 release is the top prio atm #201

@samuelstroschein samuelstroschein closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2024
@tobyspark
Copy link

Cross-referencing the same issue in the Bun repo – oven-sh/bun#12777 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants