Hi guys! I’m the devops of my team and I’m trying to deploy a redwoodjs application, so far I’ve contenerized the aplication with separated api and web stages, it runs perfectly on kubernetes and docker but our client wants to run it on lambda to take advantage of the free tier.
I’ve been able to run the api as a container in lambda with the serverless framework:
FROM node:14-alpine as base
WORKDIR /app
ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
ENV RUNTIME_ENV=$RUNTIME_ENV
ARG RUNTIME_ENV
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
COPY api/package.json api/package.json
COPY web/package.json web/package.json
COPY package.json .
COPY yarn.lock .
COPY redwood.toml .
COPY graphql.config.js .
COPY .env.docker .
COPY .yarn .yarn
COPY .yarnrc.yml .
RUN apk add --update --no-cache openssl1.1-compat
RUN yarn install
FROM base as build
COPY api api
COPY scripts scripts
RUN yarn rw build api
RUN yarn rw generate types
FROM node:16.14-alpine
WORKDIR /app
# Copy
COPY --from=build /app/api/dist /app/api/dist
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/.redwood /app/.redwood
COPY api/db api/db
COPY api/server.config.js api/server.config.js
COPY api/package.json .
COPY graphql.config.js .
COPY redwood.toml .
COPY .env.docker .
RUN apk add --update --no-cache openssl
# Install dependencies
RUN yarn install
# Install additional dependencies
RUN yarn add @redwoodjs/api-server @redwoodjs/internal @redwoodjs/cli
RUN yarn cache clean
EXPOSE 8911
CMD []
ENTRYPOINT [ "yarn", "rw", "serve", "api"]
but neither function urls o api gateway sends the requests correctly to the server, instead it starts correctly and waits for a request until the lambda times out.
my serverless.yml looks like this:
service: xxxxx-api
frameworkVersion: '3'
provider:
name: aws
ecr:
scanOnPush: false
images:
api:
path: "../"
file: "api/Dockerfile"
cacheFrom:
- api:latest
functions:
api:
image: api
fileSystemConfig:
localMountPath: /mnt/tmp
arn: arn:aws:xxxxxxxxxxx
vpc:
securityGroupIds:
- sg-xxxxxxxxxx
- sg-xxxxxxxxxx
subnetIds:
- subnet-0ae3f5751add977e2
- subnet-02791847f1e10b73e
events:
- httpApi: '*'
The logs in cloudwatch looks like this:
I’ve tried to configure the api gateway to route to /{proxy+} but that didin’t worked either
I’m pretty sure it may be related to the entrypoint I’m using, but I’m not sure how to solve it.
Do you guys have any thought about this? What did I miss? Thanks!