├── .circleci └── config.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .husky ├── post-checkout ├── post-commit ├── post-merge └── pre-push ├── Dockerfile ├── README.md ├── build.sh ├── ghostscript.zip ├── license ├── publish.sh └── renovate.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | aws-cli: circleci/aws-cli@1.2.1 5 | 6 | commands: 7 | publish: 8 | steps: 9 | - checkout 10 | - aws-cli/setup 11 | - run: ./publish.sh 12 | 13 | jobs: 14 | ap_northeast_1: 15 | executor: aws-cli/default 16 | environment: 17 | TARGET_REGION: ap-northeast-1 18 | steps: 19 | - publish 20 | 21 | ap_northeast_2: 22 | executor: aws-cli/default 23 | environment: 24 | TARGET_REGION: ap-northeast-2 25 | steps: 26 | - publish 27 | 28 | ap_south_1: 29 | executor: aws-cli/default 30 | environment: 31 | TARGET_REGION: ap-south-1 32 | steps: 33 | - publish 34 | 35 | ap_southeast_1: 36 | executor: aws-cli/default 37 | environment: 38 | TARGET_REGION: ap-southeast-1 39 | steps: 40 | - publish 41 | 42 | ap_southeast_2: 43 | executor: aws-cli/default 44 | environment: 45 | TARGET_REGION: ap-southeast-2 46 | steps: 47 | - publish 48 | 49 | ca_central_1: 50 | executor: aws-cli/default 51 | environment: 52 | TARGET_REGION: ca-central-1 53 | steps: 54 | - publish 55 | 56 | eu_north_1: 57 | executor: aws-cli/default 58 | environment: 59 | TARGET_REGION: eu-north-1 60 | steps: 61 | - publish 62 | 63 | eu_central_1: 64 | executor: aws-cli/default 65 | environment: 66 | TARGET_REGION: eu-central-1 67 | steps: 68 | - publish 69 | 70 | eu_west_1: 71 | executor: aws-cli/default 72 | environment: 73 | TARGET_REGION: eu-west-1 74 | steps: 75 | - publish 76 | 77 | eu_west_2: 78 | executor: aws-cli/default 79 | environment: 80 | TARGET_REGION: eu-west-2 81 | steps: 82 | - publish 83 | 84 | eu_west_3: 85 | executor: aws-cli/default 86 | environment: 87 | TARGET_REGION: eu-west-3 88 | steps: 89 | - publish 90 | 91 | sa_east_1: 92 | executor: aws-cli/default 93 | environment: 94 | TARGET_REGION: sa-east-1 95 | steps: 96 | - publish 97 | 98 | us_east_1: 99 | executor: aws-cli/default 100 | environment: 101 | TARGET_REGION: us-east-1 102 | steps: 103 | - publish 104 | 105 | us_east_2: 106 | executor: aws-cli/default 107 | environment: 108 | TARGET_REGION: us-east-2 109 | steps: 110 | - publish 111 | 112 | us_west_1: 113 | executor: aws-cli/default 114 | environment: 115 | TARGET_REGION: us-west-1 116 | steps: 117 | - publish 118 | 119 | us_west_2: 120 | executor: aws-cli/default 121 | environment: 122 | TARGET_REGION: us-west-2 123 | steps: 124 | - publish 125 | 126 | workflows: 127 | version: 2 128 | publish: 129 | jobs: 130 | - ap_northeast_1: 131 | context: public-lambda-layers 132 | filters: 133 | branches: 134 | only: 135 | - master 136 | 137 | - ap_northeast_2: 138 | context: public-lambda-layers 139 | filters: 140 | branches: 141 | only: 142 | - master 143 | 144 | - ap_south_1: 145 | context: public-lambda-layers 146 | filters: 147 | branches: 148 | only: 149 | - master 150 | 151 | - ap_southeast_1: 152 | context: public-lambda-layers 153 | filters: 154 | branches: 155 | only: 156 | - master 157 | 158 | - ap_southeast_2: 159 | context: public-lambda-layers 160 | filters: 161 | branches: 162 | only: 163 | - master 164 | 165 | - ca_central_1: 166 | context: public-lambda-layers 167 | filters: 168 | branches: 169 | only: 170 | - master 171 | 172 | - eu_north_1: 173 | context: public-lambda-layers 174 | filters: 175 | branches: 176 | only: 177 | - master 178 | 179 | - eu_central_1: 180 | context: public-lambda-layers 181 | filters: 182 | branches: 183 | only: 184 | - master 185 | 186 | - eu_west_1: 187 | context: public-lambda-layers 188 | filters: 189 | branches: 190 | only: 191 | - master 192 | 193 | - eu_west_2: 194 | context: public-lambda-layers 195 | filters: 196 | branches: 197 | only: 198 | - master 199 | 200 | - eu_west_3: 201 | context: public-lambda-layers 202 | filters: 203 | branches: 204 | only: 205 | - master 206 | 207 | - sa_east_1: 208 | context: public-lambda-layers 209 | filters: 210 | branches: 211 | only: 212 | - master 213 | 214 | - us_east_1: 215 | context: public-lambda-layers 216 | filters: 217 | branches: 218 | only: 219 | - master 220 | 221 | - us_east_2: 222 | context: public-lambda-layers 223 | filters: 224 | branches: 225 | only: 226 | - master 227 | 228 | - us_west_1: 229 | context: public-lambda-layers 230 | filters: 231 | branches: 232 | only: 233 | - master 234 | 235 | - us_west_2: 236 | context: public-lambda-layers 237 | filters: 238 | branches: 239 | only: 240 | - master 241 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | *.zip filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | coverage/ 3 | node_modules/ 4 | temp 5 | yarn.lock 6 | *.log 7 | .DS_Store 8 | lib/ 9 | layer/ 10 | -------------------------------------------------------------------------------- /.husky/post-checkout: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; } 3 | git lfs post-checkout "$@" 4 | -------------------------------------------------------------------------------- /.husky/post-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; } 3 | git lfs post-commit "$@" 4 | -------------------------------------------------------------------------------- /.husky/post-merge: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; } 3 | git lfs post-merge "$@" 4 | -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; } 3 | git lfs pre-push "$@" 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM lambci/lambda-base-2:build 2 | ENV GS_TAG=gs10040 3 | ENV GS_VERSION=10.04.0 4 | 5 | RUN yum install -y wget 6 | 7 | RUN mkdir /usr/local/src/ghostscript && \ 8 | cd /usr/local/src/ghostscript && \ 9 | wget -qO - https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/$GS_TAG/ghostscript-$GS_VERSION.tar.gz | tar -zxf - && \ 10 | cd ghostscript-$GS_VERSION && \ 11 | ./configure --without-luratech && \ 12 | make && make install 13 | 14 | RUN cd /usr/local && \ 15 | zip /tmp/gs.zip bin/gs 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ghostscript for AWS Lambda as a Layer 2 | 3 | ## Getting Started 4 | 5 | Click on Layers and choose "Add a layer", and "Provide a layer version ARN" and enter the following ARN. 6 | 7 | ``` 8 | arn:aws:lambda::764866452798:layer:ghostscript: 9 | ``` 10 | 11 | Works with the following [AWS Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) which 12 | run on Amazon Linux 2: 13 | 14 | - nodejs16.x, nodejs14.x, nodejs12.x, nodejs10.x 15 | - python3.8 16 | - java11 17 | 18 | ## Version Numbers 19 | 20 | | Ghostscript | VERSION | eu-west-3 | 21 | |-------------|---------|-----------| 22 | | v10.04.0 | 17 | 18 | 23 | | v10.02.0 | 15 | 16 | 24 | | v10.0.0 | 13 | 14 | 25 | | v9.56.1 | 12 | 13 | 26 | | v9.55.0 | 9 | 10 | 27 | | v9.52.0 | 8 | 9 | 28 | | v9.50.0 | 6 | 7 | 29 | | v9.20.0 | 1 | 1 | 30 | 31 | ## Where can I find the Ghostscript binary inside of Lambda after I attach the layer? 32 | 33 | You can find it at `/opt/bin/gs` (`/opt` is where Lambda unpacks layers). 34 | 35 | You can run `/opt/bin/gs --version` to make sure Ghostscript is up and running. 36 | 37 | ## Update 38 | 39 | 1. Change version number & git tag in the `Dockerfile` 40 | 2. Run `./build.sh` script which will produce `ghostscript.zip` file 41 | 3. Change version number in the `publish.sh` 42 | 4. Commit & Create a Pull Request 43 | 5. After merging, a new layer version will be published by the CI automatically 44 | 45 | ## License 46 | 47 | MIT © [Shelf](https://shelf.io) 48 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t gs-lambda-layer . 4 | docker run --rm gs-lambda-layer cat /tmp/gs.zip > ./ghostscript.zip 5 | -------------------------------------------------------------------------------- /ghostscript.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:327f7666c5fceaea4b1effe709ab6a9470972c3080080b35a9d69e1054fa9c93 3 | size 15592542 4 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Gemshelf Inc. (shelf.io) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GHOSTSCRIPT_VERSION=10.04.0 4 | LAYER_NAME='ghostscript' 5 | LAYER_VERSION=$( 6 | aws lambda publish-layer-version --region "$TARGET_REGION" \ 7 | --layer-name $LAYER_NAME \ 8 | --zip-file fileb:///home/circleci/project/ghostscript.zip \ 9 | --description "Ghostscript v${GHOSTSCRIPT_VERSION}" \ 10 | --query Version \ 11 | --output text 12 | ) 13 | 14 | aws lambda add-layer-version-permission \ 15 | --region "$TARGET_REGION" \ 16 | --layer-name $LAYER_NAME \ 17 | --statement-id sid1 \ 18 | --action lambda:GetLayerVersion \ 19 | --principal '*' \ 20 | --query Statement \ 21 | --output text \ 22 | --version-number "$LAYER_VERSION" 23 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base"], 3 | "labels": ["dependencies", "backend"], 4 | "ignoreDeps": [ 5 | "@types/node" 6 | ] 7 | } 8 | --------------------------------------------------------------------------------