Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
23 changes: 23 additions & 0 deletions scripts/Dockerfile.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:22 AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22 AS runtime
WORKDIR /app
COPY --from=build /app/dist ./dist
COPY package*.json ./
RUN apt-get update && \
apt-get install -y \
g++ \
make \
cmake \
unzip \
libcurl4-openssl-dev
RUN npm install aws-lambda-ric
RUN npm ci --only=production
RUN npx playwright install chromium --with-deps
ENTRYPOINT ["/usr/local/bin/npx", "aws-lambda-ric"]
CMD ["dist/lambda-handler.handler"]
7 changes: 7 additions & 0 deletions scripts/build-lambda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
docker buildx build --platform linux/arm64 --provenance=false -f Dockerfile.script -t lambda-script:test .
docker run --platform linux/arm64 -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
--entrypoint /aws-lambda/aws-lambda-rie \
lambda-script:test \
/usr/local/bin/npx aws-lambda-ric dist/lambda-handler.handler
294 changes: 294 additions & 0 deletions scripts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"dev": "ts-node src/main.ts"
},
"dependencies": {
"@sparticuz/chromium": "^141.0.0",
"playwright": "^1.40.0"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions scripts/prepare-image-links.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if [ -f "public/data/rolling-images.json" ]; then
exit 0
fi
cd scripts || exit
yarn install
yarn build
npm install
npm run build
npx playwright install chromium
node dist/main.js "../public/data/rolling-images.json"
2 changes: 1 addition & 1 deletion scripts/src/lambda-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getImageLinksPlaywright } from "./main";
/**
* Fetches the latest pexels featured image links using Playwright
*/
export async function lambdaHandler(
export async function handler(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_event: APIGatewayProxyEvent,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
Loading