Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

dynamodb-emulator fails to init after failed bounding #69

Open
danifbento opened this issue Jan 22, 2019 · 4 comments
Open

dynamodb-emulator fails to init after failed bounding #69

danifbento opened this issue Jan 22, 2019 · 4 comments

Comments

@danifbento
Copy link
Contributor

danifbento commented Jan 22, 2019

When trying to init sls offline start inside a Docker container I receive this message, but the 8000 port is not bounded with anything...

SLS_DEBUG=* NODE_DEBUG=dynamodb* sls offline start

Serverless: Invoke offline:start
ℹ️  dynamodb-emulator launching { retry: 0,
  givenOptions:
   { port: 8000,
     dbPath: '/py-tests/.dynamodb',
     inMemory: false,
     seed: true,
     sharedDb: true,
     delayTransientStatuses: undefined,
     optimizeDbBeforeStartup: undefined } }
ℹ️  dynamodb-emulator Spawning Emulator: { args:
   [ '-Djava.library.path=./DynamoDBLocal_lib',
     '-jar',
     'DynamoDBLocal.jar',
     '-port',
     8000,
     '-dbPath',
     '/py-tests/.dynamodb',
     '-sharedDb' ],
  cwd:
   '/root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/@conduitvc/dynamodb-emulator/emulator' }
ℹ️  dynamodb-emulator Emulator has started but need to verify socket
❌  dynamodb-emulator Port bound but by another process ... time to retry
Serverless: ERROR: Error: 8000 is bound and unavailable
@pianomansam
Copy link
Contributor

@danifbento It will be helpful to see your serverless.yml file as well as Dockerfile or Docker image.

@danifbento
Copy link
Contributor Author

danifbento commented Jan 23, 2019

Thanks.

My serverless.yml is the following:

service: tests
provider:
  name: aws
  stage: dev
  region: eu-central-1
  runtime: nodejs8.1
  profile: default
  deploymentBucket: serverless.deploys

plugins:
  - serverless-appsync-plugin
  - serverless-appsync-offline
  - serverless-offline-sns
  - serverless-offline

custom:
  serverless-offline:
    host: 0.0.0.0
  serverless-offline-sns:
    port: 4002
    debug: false
  appsync-offline:
    port: 62222
    dynamodb:
      server:
        port: 8000
        inMemory: false
        seed: true
        sharedDb: true
  region: eu-central-1
  clientId: <clientID>
  appSync:
    name: deploy_test
    authenticationType: AMAZON_COGNITO_USER_POOLS
    userPoolConfig:
      awsRegion: eu-central-1
      defaultAction: ALLOW
      userPoolId: <poolId>
    schema: schema.graphql
    mappingTemplatesLocation: ./
    mappingTemplates:
        - dataSource: get_user
          type: Invite
          field: inviter
          request: resolver/request-mapping-template.json
          response: resolver/response-mapping-template.json
    dataSources:
          - type: AWS_LAMBDA
        name: get_user
        description: 'Get User'
        config:
            lambdaFunctionArn: arn:aws:lambda:${self:custom.region}:${self:custom.clientId}:function:fn-py-getuser
            functionName: getuser
functions:
  getuser:
    handler: getuser/handler.getuser
    timeout: 10
    runtime: python3.6
resources:
   Resources:
   (...)

And Dockerfile:

FROM ubuntu:18.04

ARG aws_access_key_id
ARG aws_secret_access_key

ENV GOPATH=/py-useraccount-tests
ENV GOBIN=$GOPATH/bin
ENV PATH=/root/.npm_packages/bin:$PATH
ENV NODE_PATH=/root/.npm_packages/lib/node_modules:$NODE_PATH

RUN \
    apt-get update && \
    apt-get install -y make git curl && \
    apt-get install -y python3 python3-pip && \
    apt-get install -y golang && \
    apt-get install -y npm && \
    apt-get install -y openssh-server zip && \
    apt-get install -y default-jre
RUN \
    pip3 install boto3

RUN \
    curl -sL https://deb.nodesource.com/setup_11.x | bash - && \
    apt-get install -y nodejs

RUN apt -y autoremove

RUN \
    go get -u github.com/aws/aws-lambda-go/lambda && \
    go get -u github.com/golang/dep/cmd/dep

COPY package.json /py-tests

RUN pip3 install aws-sam-cli jwt

RUN npm config set prefix /root/.npm_packages

RUN npm install -g try-thread-sleep@latest
RUN npm install -g serverless@latest --ignore-script spawn-sync
RUN npm install -g serverless-appsync-offline@latest --ignore-script spawn-sync
RUN npm install -g serverless-appsync-plugin@latest
RUN npm install -g serverless-offline@latest
RUN npm install -g serverless-offline-sns@latest
RUN npm install -g just-api --unsafe-perm=true --allow-root
RUN npm install -g aws-appsync
RUN npm install -g aws-sdk

RUN cd /root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/graphql-phone-type/ && npm install && npm run prepare
RUN mkdir /root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/\@conduitvc/dynamodb-emulator/emulator && cd /root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/\@conduitvc/dynamodb-emulator/ && npm run install 

WORKDIR "/py-tests"

COPY . /py-tests

RUN sls config credentials --provider aws --key "$aws_access_key_id" --secret "$aws_secret_access_key"

EXPOSE 62222 8000
CMD ["sls", "offline", "start"]

@pianomansam
Copy link
Contributor

pianomansam commented Jan 23, 2019

@danifbento after a quick skim, everything seems to look ok. I'm using this inside Docker as well, however, using docker-compose and have a separate container for DynamoDB. Any reason why that isn't an option for you?

@danifbento
Copy link
Contributor Author

Hello @pianomansam

Sorry for the late response. I started using in a separated container with docker-compose and it start to work. But now I have an error starting AppSync emulator saying ERROR on aws_auth saying that is not defined. The project is in a container, but it works on my PC but not in another ...

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

No branches or pull requests

2 participants