From 0e14b5bd04fb5bba93015c4a3b25b1279618882d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 10 May 2021 22:34:38 +0100 Subject: [PATCH] Remove Lambda specific files, they will be commited into a new repository YellowLabTools/YellowLabTools-lambda-agent --- Dockerfile.lambda | 35 ----------------------------------- Makefile | 30 ------------------------------ bin/lambda.js | 47 ----------------------------------------------- 3 files changed, 112 deletions(-) delete mode 100644 Dockerfile.lambda delete mode 100644 Makefile delete mode 100644 bin/lambda.js diff --git a/Dockerfile.lambda b/Dockerfile.lambda deleted file mode 100644 index 7a7b0f6..0000000 --- a/Dockerfile.lambda +++ /dev/null @@ -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" ] diff --git a/Makefile b/Makefile deleted file mode 100644 index d81f57f..0000000 --- a/Makefile +++ /dev/null @@ -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)"}' \ No newline at end of file diff --git a/bin/lambda.js b/bin/lambda.js deleted file mode 100644 index ca51801..0000000 --- a/bin/lambda.js +++ /dev/null @@ -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}; \ No newline at end of file