forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 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,65 @@ | ||
name: job output example | ||
description: | | ||
This job takes an input source image and resizes it to multiple outputs. | ||
This demo assumes a locally running instace of Minio (AWS S3-like service) which will be used to | ||
store the outputs at. | ||
You can get a running instance of minio using the following command: | ||
docker run --name=minio -d -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address ":9001" | ||
You'll like have to change the endpointURL below to the IP address of your minio server | ||
The default credentials for a Minio Server are minioadmin/minioadmin | ||
inputs: | ||
accessKeyID: minioadmin | ||
endpointURL: http://my-minio-server:9000 | ||
secretKeyID: minioadmin | ||
source: https://upload.wikimedia.org/wikipedia/commons/c/ca/Bbb-splash.png | ||
target: s3://my-bucket/my/folder | ||
tasks: | ||
- name: get the file extension of the source | ||
var: fileExt | ||
image: alpine:3.18.3 | ||
env: | ||
SOURCE: "{{ inputs.source }}" | ||
run: | | ||
FILENAME=$(basename -- "$SOURCE") | ||
EXT="${FILENAME##*.}" | ||
echo $EXT > $TORK_OUTPUT | ||
- name: Convert the image to various resolutions | ||
each: | ||
list: "{{ ['1920x1080','1366x768','1280x720','768x1024','100x100','200x200'] }}" | ||
task: | ||
name: "Scale the image to {{ item.value }}" | ||
volumes: | ||
- /tmp | ||
image: dpokidov/imagemagick | ||
env: | ||
EXT: "{{ tasks.fileExt }}" | ||
SIZE: "{{ item.value }}" | ||
run: | | ||
mkdir /tmp/targets | ||
convert "/tmp/source.$EXT" -resize $SIZE "/tmp/targets/$SIZE.jpg" | ||
pre: | ||
- name: download the remote file | ||
image: alpine:3.18.3 | ||
env: | ||
SOURCE: "{{ inputs.source }}" | ||
EXT: "{{ tasks.fileExt }}" | ||
run: | | ||
wget $SOURCE -O "/tmp/source.$EXT" | ||
post: | ||
- name: upload the converted image to minio | ||
run: aws --endpoint-url $ENDPOINT_URL s3 cp /tmp/targets/$SIZE.jpg $TARGET/$SIZE.jpg | ||
image: amazon/aws-cli:2.13.10 | ||
env: | ||
AWS_ACCESS_KEY_ID: "{{inputs.accessKeyID}}" | ||
AWS_SECRET_ACCESS_KEY: "{{inputs.secretKeyID}}" | ||
TARGET: "{{inputs.target}}" | ||
ENDPOINT_URL: "{{inputs.endpointURL}}" | ||
SIZE: "{{ item.value }}" | ||
|
||
|
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