-
Notifications
You must be signed in to change notification settings - Fork 60
restarting RIC #9
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
Comments
I got this working with the following in my
|
This put me on the right track, but I received an error saying the server was already listening on the port. I changed it to: "live": "tsc-watch --onSuccess \"docker compose restart my-container-name\"", Dockerfile: FROM node:18-alpine AS builder
# Install NPM dependencies for function
WORKDIR /app
COPY tsconfig.json package*.json ./
RUN npm clean-install --ignore-scripts
# Copy source files
COPY src src
# Transpile TypeScript to JavaScript
RUN npm run build
################ Create dev stage #######################
FROM amazon/aws-lambda-nodejs:18 as dev
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.handler" ]
################ Create runtime stage #######################
FROM amazon/aws-lambda-nodejs:18 as prod
# Install only production dependencies
COPY package*.json ${LAMBDA_TASK_ROOT}/
RUN npm clean-install --ignore-scripts --omit=dev
# Copy transpiled code
COPY --from=builder /app/dist ${LAMBDA_TASK_ROOT}
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.handler" ]
docker-compose.yml: version: '3.9'
services:
web:
build:
context: .
target: dev
ports:
- 9000:8080
- 9229:9229 # debugger
environment:
ValidatedEmailAddress: [email protected]
volumes:
- ~/.aws:/root/.aws:ro # AWS credentials
- ./dist:/var/task
- ./node_modules:/var/task/node_modules |
I don't think either of those are the right solutions. The first works outside of docker which means you have to account for inconsistencies between different OS' that your devs are using. The second one forces container restart which is costly in terms of both time and resources. It would be very helpful if the client could add support for watching and hot-reloading the handler code upon code changes. This along with the ability to enter debugger mode would make local development of lambdas amazing. |
I am currently using "scripts": {
"local:lambda": "nodemon --exec \"/usr/local/bin/aws-lambda-rie /usr/local/bin/npx aws-lambda-ric index.handler\""
} |
Rebuilding the image with every code change is not an ideal local developer experience.
Is there a way to restart the emulator on code change? Volume mount the function directory into the container, perform code changes to the function, and have the emulator restart?
The text was updated successfully, but these errors were encountered: