Open danifbento opened 5 years ago
@danifbento It will be helpful to see your serverless.yml file as well as Dockerfile or Docker image.
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"]
@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?
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 ...
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