opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
22 stars 0 forks source link

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

Open IslamZaoui opened 1 month ago

IslamZaoui commented 1 month ago

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 commented 1 month ago

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

IslamZaoui commented 1 month ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

@dihmeetree can you try without the --link ?

LorisSigrist commented 3 weeks ago

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 commented 3 weeks ago

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" ]