# toolbox-optimizer-docker

> Thin wrapper around the amp-optimizer

Latest version **2.7.1-alpha.0** (published 2020-12-01) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install toolbox-optimizer-docker
pnpm add toolbox-optimizer-docker
yarn add toolbox-optimizer-docker
bun add toolbox-optimizer-docker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.7.1-alpha.0 |
| Published | 2020-12-01 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | AMPHTML Team |
| Maintainers | patrickkettner |
| Keywords | amp, optimizer, docker |

## Links

- npm: https://www.npmjs.com/package/toolbox-optimizer-docker
- Repository: https://github.com/ampproject/amp-toolbox
- Homepage: https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer
- Issues: https://github.com/ampproject/amp-toolbox/issues
- npm.io page: https://npm.io/package/toolbox-optimizer-docker

## Dependencies (1)

- [@ampproject/toolbox-optimizer](https://npm.io/package/@ampproject/toolbox-optimizer.md) ^2.6.0

## Recent versions

- 2.7.1-alpha.0 (latest) — 2020-12-01

## README

## Introduction

amp-optimizer-docker is a [Docker](https://www.docker.com/) container that exposes an [AMP Optimizer](https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer) server for optimizing your amphtml using the same server-side-rendering optimizations as the [Google AMP Cache](https://developers.google.com/amp/cache).

## How it works

The AMP Optimizer server accepts `POST` requests at port `3000` and requires an HTML body. It then runs the HTML through the [optimizer](https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer) package, and returns the result as the response.

## Configuration

There are two different kinds of configuration you can supply to the container:
1. Static configuration via environment variables: On startup, the container will search for environment variables prefixed with `AMP_OPTIMIZER_` and pass the values as configuration options when initializing the underlying optimizer library. The full list of options are available [here](https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer#options). Options should be specified in SCREAMING_SNAKE_CASE as opposed to camelCase. For example, in order to configure the `preloadHeroImage` option, you would declare the environment variable named: `AMP_OPTIMIZER_PRELOAD_HERO_IMAGE`.
2. Per-request configuration: there are some options that can only be set on a per-request basis. For example, the `canonical` flag for specifying an AMP page's canonical link. These can be specified via query params, e.g. `/?canonical=http://example.com`.

## Usage

### Running a basic optimizer server

 via:

```
$ docker pull amp-toolbox-docker-optimizer
$ docker run -it amp-toolbox-docker-optimizer
```

### More complex configurations

The `amp-toolbox-docker-optimizer` image can be layered and composed using any of the usual container orchestration tools, like [Docker Compose](https://docs.docker.com/compose/) or [Kubernetes](https://kubernetes.io/). An example of using Docker Compose is provided under the `demo` directory.

## Best Practice: Cache server-side-rendered AMPs

To achieve best performance, transformations shouldn't be applied for
every request. Instead, transformations should only be applied the *first time*
a page is requested, and the results then cached. Caching can happen on the CDN
level, on the site's internal infrastructure (e.g.: Memcached), or even on the
server itself, if the set of pages is small enough to fit in memory.

---
_Source: https://npm.io/package/toolbox-optimizer-docker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
