Remove Lambda specific files, they will be commited into a new repository YellowLabTools/YellowLabTools-lambda-agent

This commit is contained in:
Gaël Métais
2021-05-10 22:34:38 +01:00
parent 90ded3e1cb
commit 0e14b5bd04
3 changed files with 0 additions and 112 deletions
-35
View File
@@ -1,35 +0,0 @@
FROM public.ecr.aws/lambda/nodejs:12
ENV DOCKERIZED yes
RUN yum install -y \
git gcc make gcc-c++ zlib-devel libjpeg-turbo-devel nasm automake autoconf libtool \
ca-certificates freetype freetype-devel harfbuzz nss \
cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/a/atk-2.26.0-1.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/a/at-spi2-atk-2.26.0-1.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/a/at-spi2-core-2.26.0-1.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libxkbcommon-0.7.1-5.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libXcomposite-0.4.4-11.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/a/alsa-lib-1.1.4.1-3.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libXi-1.7.9-4.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libXtst-1.2.3-4.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libxkbcommon-x11-0.7.1-5.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/g/gtk3-3.22.24-1.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libepoxy-1.4.3-3.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libwayland-cursor-1.14.0-1.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/m/mesa-libwayland-egl-17.2.2-4.fc27.x86_64.rpm && \
rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/g/gdk-pixbuf2-2.36.11-1.fc27.x86_64.rpm && \
rpm -ivh --force --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/l/libpng-1.6.31-1.fc27.x86_64.rpm && \
rpm -ivh --force --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/Packages/z/zlib-1.2.11-4.fc27.x86_64.rpm && \
yum clean all && \
rm -rf /var/cache/yum
ADD . /var/task
RUN rm -rf node_modules && \
npm install jpegoptim-bin --unsafe-perm=true --allow-root && \
NODE_ENV=development && npm install --only=prod && \
sed -i 's@"--disable-dev-shm-usage"@"--disable-dev-shm-usage", "--no-sandbox", "--no-zygote", "--disable-gpu", "--single-process"@' node_modules/phantomas/lib/browser.js
CMD [ "bin/lambda.runner" ]
-30
View File
@@ -1,30 +0,0 @@
env ?= dev
AWS_PROFILE ?= yellowlabtools-$(env)
AWS_REGION ?= us-east-1
DOCKER_IMAGE_TAG ?= latest
RESULT_BUCKET_NAME ?= $(env)-yellowlabtools-storage
TEST_NAME ?= test-local
TEST_URL ?= https://www.google.fr
all: install
install:
@npm install
build-docker-image-lambda:
@docker build -f Dockerfile.lambda -t yellowlabtools-runner-lambda .
tag-docker-image-lambda:
@docker tag yellowlabtools-runner-lambda:$(DOCKER_IMAGE_TAG) $(DOCKER_REGISTRY)/yellowlabtools-runner-lambda:$(DOCKER_IMAGE_TAG)
push-docker-image-lambda:
@docker push $(DOCKER_REGISTRY)/yellowlabtools-runner-lambda:$(DOCKER_IMAGE_TAG)
login-docker:
@AWS_PROFILE=$(AWS_PROFILE) aws ecr get-login-password --region $(AWS_REGION) | docker login --username AWS --password-stdin $(DOCKER_REGISTRY)
start-local-lambda:
@docker run --rm -it -p 9000:8080 -e RESULT_BUCKET_NAME=$(RESULT_BUCKET_NAME) -e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) -e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) yellowlabtools-runner-lambda:$(DOCKER_IMAGE_TAG)
run-local-test:
@curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"id": "$(TEST_NAME)", "url": "$(TEST_URL)"}'
-47
View File
@@ -1,47 +0,0 @@
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const ylt = require('..');
// noinspection JSUnusedLocalSymbols
async function runner({id, url, options = {}}, context) {
console.log(`Processing run #${id} on ${url}`);
// AWS S3 bucket and path
const bucket = process.env.RESULT_BUCKET_NAME;
const keyPrefix = `results/${id}`;
// Function that can save any file on S3 (JSON, screenshot,...)
const saveFile = async (path, content) => s3.putObject({Bucket: bucket, Key: `${keyPrefix}/${path}`, Body: content})
.promise();
// Let's launch ylt
const result = await ylt(url, {...options, saveScreenshotFn: saveFile})
.then(async data => {
console.log(`Run succeeded`);
data.runId = id;
await saveFile('results.json', JSON.stringify(data));
return {
status: 'processed',
id,
bucket,
keyPrefix
};
})
.fail(error => {
console.log(`Run failed with error: ${error}`);
return {
status: 'failed',
id,
bucket,
errorMessage: error
};
});
return result;
}
module.exports = {runner};