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

Create changelog docs for latest release - Docker build fail after v1.5.6 release #2198

Closed
adarshaacharya opened this issue Oct 11, 2022 · 13 comments · Fixed by #2212
Closed

Comments

@adarshaacharya
Copy link
Contributor

adarshaacharya commented Oct 11, 2022

Describe the feature you'd like to request

Due to latest v1.5.6 release of turborepo, docker build is failing but can't figure out what's the exact issue. Since last changelog released was for v1.5.1, please create new one with changes made and breaking changes if there are any.

I've got following error

RUN yarn global add turbo
 Fetching packages...
Linking dependencies...
 Building fresh packages...
error /usr/local/share/.config/yarn/global/node_modules/turbo: Command failed.
Exit code: 1

Describe the solution you'd like

creating changelog after each release

Describe alternatives you've considered

@adarshaacharya adarshaacharya changed the title Create changelog docs for latest release Create changelog docs for latest release -docker build fail after v1.5.6 release Oct 11, 2022
@IkeLutra
Copy link

I believe it is a bug in the postinstall script.
Here is a more detailed log from installation: npm install --no-update-notifier --no-fund --global pnpm turbo

121 verbose pkgid turbo@1.5.6
122 verbose cwd /
123 verbose Linux 5.10.104-linuxkit
124 verbose node v16.17.1
125 verbose npm  v8.15.0
126 error code 1
127 error path /usr/local/lib/node_modules/turbo
128 error command failed
129 error command sh /tmp/postinstall-e52d70af.sh
130 error node:internal/errors:477
130 error     ErrorCaptureStackTrace(err);
130 error     ^
130 error
130 error <ref *1> Error: spawnSync /usr/local/lib/node_modules/turbo/bin/turbo ENOENT
130 error     at Object.spawnSync (node:internal/child_process:1112:20)
130 error     at spawnSync (node:child_process:827:24)
130 error     at Object.execFileSync (node:child_process:870:15)
130 error     at validateBinaryVersion (/usr/local/lib/node_modules/turbo/install.js:25:6)
130 error     at /usr/local/lib/node_modules/turbo/install.js:308:5 {
130 error   errno: -2,
130 error   code: 'ENOENT',
130 error   syscall: 'spawnSync /usr/local/lib/node_modules/turbo/bin/turbo',
130 error   path: '/usr/local/lib/node_modules/turbo/bin/turbo',
130 error   spawnargs: [ '--version' ],
130 error   error: [Circular *1],
130 error   status: null,
130 error   signal: null,
130 error   output: null,
130 error   pid: 26,
130 error   stdout: null,
130 error   stderr: null
130 error }
131 verbose exit 1
132 timing npm Completed in 65188ms
133 verbose unfinished npm timer reify 1665478312917
134 verbose unfinished npm timer reify:build 1665478377779
135 verbose unfinished npm timer build 1665478377780
136 verbose unfinished npm timer build:deps 1665478377780
137 verbose unfinished npm timer build:run:postinstall 1665478377790
138 verbose unfinished npm timer build:run:postinstall:node_modules/turbo 1665478377791
139 verbose code 1

My docker image was node:16-alpine with no additions

@adarshaacharya adarshaacharya changed the title Create changelog docs for latest release -docker build fail after v1.5.6 release Create changelog docs for latest release - Docker build fail after v1.5.6 release Oct 11, 2022
@prakashharisharma
Copy link

Any workaround ?? Facing same issue.

#9 [pruner 1/3] RUN yarn global add turbo
#9 sha256:414f928a3764b82d686b02f50c42204728f93ca324553de85c10f19e17c456d9
#9 0.489 yarn global v1.22.19
#9 0.542 [1/4] Resolving packages...
#9 1.069 [2/4] Fetching packages...
#9 2.326 [3/4] Linking dependencies...
#9 2.368 [4/4] Building fresh packages...
#9 2.523 error /usr/local/share/.config/yarn/global/node_modules/turbo: Command failed.
#9 2.523 Exit code: 1
#9 2.523 Command: node install.js
#9 2.523 Arguments: 
#9 2.523 Directory: /usr/local/share/.config/yarn/global/node_modules/turbo
#9 2.523 Output:
#9 2.523 node:internal/errors:856
#9 2.523   const err = new Error(message);
#9 2.523               ^
#9 2.523 
#9 2.523 Error: Command failed: node /usr/local/share/.config/yarn/global/node_modules/turbo/bin/turbo --version
#9 2.523 /usr/local/share/.config/yarn/global/node_modules/turbo/bin/turbo:13

