Skip to content

Commit

Permalink
feat: container version of the lambda function (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
birme authored Oct 3, 2023
1 parent 438abc5 commit e691232
Show file tree
Hide file tree
Showing 7 changed files with 825 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
**/__mocks__
**/*.test.ts
42 changes: 38 additions & 4 deletions .github/workflows/builddeploy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
name: Deploy to Lambda
on:
push:
branches:
- master
release:
types: [released]

jobs:
deploy_source:
publish_docker:
name: Build Docker image and publish to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.HUB_DOCKER_USERNAME }}
password: ${{ secrets.HUB_DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: eyevinntechnology/lambda-stitch

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy_lambda:
name: Build and Deploy Lambda
strategy:
matrix:
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG NODE_IMAGE=node:18-alpine

FROM ${NODE_IMAGE}
ENV NODE_ENV=production
EXPOSE 8000
USER node
WORKDIR /app
COPY --chown=node:node ["package.json", "package-lock.json*", "index.js", "server.js", "./"]
# Delete prepare script to avoid errors from husky
RUN npm pkg delete scripts.prepare \
&& npm ci --omit=dev
CMD [ "npm", "run", "start" ]
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ exports.handler = async event => {
response = await handleMediaManifestRequest(event);
} else if (event.path.match(/\/stitch\/assetlist\/.*$/)) {
response = await handleAssetListRequest(event);
} else if (event.path === "/" && event.httpMethod === "GET") {
response = {
statusCode: 200,
body: "OK"
}
} else {
response = generateErrorResponse({ code: 404 });
}
Expand Down
Loading

0 comments on commit e691232

Please sign in to comment.