-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Integrated new email template in cli Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Update help test Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Delete temp img in for error case Signed-off-by: Rupal Mahajan <maharup@amazon.com> * use const for emailTemplateImageBuffer Signed-off-by: Rupal Mahajan <maharup@amazon.com> * embed opensearch logo Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Accept text file for email body and add logic to convert text to html Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Increase wait time after dom modification Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Add dockerfile Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Updates required for working with lambda Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Change path to fix test failure Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Add ora spinner back Signed-off-by: Rupal Mahajan <maharup@amazon.com> * nit Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Add promise for sending email, Update Dockerfile with tgz install Signed-off-by: Rupal Mahajan <maharup@amazon.com> * nit: log Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Update doc Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Address PR comments Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Update Dockerfile Signed-off-by: Rupal Mahajan <maharup@amazon.com> * nit: remove ls Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Move Dockerfile to example doc Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Add Dockerfile for building from source Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Nit: remove ls from Dockerfile Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Adding apt-get remove -y google-chrome-stable Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Update example docs Signed-off-by: Rupal Mahajan <maharup@amazon.com> * nit Signed-off-by: Rupal Mahajan <maharup@amazon.com> * Update docs/examples/lambda_container_image.md Co-authored-by: Joshua Li <joshuali925@gmail.com> --------- Signed-off-by: Rupal Mahajan <maharup@amazon.com> Co-authored-by: Joshua Li <joshuali925@gmail.com>
- Loading branch information
1 parent
c8ca95f
commit d98381d
Showing
13 changed files
with
1,153 additions
and
978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Scheduling Reports with Lambda | ||
|
||
Opensearch reporting CLI can be used with Lambda for scheduling email reports. | ||
|
||
### Prerequisites | ||
|
||
- AMD64 Systems | ||
- Docker | ||
|
||
### Creating Lambda container image | ||
|
||
1. Create a Dockerfile. Following Dockerfile can be used to create a container image for v1.0.0. | ||
```dockerfile | ||
# Define function directory | ||
ARG FUNCTION_DIR="/function" | ||
|
||
# Base image of the docker container | ||
FROM node:lts-slim as build-image | ||
|
||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
|
||
# AWS Lambda runtime dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
g++ \ | ||
make \ | ||
unzip \ | ||
libcurl4-openssl-dev \ | ||
autoconf \ | ||
automake \ | ||
libtool \ | ||
cmake \ | ||
python3 \ | ||
libkrb5-dev \ | ||
curl | ||
|
||
# Copy function code | ||
WORKDIR ${FUNCTION_DIR} | ||
RUN curl -LJO https://artifacts.opensearch.org/reporting-cli/opensearch-reporting-cli-1.0.0.tgz | ||
RUN tar -xzf opensearch-reporting-cli-1.0.0.tgz | ||
RUN mv package/* . | ||
RUN npm install && npm install aws-lambda-ric | ||
|
||
# Build Stage 2: Copy Build Stage 1 files in to Stage 2. Install chromium dependencies and chromium. | ||
FROM node:lts-slim | ||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
# Set working directory to function root directory | ||
WORKDIR ${FUNCTION_DIR} | ||
# Copy in the build image dependencies | ||
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} | ||
|
||
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) | ||
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer installs, work. | ||
RUN apt-get update \ | ||
&& apt-get install -y wget gnupg \ | ||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \ | ||
--no-install-recommends \ | ||
&& apt-get remove -y google-chrome-stable \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENTRYPOINT ["/usr/local/bin/npx", "aws-lambda-ric"] | ||
|
||
ENV HOME="/tmp" | ||
CMD [ "/function/src/index.handler" ] | ||
``` | ||
|
||
2. Run the build command in from the directory where Dockerfile exists. | ||
|
||
``` | ||
docker build -t opensearch-reporting-cli . | ||
``` | ||
### Use Lambda container image | ||
|
||
1. Push the Docker image to [Amazon ECR](https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-console.html) | ||
|
||
2. Create a Lambda Function. Select previously created container image and architecture x86_64'. | ||
3. Update Lambda timeout to 5 min and memory size to at least 1024MB. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## Create Lambda container image from source code | ||
|
||
1. Checkout this package from version control | ||
``` | ||
git clone git@github.com:opensearch-project/reporting-cli.git | ||
cd reporting-cli | ||
``` | ||
2. Add the following Dockerfile inside `reporting-cli`. | ||
```dockerfile | ||
# Define function directory | ||
ARG FUNCTION_DIR="/function" | ||
|
||
# Base image of the docker container | ||
FROM node:lts-slim as build-image | ||
|
||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
|
||
# AWS Lambda runtime dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
g++ \ | ||
make \ | ||
unzip \ | ||
libcurl4-openssl-dev \ | ||
autoconf \ | ||
automake \ | ||
libtool \ | ||
cmake \ | ||
python3 \ | ||
libkrb5-dev | ||
|
||
# Copy function code | ||
COPY package.json src/ ${FUNCTION_DIR}/ | ||
WORKDIR ${FUNCTION_DIR} | ||
RUN npm install && npm install aws-lambda-ric | ||
|
||
# Build Stage 2: Copy Build Stage 1 files in to Stage 2. Install chromium dependencies and chromium. | ||
FROM node:lts-slim | ||
|
||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
|
||
# Set working directory to function root directory | ||
WORKDIR ${FUNCTION_DIR} | ||
|
||
# Copy in the build image dependencies | ||
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} | ||
|
||
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) | ||
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer installs, work. | ||
RUN apt-get update \ | ||
&& apt-get install -y wget gnupg \ | ||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \ | ||
--no-install-recommends \ | ||
&& apt-get remove -y google-chrome-stable \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENTRYPOINT ["/usr/local/bin/npx", "aws-lambda-ric"] | ||
|
||
ENV HOME="/tmp" | ||
CMD [ "/function/index.handler" ] | ||
|
||
``` | ||
3. Run the build command. | ||
``` | ||
docker build -t opensearch-reporting-cli . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
const run = require('./run.js'); | ||
|
||
run(undefined); |
Oops, something went wrong.