@Andersos
Copy link

Any workaround ?? Facing same issue.

If you pin turbo to version 1.5.5 it should work fine:

RUN yarn global add turbo@1.5.5

@gsoltis
Copy link
Contributor

gsoltis commented Oct 11, 2022

Apologies, the release notes are generated. I suspect that this is related to the switch to enable CGO. I'll take a look at the docker issue, we'll either need to update our build process or docs on dependencies in docker environments.

@Rykuno
Copy link

Rykuno commented Oct 12, 2022

I'll hop on this. We're utilizing turbo@1.5.6 and downgrading the docker build to turbo@1.5.5 fixed this issue.

@prakashharisharma
Copy link

Any workaround ?? Facing same issue.

#9 [pruner 1/3] RUN yarn global add turbo
#9 sha256:414f928a3764b82d686b02f50c42204728f93ca324553de85c10f19e17c456d9
#9 0.489 yarn global v1.22.19
#9 0.542 [1/4] Resolving packages...
#9 1.069 [2/4] Fetching packages...
#9 2.326 [3/4] Linking dependencies...
#9 2.368 [4/4] Building fresh packages...
#9 2.523 error /usr/local/share/.config/yarn/global/node_modules/turbo: Command failed.
#9 2.523 Exit code: 1
#9 2.523 Command: node install.js
#9 2.523 Arguments: 
#9 2.523 Directory: /usr/local/share/.config/yarn/global/node_modules/turbo
#9 2.523 Output:
#9 2.523 node:internal/errors:856
#9 2.523   const err = new Error(message);
#9 2.523               ^
#9 2.523 
#9 2.523 Error: Command failed: node /usr/local/share/.config/yarn/global/node_modules/turbo/bin/turbo --version
#9 2.523 /usr/local/share/.config/yarn/global/node_modules/turbo/bin/turbo:13

Thanks @Rykuno It worked after downgrading to turbo@1.5.5

@laat
Copy link
Contributor

laat commented Oct 12, 2022

Any workaround ?? Facing same issue.

You can either pin the dependency to 1.5.5:

FROM node:alpine
RUN yarn global add turbo@1.5.5

or add libc6-compat:

FROM node:alpine
RUN apk add --no-cache libc6-compat
RUN yarn global add turbo@1.5.6

@gsoltis
Copy link
Contributor

gsoltis commented Oct 12, 2022

add libc6-compat

I think this is the correct path forward for alpine compatibility. It looks like alpine doesn't ship glibc by default, instead preferring musl. We can look into shipping a musl build in the future, but the current build expects glibc.

I'll get that added to the docs.

@big-camel
Copy link
Contributor

big-camel commented Oct 13, 2022

Use with libc6-compat and 16-alpine

FROM node:16-alpine AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=web --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install

# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
RUN yarn turbo run build --filter=web...

FROM node:16-alpine AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static

CMD node apps/web/server.js

@adarshaacharya
Copy link
Contributor Author

adarshaacharya commented Oct 13, 2022

Use with libc6-compat and 16-alpine

FROM node:16-alpine AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=web --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install

# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
RUN yarn turbo run build --filter=web...

FROM node:16-alpine AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static

CMD node apps/web/server.js

@prakashharisharma looks like

RUN apk add --no-cache libc6-compat

is the new solution moving forward.

@kodiakhq kodiakhq bot closed this as completed in #2212 Oct 13, 2022
kodiakhq bot pushed a commit that referenced this issue Oct 13, 2022
Alpine doesn't ship with `glibc` compatibility by default, add a note to the docs for that environment.

