Skip to content

Commit

Permalink
Merge pull request #162 from humanmade/v3-branch
Browse files Browse the repository at this point in the history
Switch to typescript and response streaming
  • Loading branch information
joehoyle authored Nov 20, 2023
2 parents ed7981c + bbf4860 commit 8702dfa
Show file tree
Hide file tree
Showing 37 changed files with 21,588 additions and 6,985 deletions.
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

0 comments on commit 8702dfa

Please sign in to comment.