Skip to content

Building docker image from within CircleCI fails #40

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

Closed
txus opened this issue May 11, 2019 · 5 comments
Closed

Building docker image from within CircleCI fails #40

txus opened this issue May 11, 2019 · 5 comments

Comments

@txus
Copy link

txus commented May 11, 2019

🐛 Bug description

I'm trying to do continuous deployment (of a private project) on CircleCI. When building the dockerized Rust image, it fails with this message (SLS_DEBUG=true):

Serverless: Building native Rust ingest.import func...
Unable to find image 'softprops/lambda-rust:0.2.1-rust-1.34.1' locally
0.2.1-rust-1.34.1: Pulling from softprops/lambda-rust

Digest: sha256:972b2621171e89d54b3812fa411792a5b384e88dc2af8f5c21b3131f3610f2fe
Status: Downloaded newer image for softprops/lambda-rust:0.2.1-rust-1.34.1
error: could not find `Cargo.toml` in `/code` or any parent directory

Serverless: Dockerized Rust build encountered an error: undefined 1.
 
  Error --------------------------------------------------
  
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error
    at functions.forEach.funcName (/home/circleci/code/node_modules/serverless-rust/index.js:121:15)
    at Array.forEach (<anonymous>)
    at RustPlugin.build (/home/circleci/code/node_modules/serverless-rust/index.js:101:22)
    at BbPromise.reduce (/home/circleci/code/node_modules/serverless/lib/classes/PluginManager.js:422:55)
From previous event:
    at PluginManager.invoke (/home/circleci/code/node_modules/serverless/lib/classes/PluginManager.js:422:22)
    at PluginManager.run (/home/circleci/code/node_modules/serverless/lib/classes/PluginManager.js:453:17)
    at variables.populateService.then (/home/circleci/code/node_modules/serverless/lib/Serverless.js:109:33)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at Serverless.run (/home/circleci/code/node_modules/serverless/lib/Serverless.js:96:6)
    at serverless.init.then (/home/circleci/code/node_modules/serverless/bin/serverless:43:28)
    at /home/circleci/code/node_modules/graceful-fs/graceful-fs.js:111:16
    at /home/circleci/code/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.args [as oncomplete] (fs.js:140:20)
From previous event:
    at initializeErrorReporter.then (/home/circleci/code/node_modules/serverless/bin/serverless:43:6)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at /home/circleci/code/node_modules/serverless/bin/serverless:28:46
    at Object.<anonymous> (/home/circleci/code/node_modules/serverless/bin/serverless:65:4)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at findNodeScript.then.existing (/usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           10.15.3
     Serverless Version:     1.42.2
 
Exited with code 1

It seems as if it can't mount the current directory as a volume?

🤔 Expected Behavior

It should have been able to build the image as it does locally.

👟 Steps to reproduce

It is a private project, but I'm pretty sure it happens with any serverless-rust project on CircleCI.

🌍 Your environment

Running on CircleCI, from image rust:latest-node and a remote docker env set up.

OS: linux
Node Version: 10.15.3
Serverless Version: 1.42.2
plugin version: 0.3.4

@softprops
Copy link
Owner

Do you have an example repo I could look at or fork?

Here's where the volume mount for /code gets set.

https://github.com/softprops/serverless-rust/blob/master/index.js#L62

@maxcountryman
Copy link

maxcountryman commented Aug 16, 2019

I've run into this same issue (apologies, I raised this issue here: softprops/lambda-rust#25 )--I could possibly provide a CircleCI config at least.

@maxcountryman
Copy link

Here's a CirlceCI config that reproduces my issue.

However after reading a bit more about how the setup_remote_docker directive works (specifically the fact that it's isolated from the job container) I started to think that the overall approach I was taking wasn't ideal.

So I was able to resolve my issue by switching to the machine job type. Here's a working example:

    deploy:
        machine: true
        #docker:
        #    - image: circleci/rust:latest-node

        steps:
            - checkout
            #- setup_remote_docker
            - run:
                name: Deploy function
                command: |
                    npm i -D serverless-rust
                    npx serverless deploy

Using machine: true I'm able to deploy via CircleCI.

@softprops
Copy link
Owner

Just an update on this. The latest release adds experimental support for building locally which might solve this issue. I've set up integration tests on with github actions for linux, windows, and macos vms

https://github.com/softprops/serverless-rust#-experimental-local-builds

@softprops
Copy link
Owner

closing for now since its now possible to build without docker. feel free to reopen if you continue to see a problem when using the latest version

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

No branches or pull requests

3 participants