Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to typescript and response streaming #162

Merged
merged 37 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
13c0482
Switch to typescript and response streaming
joehoyle Jul 27, 2023
0fb0657
Remove built files
joehoyle Jul 27, 2023
6010bb8
Simplify docs
joehoyle Jul 27, 2023
96f68a3
Build in GH actions
joehoyle Jul 27, 2023
7f494bf
Build on this PR too
joehoyle Jul 27, 2023
408509c
Run tsc
joehoyle Jul 27, 2023
066cc60
Add typescript
joehoyle Jul 27, 2023
428a929
Add global types
joehoyle Jul 27, 2023
0b504ea
Fix GIF response content type
joehoyle Jul 27, 2023
c0762d6
Support for animated gifs
joehoyle Jul 27, 2023
fb943ce
Add back package.json
joehoyle Jul 27, 2023
ce47b0c
Build zip and upload
joehoyle Jul 27, 2023
f11781f
Add release upload file workflow
joehoyle Jul 27, 2023
96a4beb
Checkout v3
joehoyle Jul 27, 2023
ef68a3f
Add support for signed URLs
joehoyle Jul 28, 2023
d6224e0
Add a local nodejs server
joehoyle Jul 28, 2023
d84dec9
Docker build
joehoyle Jul 28, 2023
40379d3
Build too
joehoyle Jul 28, 2023
124f59f
Only build edge from master
joehoyle Jul 28, 2023
87110fa
Update src/lambda-handler.ts
joehoyle Aug 9, 2023
d558519
Update src/lib.ts
joehoyle Aug 9, 2023
593e3e0
Update src/lib.ts
joehoyle Aug 9, 2023
2efae9d
Apply suggestions from code review
joehoyle Aug 9, 2023
c019893
PR Feedback for type
joehoyle Aug 9, 2023
ed857d5
Extract resize buffer result
joehoyle Aug 9, 2023
2bf4127
Remove ts-ignore
joehoyle Aug 9, 2023
c92240e
Coding reformatting
joehoyle Aug 9, 2023
19b3ef9
Add lint npm command
joehoyle Aug 9, 2023
c774b85
Override eslint dep
joehoyle Aug 9, 2023
05bcae8
Fix eslint deps
joehoyle Aug 9, 2023
4ebe817
Document SAM
joehoyle Aug 9, 2023
eb59e4c
Fix doc
joehoyle Aug 9, 2023
baa06dc
Apply suggestions from code review
joehoyle Sep 21, 2023
ed4d6ef
Lowercase and trim signed headers
joehoyle Sep 21, 2023
ae5bed3
No need for Buffer hinting
joehoyle Sep 21, 2023
17f1059
Merge branch 'v3-branch' of github.com:humanmade/tachyon into v3-branch
joehoyle Sep 21, 2023
bbf4860
Merge branch 'master' into v3-branch
joehoyle Sep 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,38 @@ on:
push:
branches:
- 'master'
release:
types: [released]
pull_request:
types: [opened, synchronize, reopened]

tags:
- "*"
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Docker meta
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm install
- run: npx tsc
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: humanmade/tachyon
tags: |
type=edge,branch=master
type=ref,event=tag
type=ref,event=pr
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
- uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push latest
- name: Build and push latest
uses: docker/build-push-action@v2
with:
file: Dockerfile.multiarch
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build PR

on:
pull_request:
branches:
- '**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm install
- run: npx tsc
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- run: npm run build
- run: npm run build-zip
- uses: actions/upload-artifact@v3
with:
path: lambda.zip
name: lambda

27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm install
- run: npx tsc
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- run: npm run build
- run: npm run build-zip
- uses: softprops/action-gh-release@v1
with:
files: lambda.zip
name: lambda

6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules/
.idea
lambda.zip
config.json
test-filesize/output
.aws-sam/
test-filesize
.DS_Store
dist/
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

14 changes: 10 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Contributing

## Release Process
## Building

You'll need to [install the AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) as AWS SAM is used to build the ZIP and text the fixtures.

