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

[bug] panic when running moon docker setup in Dockerfile #1700

Open
CluEleSsUK opened this issue Oct 22, 2024 · 6 comments
Open

[bug] panic when running moon docker setup in Dockerfile #1700

CluEleSsUK opened this issue Oct 22, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@CluEleSsUK
Copy link

Describe the bug

I generated a dockerfile using moon docker file <project>. Building the resulting dockerfile panics

Steps to reproduce

  1. moon docker setup projectName
  2. docker build -f path/to/Dockerfile .

Expected behavior

dockerfile builds

Screenshots

[+] Building 72.7s (12/17)                                                                                                                                                                                                                                                                    docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                          0.0s
 => => transferring dockerfile: 1.06kB                                                                                                                                                                                                                                                                        0.0s
 => [internal] load metadata for node:latest                                                                                                                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                             0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                               0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                            39.7s
 => => transferring context: 6.93GB                                                                                                                                                                                                                                                                          39.0s
 => [base 1/3] FROM node:latest                                                                                                                                                                                                                              0.0s
 => CACHED [base 2/3] WORKDIR /app                                                                                                                                                                                                                                                                            0.0s
 => [base 3/3] RUN curl -fsSL https://moonrepo.dev/install/moon.sh | bash                                                                                                                                                                                                                                     2.3s
 => [skeleton 1/2] COPY . .                                                                                                                                                                                                                                                                                  23.8s 
 => [skeleton 2/2] RUN moon docker scaffold hose                                                                                                                                                                                                                                                              7.5s 
 => [build 1/6] COPY --from=skeleton /root/.proto /root/.proto                                                                                                                                                                                                                                                0.4s 
 => [build 2/6] COPY --from=skeleton /app/.moon/docker/workspace .                                                                                                                                                                                                                                            0.0s 
 => ERROR [build 3/6] RUN moon docker setup                                                                                                                                                                                                                                                                   1.0s 
------                                                                                                                                                                                                                                                                                                             
 > [build 3/6] RUN moon docker setup:
1.016 Error:   × Main thread panicked.
1.016   ├─▶ at /app/crates/action-pipeline/src/action_pipeline.rs:140:38
1.016   ╰─▶ mpsc bounded channel requires buffer > 0
1.016   help: set the `RUST_BACKTRACE=1` environment variable to display a
1.016         backtrace.
1.016 
1.021 Aborted
------
Dockerfile:32

Environment

  System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 67.66 MB / 32.00 GB
    Shell: 3.7.1 - /usr/local/bin/fish
  Binaries:
    Node: 22.3.0 - ~/.nvm/versions/node/v22.3.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.3.0/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v22.3.0/bin/npm

Additional context

@CluEleSsUK CluEleSsUK added the bug Something isn't working label Oct 22, 2024
@CluEleSsUK
Copy link
Author

CluEleSsUK commented Oct 22, 2024

The generated dockerfile looks like so:

#### Installs moon.

FROM  node:latest AS base
WORKDIR /app

# Install moon binary
RUN curl -fsSL https://moonrepo.dev/install/moon.sh | bash
ENV PATH="/root/.moon/bin:$PATH"

#### SKELETON STAGE
#### Scaffolds repository skeleton structures.

FROM base AS skeleton

# Copy entire repository and scaffold
COPY . .
RUN moon docker scaffold hose

#### BUILD STAGE
#### Builds the project.

FROM base AS build

# Copy toolchain
COPY --from=skeleton /root/.proto /root/.proto

# Copy workspace configs
COPY --from=skeleton /app/.moon/docker/workspace .

# Install dependencies
RUN moon docker setup

# Copy project sources
COPY --from=skeleton /app/.moon/docker/sources .

# Build the project
RUN moon run hose:build

# Prune extraneous dependencies
RUN moon docker prune

#### START STAGE
#### Runs the project.

FROM base AS start

# Copy built sources
COPY --from=build /root/.proto /root/.proto
COPY --from=build /app /app

ENTRYPOINT node /app/index.js

I added the last ENTRYPOINT, but that shouldn't change anything

@CluEleSsUK
Copy link
Author

fwiw I have also tried npm install -g @moonrepo/cli instead of the curl->bash, but that gives me

 > [build 5/6] RUN moon run hose:build:
0.213 Error: project::task::unknown
0.213 
0.213   × Unknown task build for project hose.
0.213   help: Has this task been configured?
0.213 

This task runs no problem outside docker

@milesj
Copy link
Collaborator

milesj commented Oct 22, 2024

Yeah that panic basically means there are no actions in the pipeline: https://github.com/moonrepo/moon/blob/master/crates/action-pipeline/src/action_pipeline.rs#L140

Something isn't right in the Dockerfile. Seems like critical config files are missing.

If you run moon docker scaffold outside of docker, does the shape of .moon/docker look correct?

@CluEleSsUK
Copy link
Author

hmm it does not, it contains my package.json, moon.yml, tsconfig.json and .gitignore (but no source directories).
This sort of aligns with the build task except the glob:

language: 'typescript'

tasks:
  build:
    command: 'npm run build'
    inputs:
      - 'src/**/*'
      - 'tsconfig.json'
      - 'package.json'
    outputs:
      - 'index.js'

@CluEleSsUK
Copy link
Author

ah sorry, the source dir is under .moon/docker/sources/$project 🤡

@milesj
Copy link
Collaborator

milesj commented Oct 23, 2024

Can you pass --log trace to moon docker setup and then paste the logs?

Also, .dockerignore looks fine yeah?

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

No branches or pull requests

2 participants