Skip to content

Instantly share code, notes, and snippets.

@GeorgeSabu

GeorgeSabu/Dockerfile

Last active Sep 2, 2020
Embed
What would you like to do?
Example docker job to upload and download Polly files
# In this example the docker is being built with docker name "mithoopolly/polly_cli_test" and tag "latest"
FROM ubuntu:latest
# update the node and npm
RUN apt-get update && \
apt-get install -y \
curl \
git \
uuid-runtime \
&& \
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get install -y nodejs
# Install PollyCLI
RUN npm install -g @elucidatainc/pollycli && polly version --version
# An example script to upload and download files using Polly CLI
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]
#!/bin/bash
# Checking the version of Polly CLI
polly --version
# login into Polly with Polly CLI inside a Polly job
polly login --auto
# Workspace in which job is been run will be auto detected if --yes flag is passed in the Polly jobs.
# If --yes is not passed it will prompt the user asking if they should take the default value
# or they want to enter a new value.
# NOTE: In the polly if --yes flag the Polly job will go to error state
echo "====================LISTING WORKSPACE FILES==============================="
polly files list --workspace-path polly:// --yes
echo "=========================================================================="
# PROJECT1_PATH is a system environment that is been passed by the user when starting a Polly job.
# See the Polly CLI documentation to know how to pass the environment to a job.
mkdir ./${PROJECT1_PATH}
echo "=====================DOWNLOAD THE FILES==================================="
polly files sync --source polly://${PROJECT1_PATH}/ --destination ./${PROJECT1_PATH} --yes
echo "=========================================================================="
echo "=====================LIST THE DOWNLOADED FILE============================="
ls ./${PROJECT1_PATH}
echo "=========================================================================="
echo "====================CREATE RANDOM FILE WHICH SIMULATE OUTPUT=============="
RANDOM_NAME=$(uuidgen).txt
dd if=/dev/urandom of=${RANDOM_NAME} bs=64M count=8
echo ${RANDOM_NAME}
echo "=========================================================================="
# In the below example we have used "polly files copy" to transfer a file to polly.
# If a group of files are there its better to use the "polly files sync" to upload
# the output folder.
echo "=====================UPLOAD THE FILES==================================="
polly files copy --source ./${RANDOM_NAME} --destination polly://${PROJECT1_PATH}/output/${RANDOM_NAME} --yes
echo "=========================================================================="
{
"cpu": "1",
"memory": "1Gi",
"image": "mithoopolly/polly_cli_test",
"tag": "latest",
"name": "test for auto login into polly",
"env": {
"PROJECT1_PATH" : "exampleProject"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment