Skip to content

Commit

Permalink
Deploy Oct 30, 2023 🎃 (#442)
Browse files Browse the repository at this point in the history
* Various dependency updates
* Update to node v18
  • Loading branch information
julienw committed Oct 30, 2023
2 parents 8027cf1 + fd9fd19 commit 54ff9d3
Show file tree
Hide file tree
Showing 20 changed files with 2,293 additions and 1,889 deletions.
18 changes: 9 additions & 9 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
presets: [
["@babel/preset-env", { targets: { node: true }}],
"presets": [
["@babel/preset-env", { "targets": { "node": true } }],
"@babel/preset-typescript"
],
plugins: [
"plugins": [
// Without `loose`, the transformation uses `Object.defineProperty` which
// obeys the spec more, but we get a bundle that's 8kB larger. That was the
// default in babel v6.
["@babel/plugin-proposal-class-properties", { loose: true }],
["@babel/plugin-transform-class-properties", { "loose": true }],

// Like `plugin-proposal-class-properties`, `loose` option is being used
// Like `plugin-transform-class-properties`, `loose` option is being used
// inside of this plugin as well. These plugins must have the same value,
// therefore it's set to true here.
["@babel/plugin-proposal-private-methods", { "loose": true }],
["@babel/plugin-transform-private-methods", { "loose": true }],

// Like `plugin-proposal-class-properties`, `loose` option is being used
// Like `plugin-transform-class-properties`, `loose` option is being used
// inside of this plugin as well. These plugins must have the same value,
// therefore it's set to true here.
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
["@babel/plugin-proposal-object-rest-spread", { useBuiltIns: true }]
["@babel/plugin-transform-private-property-in-object", { "loose": true }],
["@babel/plugin-transform-object-rest-spread", { "useBuiltIns": true }]
]
}
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
executors:
node:
docker:
- image: cimg/node:16.11
- image: cimg/node:18.14
environment:
IMAGE_NAME: mozilla/profiler-server

Expand All @@ -19,7 +19,7 @@ orbs:

commands:
checkout-and-dependencies:
description: "Checkout and install dependencies, managing a cache"
description: 'Checkout and install dependencies, managing a cache'
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -50,7 +50,7 @@ workflows:
- typescript
- license-check
- shellcheck/check:
name: "Shellcheck"
name: 'Shellcheck'
- docker
- docker-publish:
requires:
Expand All @@ -67,7 +67,7 @@ workflows:
weekly:
triggers:
- schedule:
cron: "0 0 * * 4"
cron: '0 0 * * 4'
filters:
branches:
only:
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
# This sets up a remote environment that's necessary to run docker commands.
- setup_remote_docker
- run:
name: "Build the Docker image"
name: 'Build the Docker image'
command: yarn docker:build --pull --build-arg circle_build_url=$CIRCLE_BUILD_URL
- run:
name: "Start the docker image in a container and check it's running"
Expand Down
9 changes: 2 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ module.exports = {
node: true,
},
parser: '@babel/eslint-parser',
extends: [
'eslint:recommended',
// This works with the prettier plugin, this needs to be at the end always.
// Replace it with the "prettier" config if we remove the plugin.
'plugin:prettier/recommended',
],
extends: ['eslint:recommended', 'prettier'],
parserOptions: {
ecmaVersion: '2017',
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
sourceType: 'module',
},
plugins: ['@babel', 'import', 'prettier'],
plugins: ['@babel', 'import'],
settings: {
'import/resolver': {
node: {
Expand Down
74 changes: 49 additions & 25 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Be careful to replace some placeholders with the real values.

We version all the business endpoinds described in this document. This is
handled by a header:

```
Accept: application/vnd.firefox-profiler+json;version=1.0
```
Expand All @@ -22,27 +23,34 @@ These endpoints are CORS-friendly and can be called from any website.
## Upload: `POST /compressed-store`

Input:
* The data to upload as the raw body. Note the service supports the chunked

- The data to upload as the raw body. Note the service supports the chunked
encoding too.

Output:
* A JWT token if successful (HTTP status is 200)

- A JWT token if successful (HTTP status is 200)

Possible errors:
* 400: Bad Request if the pushed data isn't a gzipped JSON
* 413: Payload Too Large if the pushed data is too big
* 500: unexpected error

- 400: Bad Request if the pushed data isn't a gzipped JSON
- 413: Payload Too Large if the pushed data is too big
- 500: unexpected error

### How to use it from the command-line

You can use the utility [tools/generate-file.js](../tools/generate-file.js) to generate
big files suitable to use with the server. For example:

```
node tools/generate-file.js 5m ____PATH_TO_FILE____
```

will generate a file of 5 MiB that the server will accept. This is a JSON file
filled in with random values.

Then you can push the file to the storage:

```
curl -i -X POST --data-binary @____PATH_TO_FILE____ \
-H 'Accept: application/vnd.firefox-profiler+json;version=1.0' \
Expand All @@ -65,28 +73,33 @@ You can decode the JWT to get the profile token using our tool
that you can just copy paste because it has no dependency.

From the JWT token, this gets the profile token:

```
echo '____PUT_JWT_TOKEN_HERE____' | tools/decode_jwt_payload.py
```

## Delete profile: `DELETE /profile/____PROFILE_TOKEN____`

Inputs:
* the JWT token in the header `Authorization`.
* the profile token in the URL.

- the JWT token in the header `Authorization`.
- the profile token in the URL.

Output:
* A 200 status with some text explaining what happened.

- A 200 status with some text explaining what happened.

Possible errors:
* 400 Bad Request: if no profile token was passed.
* 401 Forbidden: if the JWT is absent or invalid.
* 404 Not Found: if there's no data for this profile token.
* 500: for an unexpected error.

- 400 Bad Request: if no profile token was passed.
- 401 Forbidden: if the JWT is absent or invalid.
- 404 Not Found: if there's no data for this profile token.
- 500: for an unexpected error.

### With the command line

This is how we delete the previously uploaded file:

```
curl \
--include \
Expand All @@ -106,15 +119,18 @@ This returns a status 200 if the deletion is successful.
This service allows to shorten a profiler-related URL.

Input: a JSON object containing:
* a property `longUrl`: the URL to be shortened.

- a property `longUrl`: the URL to be shortened.

Output: a JSON object containing:
* a property `shortUrl`: the shortened URL.

- a property `shortUrl`: the shortened URL.

Possible errors:
* 400 Bad Request: if the input json is malformed, the property `longUrl` is

- 400 Bad Request: if the input json is malformed, the property `longUrl` is
missing, or it doesn't start with `https://profiler.firefox.com/`.
* 500: for an unexpected error.
- 500: for an unexpected error.

### With the command line:

Expand All @@ -124,33 +140,42 @@ curl -i -X POST \
-H 'Accept: application/vnd.firefox-profiler+json;version=1.0' \
____SERVER_DOMAIN____/shorten
```

This should return a json that looks like:

```json
{ "shortUrl": "https://share.firefox.dev/XXXXXX" }
```

## Expand URL: `POST /expand`

This service allows to expand a profiler-related URL.

Input: a JSON object containing:
* a property `shortUrl`: the shortened URL.

- a property `shortUrl`: the shortened URL.

Output: a JSON object containing:
* a property `longUrl`: the long URL

- a property `longUrl`: the long URL

Possible errors:
* 400 Bad Request: if the input json is malformed, the property `shortUrl` is
missing, or the resulting long URL doesn't start with `https://profiler.firefox.com/`.
* 500: for an unexpected error.

- 400 Bad Request: if the input json is malformed, the property `shortUrl` is
missing, or the resulting long URL doesn't start with `https://profiler.firefox.com/`.
- 500: for an unexpected error.

### With the command line:

```
curl -i -X POST \
--data-binary '{ "shortUrl": "https://share.firefox.dev/XXXXXX" }' \
-H 'Accept: application/vnd.firefox-profiler+json;version=1.0' \
____SERVER_DOMAIN____/expand
```

This should return a json that looks like:

```json
{ "longUrl": "https://profiler.firefox.com/" }
```
Expand All @@ -159,8 +184,7 @@ This should return a json that looks like:

These endpoints don't support CORS and aren't versioned:

* `/__version__`: returns the version information for the currently deployed
- `/__version__`: returns the version information for the currently deployed
server.
* `/__heartbeat__`: returns 200 if the server and 3rd-party servers are up.
* `/__lbheartbeat__`: returns 200 if the server is up.

- `/__heartbeat__`: returns 200 if the server and 3rd-party servers are up.
- `/__lbheartbeat__`: returns 200 if the server is up.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# instead of the default. See docs-developer/docker.md for more information.

# Setup a container and build the project in it
# We set up a node 16 running in latest Debian stable called bullseye, in the
# We set up a node 18 running in latest Debian stable called bullseye, in the
# "slim" flavor because we don't need the big version.
FROM node:16-bullseye-slim AS builder
FROM node:18-bullseye-slim AS builder

# Create the user we'll run the build commands with. Its home is configured to
# be the directory /app. It helps avoiding warnings when running tests and
Expand Down Expand Up @@ -86,7 +86,7 @@ RUN du -khs node_modules
RUN ls -la

# ----- And now, let's build the runtime container -----
FROM node:16-bullseye-slim
FROM node:18-bullseye-slim
ENV NODE_ENV="production"
ENV PORT=8000

Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Firefox profiler server

[![Matrix][matrix-badge]][matrix]

Welcome to the repository for the Firefox profiler server! This server
implements some APIs needed by the profiler UI.

Here are some links to know more:
* The [Firefox Profiler]
* The [Profiler repository]

- The [Firefox Profiler]
- The [Profiler repository]

## APIs

The APIs are documented in [API.md](./API.md).

## Develop and running the server locally

### Install the local tooling

You will need a recent enough version of [Yarn v1](http://classic.yarnpkg.com/),
version 1.10 is known to work correctly.
You can install it into your home directory on Linux and probably OS X with:
Expand All @@ -24,9 +28,11 @@ wget https://yarnpkg.com/install.sh
chmod a+x install.sh
./install.sh
```

or [follow the instructions specific to your OS on Yarn's website](https://classic.yarnpkg.com/en/docs/install).

### Download the profiler code and install its dependencies

To download and prepare the Firefox Profiler server run:

```bash
Expand Down Expand Up @@ -54,10 +60,13 @@ in [docs-developer/google-storage.md](docs-developer/google-storage.md) explains
further how to configure Google Cloud Storage.

### Run the server

Lastly you can run the server with:

```bash
yarn start
```

This will start the server on port 5252.

## Build or pull a docker image
Expand All @@ -67,21 +76,24 @@ image. Find more [in the dedicated documentation](docs-developer/docker.md).

Also the images we use for production [are public](https://hub.docker.com/r/mozilla/profiler-server/tags),
you can pull latest versions with:
* for master: `docker pull mozilla/profiler-server:master-latest`
* for production: `docker pull mozilla/profiler-server:production-latest`

- for master: `docker pull mozilla/profiler-server:master-latest`
- for production: `docker pull mozilla/profiler-server:production-latest`

Again, look the [dedicated documentation](docs-developer/docker.md) to know more.

## Discussion

Say hello on Matrix in the [*Firefox Profiler* channel (*#profiler:mozilla.org*)][matrix].
Say hello on Matrix in the [_Firefox Profiler_ channel (_#profiler:mozilla.org_)][matrix].

## License

[MPL v2](./LICENSE)

[matrix]: https://chat.mozilla.org/#/room/#profiler:mozilla.org

<!-- chat.mozilla.org's "real" server is mozilla.modular.im. -->

[matrix-badge]: https://img.shields.io/matrix/profiler:mozilla.org?server_fqdn=mozilla.modular.im&label=matrix
[Firefox Profiler]: https://profiler.firefox.com/
[Profiler repository]: https://github.com/firefox-devtools/profiler/
Loading

0 comments on commit 54ff9d3

Please sign in to comment.