I’m trying to containerize so that I don’t have to mess around with different versions of Node (among other thing) for different projects. The title says it all, is it possible to run Serverless in a Docker container?
I created a Dockerfile:
FROM node:8-alpine
RUN apk update
RUN npm install -g serverless && \
npm install -g serverless-offline && \
npm install -g yarn
WORKDIR /usr/src/app
COPY package*.json ./
RUN yarn
COPY . .
EXPOSE 3000
CMD [ "sls", "offline" ]
Build it: docker build -t serverless/docker .
Run it: docker run -p 49160:3000 serverless/docker
Response: curl: (56) Recv failure: Connection reset by peer
In that case, maybe trying to change the host serverless-offline is listening on to 0.0.0.0 would help. You can do so by adding the snippet below to your serverless.yml.
I had some issues with my base image not being able to find the sls or serverless commands automatically and I ended up having to actually provide a path to the serverless bin file, I also created a Github Gist to hopefully give a little more help with this in the future to anyone needing a little bit more clarification.
Thanks to everyone on this thread for pointing me in the right direction with the host flag