Fixes #2198
ghoshanjega added a commit to ghoshanjega/party that referenced this issue Oct 22, 2022
kodiakhq bot pushed a commit that referenced this issue Nov 11, 2022
This adds a helpful error when we fail to run the turbo binary in alpine linux pointing to the related doc to help users get unblocked when failing to run with glibc compat installed as currently they will just see an `ENOENT` error which doesn't lead to the docs very well. 

x-ref: #2212
x-ref: #2198

Co-authored-by: Nathan Hammond <20542+nathanhammond@users.noreply.github.com>
jdalrymple added a commit to jdalrymple/gitbeaker that referenced this issue Feb 19, 2023
jdalrymple added a commit to jdalrymple/gitbeaker that referenced this issue Mar 13, 2023
@michealroberts
Copy link

This was certainly a breaking change imho, which has introduced a different set of architecture dependencies and should have only have been pushed as a turbo version 2.

The libc6-compat fixed as outlined above simply will not work on linux/amd64 architectures.

Scrambling for a fix is not a nice feeling.

@artemchs
Copy link

artemchs commented Jul 12, 2024

This was certainly a breaking change imho, which has introduced a different set of architecture dependencies and should have only have been pushed as a turbo version 2.

The libc6-compat fixed as outlined above simply will not work on linux/amd64 architectures.

Scrambling for a fix is not a nice feeling.

It seems like the problem isn't fixed yet or there isn't right documentation on how to fix it. Even though this issue has been closed for a long time, I still get an error that's described here, so I thought it may be useful to ask y'all for a solution.

Here's my Dockerfile:

# Alpine image
FROM node:22.1.0-alpine AS alpine
RUN apk update
RUN apk add --no-cache libc6-compat

# Setup pnpm and turbo on the alpine base
FROM alpine as base
RUN npm i -g pnpm turbo
RUN pnpm config set store-dir ~/.pnpm-store

# Prune projects
FROM base AS pruner

WORKDIR /app
COPY . .
RUN turbo prune --scope=api --docker

# Build the project
FROM base AS builder

WORKDIR /app

# Copy lockfile and package.json's of isolated subworkspace
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=pruner /app/out/json/ .

# First install the dependencies (as they change less often)
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile

# Copy source code of isolated subworkspace
COPY --from=pruner /app/out/full/ .

RUN turbo build --filter=api
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm prune --prod --no-optional
RUN rm -rf ./**/*/src

# Final image
FROM alpine AS runner

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/api

ARG PORT=8080
ENV PORT=${PORT}
ENV NODE_ENV=production

EXPOSE ${PORT}

# CMD node apps/${PROJECT}/dist/main.js
CMD ["sh", "-c", "source .env.production && node apps/${PROJECT}/dist/main.js"]

I've also tried to prefix with ./ in my pnpm-workspace.yml:

packages:
  - "./apps/*"
  - "./packages/*"

I've checked whether I have "packageManager" field in my root package.json, and I do:

{
    "name": "my-project-123",
    "private": true,
    "scripts": {
        "build": "turbo build",
        "dev": "turbo dev",
        "lint": "turbo lint",
        "format": "prettier --write \"**/*.{ts,tsx,md}\""
    },
    "devDependencies": {
        "@eslint/compat": "^1.1.0",
        "@eslint/js": "^9.6.0",
        "@next/eslint-plugin-next": "^14.2.4",
        "@tanstack/eslint-plugin-query": "^5.50.1",
        "eslint": "~9.6.0",
        "eslint-plugin-react": "^7.34.3",
        "globals": "^15.8.0",
        "prettier": "^3.3.2",
        "turbo": "latest",
        "typescript-eslint": "^7.16.0"
    },
    "packageManager": "pnpm@9.5.0",
    "engines": {
        "node": ">=22.1.0"
    }
}

Whenever I run my docker-compose.yml that uses this Dockerfile I get an error that says: "WARNING No locally installed turbo found. Using version: 2.0.6.". I thought I'd find a solution to this problem in this issue, but I didn't. Yet it may be possible that I've made a mistake somewhere else that somehow affects the monorepo configuration, but it seems improbable.

@ba2sik
Copy link

ba2sik commented Sep 6, 2024

it happens to me also, turbo 2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.