```
npm install
npm run build // Builds the function for use in SAM
npm run test // Invoke a function via SAM using a fixture from ./events/
```


1. Create and push a new tag following the convention `vx.x.x`
1. Build a new ZIP file by running `npm run build-node-modules && npm run build-zip`
1. Publish a new GitHub release, uploading `lambda.zip` as the built artifact to GitHub
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM public.ecr.aws/lambda/nodejs:14
COPY node_modules/ /var/task/node_modules
COPY server.js /var/task/
COPY index.js /var/task
COPY proxy-file.js /var/task
FROM public.ecr.aws/lambda/nodejs:18
COPY package.json /var/task/
COPY package-lock.json /var/task/
RUN npm install --omit=dev
COPY dist /var/task/dist

ARG AWS_REGION
ARG AWS_S3_BUCKET
ARG AWS_S3_ENDPOINT
# Set environment variables, backwards compat with Tachyon 2x.
ARG S3_REGION
ARG S3_BUCKET
ARG S3_ENDPOINT
ARG PORT

# Start the reactor
EXPOSE ${PORT:-8080}
ENTRYPOINT /var/lang/bin/node server.js ${PORT:-8080}
ENTRYPOINT /var/lang/bin/node dist/server.js ${PORT:-8080}
28 changes: 0 additions & 28 deletions Dockerfile.multiarch

This file was deleted.

47 changes: 18 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,34 @@
</tr>
</table>

Tachyon is a faster than light image resizing service that runs on AWS. Super simple to set up, highly available and very performant.

Tachyon is built with some strong opinions and assumptions:

- Runs on AWS (using CloudFront, Lambda and API Gateway.)
- Expects original image files to be stored on Amazon S3.
- Only supports simple image resizing, not a full image manipulation service.
## Setup

Tachyon works best with WordPress, coupled with [S3 Uploads](https://github.com/humanmade/s3-uploads) and the [Tachyon Plugin](https://github.com/humanmade/tachyon-plugin).
Tachyon comes in two parts: the server to serve images and the [plugin to use it](./docs/plugin.md). To use Tachyon, you need to run at least one server, as well as the plugin on all sites you want to use it.

**[View Documentation →](docs/README.md)**
## Installation on AWS Lambda

![](docs/diagram.png)
We require using Tachyon on [AWS Lambda](https://aws.amazon.com/lambda/details/) to offload image processing task in a serverless configuration. This ensures you don't need lots of hardware to handle thousands of image resize requests, and can scale essentially infinitely. One Tachyon stack is required per S3 bucket, so we recommend using a common region bucket for all sites, which then only requires a single Tachyon stack per region.

## Documentation

**[View Documentation →](docs/README.md)**


### Setup

Tachyon comes in two parts: the [server to serve images](docs/server.md), and the [plugin to use it](docs/plugin.md). To use Tachyon, you need to run at least one server, as well as the plugin on all sites you want to use it.

The server is also available as a [Docker image](docs/docker.md), which can be used in production or to set up a local test environment.
Tachyon requires the following Lambda Function spec:

## Using
- Runtime: Node JS 18
- Function URL activated
- Env vars:
- S3_BUCKET=my-bucket
- S3_REGION=my-bucket-region
- S3_ENDPOINT=http://my-custom-endpoint (optional)
- S3_FORCE_PATH_STYLE=1 (optional)

Tachyon provides a simple HTTP interface in the form of:
Take the `lambda.zip` from the latest release and upload it to your function.

`https://{tachyon-domain}/my/image/path/on/s3.png?w=100&h=80`

It's really that simple!

**[View Args Reference →](docs/using.md)**

### Upgrading

When upgrading, be sure to perform an API Gateway deployment from the AWS Console. Navigate to API Gateway from the AWS Console and select the "Tachyon" API. Once selected, click "Actions" and then "Deploy API."
## Documentation

![](docs/perform-deployment.png)
* [Plugin Setup](./docs/plugin.md)
* [Using Tachyon](./docs/using.md)
* [Hints and Tips](./docs/tips.md)


## Credits
Expand Down
Loading