From f9d62600dcf4a714d13909d7d040ad30759e387b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Mar 2023 17:25:46 +0000 Subject: [PATCH 1/6] fix(docker): bump node from 18.14.2-alpine3.17 to 18.15.0-alpine3.17 Bumps node from 18.14.2-alpine3.17 to 18.15.0-alpine3.17. --- updated-dependencies: - dependency-name: node dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fc174c61..1bdc70e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM} node:18.14.2-alpine3.17@sha256:0d2712ac2b2c1149391173de670406f6e3dbdb1b2ba44e8530647e623e0e1b17 as build +FROM --platform=${TARGETPLATFORM} node:18.15.0-alpine3.17@sha256:f605fcd5254d0e398e04d93c7b11e2aec2a6e1aeb7da1f99bc40cd101dd8cde4 as build # set app basepath ENV HOME=/home/app @@ -26,7 +26,7 @@ RUN pnpm install --prod --frozen-lockfile --ignore-scripts RUN rm -rf $PROJECT_WORKDIR/.pnpm-store # start new image for lower size -FROM --platform=${TARGETPLATFORM} node:18.14.2-alpine3.17@sha256:0d2712ac2b2c1149391173de670406f6e3dbdb1b2ba44e8530647e623e0e1b17 +FROM --platform=${TARGETPLATFORM} node:18.15.0-alpine3.17@sha256:f605fcd5254d0e398e04d93c7b11e2aec2a6e1aeb7da1f99bc40cd101dd8cde4 # dumb-init registers signal handlers for every signal that can be caught RUN apk update && apk add --no-cache dumb-init From 3fe7e2cc5f3028ddcdd927e9c020c0772304c719 Mon Sep 17 00:00:00 2001 From: Adrian Trzeciak Date: Thu, 2 Feb 2023 18:10:19 +0100 Subject: [PATCH 2/6] feat: unprotected unversioned health route --- src/plugins/remote-cache/index.ts | 17 ++++++++++++++++- src/plugins/remote-cache/routes/get-health.ts | 14 ++++++++++++++ src/plugins/remote-cache/routes/index.ts | 1 + test/local.ts | 8 ++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/plugins/remote-cache/routes/get-health.ts diff --git a/src/plugins/remote-cache/index.ts b/src/plugins/remote-cache/index.ts index 78298dc9..b36c76b5 100644 --- a/src/plugins/remote-cache/index.ts +++ b/src/plugins/remote-cache/index.ts @@ -1,6 +1,13 @@ import { FastifyInstance } from 'fastify' import { badRequest, unauthorized } from '@hapi/boom' -import { getArtifact, putArtifact, artifactsEvents, headArtifact, getStatus } from './routes' +import { + getArtifact, + putArtifact, + artifactsEvents, + headArtifact, + getStatus, + getHealth, +} from './routes' import { createLocation } from './storage' import { STORAGE_PROVIDERS } from '../../env' @@ -33,6 +40,10 @@ async function turboRemoteCache( let authHeader = request.headers['authorization'] authHeader = Array.isArray(authHeader) ? authHeader.join() : authHeader + if (request.url.includes('health')) { + return + } + if (!authHeader) { throw badRequest(`Missing Authorization header`) } @@ -58,6 +69,10 @@ async function turboRemoteCache( }), ) + await instance.register(async i => { + i.route(getHealth) + }) + await instance.register( async function (i) { i.route(getArtifact) diff --git a/src/plugins/remote-cache/routes/get-health.ts b/src/plugins/remote-cache/routes/get-health.ts new file mode 100644 index 00000000..52989c75 --- /dev/null +++ b/src/plugins/remote-cache/routes/get-health.ts @@ -0,0 +1,14 @@ +import type { Server } from 'http' +import type { RouteOptions, RawReplyDefaultExpression, RawRequestDefaultExpression } from 'fastify' + +export const getHealth: RouteOptions< + Server, + RawRequestDefaultExpression, + RawReplyDefaultExpression +> = { + method: 'GET', + url: '/health', + async handler(req, reply) { + reply.send('Server is running 🙌') + }, +} diff --git a/src/plugins/remote-cache/routes/index.ts b/src/plugins/remote-cache/routes/index.ts index 4f980165..0e9277c0 100644 --- a/src/plugins/remote-cache/routes/index.ts +++ b/src/plugins/remote-cache/routes/index.ts @@ -3,3 +3,4 @@ export { headArtifact } from './head-artifact' export { putArtifact } from './put-artifact' export { artifactsEvents } from './artifacts-events' export { getStatus } from './get-status' +export { getHealth } from './get-health' diff --git a/test/local.ts b/test/local.ts index 3d0ecd33..b8e485cc 100644 --- a/test/local.ts +++ b/test/local.ts @@ -165,4 +165,12 @@ test(`local'`, async t => { t2.equal(response.statusCode, 200) t2.same(response.json(), { status: 'enabled' }) }) + t.test('should return 200 when GET health is called', async t2 => { + t2.plan(1) + const response = await app.inject({ + method: 'GET', + url: `/health`, + }) + t2.equal(response.statusCode, 200) + }) }) From 7f6888494ae0e5e23a440df6c811e684ec6fa7ef Mon Sep 17 00:00:00 2001 From: Adrian Trzeciak Date: Tue, 21 Mar 2023 08:08:05 +0100 Subject: [PATCH 3/6] feat: unprotected health route --- src/plugins/remote-cache/index.ts | 52 ++++++++----------- src/plugins/remote-cache/routes/get-health.ts | 14 ----- src/plugins/remote-cache/routes/index.ts | 1 - test/local.ts | 9 ++-- 4 files changed, 27 insertions(+), 49 deletions(-) delete mode 100644 src/plugins/remote-cache/routes/get-health.ts diff --git a/src/plugins/remote-cache/index.ts b/src/plugins/remote-cache/index.ts index b36c76b5..48553eec 100644 --- a/src/plugins/remote-cache/index.ts +++ b/src/plugins/remote-cache/index.ts @@ -1,13 +1,6 @@ import { FastifyInstance } from 'fastify' import { badRequest, unauthorized } from '@hapi/boom' -import { - getArtifact, - putArtifact, - artifactsEvents, - headArtifact, - getStatus, - getHealth, -} from './routes' +import { getArtifact, putArtifact, artifactsEvents, headArtifact, getStatus } from './routes' import { createLocation } from './storage' import { STORAGE_PROVIDERS } from '../../env' @@ -35,24 +28,6 @@ async function turboRemoteCache( }, ) - const tokens = new Set(allowedTokens) - instance.addHook('onRequest', async function (request) { - let authHeader = request.headers['authorization'] - authHeader = Array.isArray(authHeader) ? authHeader.join() : authHeader - - if (request.url.includes('health')) { - return - } - - if (!authHeader) { - throw badRequest(`Missing Authorization header`) - } - const [, token] = authHeader.split('Bearer ') - if (!tokens.has(token)) { - throw unauthorized(`Invalid authorization token`) - } - }) - instance.decorate( 'location', createLocation(provider, { @@ -69,16 +44,33 @@ async function turboRemoteCache( }), ) - await instance.register(async i => { - i.route(getHealth) - }) - await instance.register( async function (i) { + const tokens = new Set(allowedTokens) + + i.addHook('onRequest', async function (request) { + let authHeader = request.headers['authorization'] + authHeader = Array.isArray(authHeader) ? authHeader.join() : authHeader + + if (!authHeader) { + throw badRequest(`Missing Authorization header`) + } + const [, token] = authHeader.split('Bearer ') + if (!tokens.has(token)) { + throw unauthorized(`Invalid authorization token`) + } + }) + i.route(getArtifact) i.route(headArtifact) i.route(putArtifact) i.route(artifactsEvents) + }, + { prefix: `/${apiVersion}` }, + ) + + await instance.register( + async i => { i.route(getStatus) }, { prefix: `/${apiVersion}` }, diff --git a/src/plugins/remote-cache/routes/get-health.ts b/src/plugins/remote-cache/routes/get-health.ts deleted file mode 100644 index 52989c75..00000000 --- a/src/plugins/remote-cache/routes/get-health.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { Server } from 'http' -import type { RouteOptions, RawReplyDefaultExpression, RawRequestDefaultExpression } from 'fastify' - -export const getHealth: RouteOptions< - Server, - RawRequestDefaultExpression, - RawReplyDefaultExpression -> = { - method: 'GET', - url: '/health', - async handler(req, reply) { - reply.send('Server is running 🙌') - }, -} diff --git a/src/plugins/remote-cache/routes/index.ts b/src/plugins/remote-cache/routes/index.ts index 0e9277c0..4f980165 100644 --- a/src/plugins/remote-cache/routes/index.ts +++ b/src/plugins/remote-cache/routes/index.ts @@ -3,4 +3,3 @@ export { headArtifact } from './head-artifact' export { putArtifact } from './put-artifact' export { artifactsEvents } from './artifacts-events' export { getStatus } from './get-status' -export { getHealth } from './get-health' diff --git a/test/local.ts b/test/local.ts index b8e485cc..c8d980b2 100644 --- a/test/local.ts +++ b/test/local.ts @@ -153,7 +153,7 @@ test(`local'`, async t => { t2.equal(response.statusCode, 200) t2.same(response.json(), {}) }) - t.test('should return 200 when GET artifacts/status is called', async t2 => { + t.test('should return 200 when GET artifacts/status is calle with auth header', async t2 => { t2.plan(2) const response = await app.inject({ method: 'GET', @@ -165,12 +165,13 @@ test(`local'`, async t => { t2.equal(response.statusCode, 200) t2.same(response.json(), { status: 'enabled' }) }) - t.test('should return 200 when GET health is called', async t2 => { - t2.plan(1) + t.test('should return 200 when GET artifacts/status is calle without auth header', async t2 => { + t2.plan(2) const response = await app.inject({ method: 'GET', - url: `/health`, + url: `/v8/artifacts/status`, }) t2.equal(response.statusCode, 200) + t2.same(response.json(), { status: 'enabled' }) }) }) From 1b7ad8f11db402310ba178e02e23f72abe05bc7b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 21 Mar 2023 11:33:30 +0000 Subject: [PATCH 4/6] chore(release): 1.13.3 [skip ci] ## [1.13.3](https://github.com/ducktors/turborepo-remote-cache/compare/v1.13.2...v1.13.3) (2023-03-21) ### Bug Fixes * **docker:** bump node from 18.14.2-alpine3.17 to 18.15.0-alpine3.17 ([f9d6260](https://github.com/ducktors/turborepo-remote-cache/commit/f9d62600dcf4a714d13909d7d040ad30759e387b)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e76d9d..b81de8ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.13.3](https://github.com/ducktors/turborepo-remote-cache/compare/v1.13.2...v1.13.3) (2023-03-21) + + +### Bug Fixes + +* **docker:** bump node from 18.14.2-alpine3.17 to 18.15.0-alpine3.17 ([f9d6260](https://github.com/ducktors/turborepo-remote-cache/commit/f9d62600dcf4a714d13909d7d040ad30759e387b)) + ## [1.13.2](https://github.com/ducktors/turborepo-remote-cache/compare/v1.13.1...v1.13.2) (2023-02-26) diff --git a/package.json b/package.json index e4ab506b..ed8aef52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "turborepo-remote-cache", - "version": "1.13.2", + "version": "1.13.3", "description": "Turborepo remote cache server", "main": "build", "author": "Maksim Sinik ", From a1423ce28d8b6575846bdd73671dfa4f9e70a9a5 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 21 Mar 2023 12:42:14 +0100 Subject: [PATCH 5/6] chore: update docker badge on readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ff254fb..3b633a44 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ --- ![remote_cache_1](https://user-images.githubusercontent.com/1620916/216358421-36a63b0e-d1f6-484f-a4ca-6a7119cc0816.jpg) -[![GitHub package.json version](https://img.shields.io/github/package-json/v/ducktors/turborepo-remote-cache)](https://github.com/ducktors/turborepo-remote-cache/releases) [![CI](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml) [![Release](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml) [![Docker](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/bbb26ca5247dee70dde0/maintainability)](https://codeclimate.com/github/ducktors/turborepo-remote-cache/maintainability) [![Coverage Status](https://coveralls.io/repos/github/ducktors/turborepo-remote-cache/badge.svg?branch=main)](https://coveralls.io/github/ducktors/turborepo-remote-cache?branch=main) [![Docker Pulls](https://img.shields.io/docker/pulls/fox1t/turborepo-remote-cache?logo=docker)](https://hub.docker.com/r/fox1t/turborepo-remote-cache) [![npm](https://img.shields.io/npm/dt/turborepo-remote-cache)](https://www.npmjs.com/package/turborepo-remote-cache) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) +[![GitHub package.json version](https://img.shields.io/github/package-json/v/ducktors/turborepo-remote-cache)](https://github.com/ducktors/turborepo-remote-cache/releases) [![CI](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml) [![Release](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml) [![Docker](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml/badge.svg)](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/bbb26ca5247dee70dde0/maintainability)](https://codeclimate.com/github/ducktors/turborepo-remote-cache/maintainability) [![Coverage Status](https://coveralls.io/repos/github/ducktors/turborepo-remote-cache/badge.svg?branch=main)](https://coveralls.io/github/ducktors/turborepo-remote-cache?branch=main) [![Docker Pulls](https://img.shields.io/docker/pulls/ducktors/turborepo-remote-cache?logo=docker)](https://hub.docker.com/r/ducktors/turborepo-remote-cache) [![npm](https://img.shields.io/npm/dt/turborepo-remote-cache)](https://www.npmjs.com/package/turborepo-remote-cache) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) [![All Contributors](https://img.shields.io/badge/all_contributors-17-orange.svg?style=flat-square)](#contributors-) From 27484a3192a43a6a96d8e9ab3e44e6f1aad546c6 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 21 Mar 2023 12:44:49 +0100 Subject: [PATCH 6/6] chore: update docker image reference. moving from fox1t to ducktors --- .github/workflows/ci.yml | 22 +++------------------- docs/deployment-environments.md | 4 ++-- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4682c94c..1ea2f35b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,32 +86,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Get package version - id: package-version - uses: martinbeentjes/npm-get-version-action@main - with: - path: . - - name: Set correct environment - run: | - TAG=${{ steps.package-version.outputs.current-version}} - echo "TAG=$TAG" >> "$GITHUB_ENV" - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: fox1t/turborepo-remote-cache - flavor: latest=true - tags: type=raw,value=${{ env.TAG }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build and push + - name: Test commit Build uses: docker/build-push-action@v4 with: context: . platforms: linux/x86_64,linux/arm64 push: false - tags: ${{ steps.meta.outputs.tags }} + tags: ducktors/turborepo-remote-cache:local cache-from: | - fox1t/turborepo-remote-cache:cache + ducktors/turborepo-remote-cache:cache diff --git a/docs/deployment-environments.md b/docs/deployment-environments.md index 9f8616a3..eb44c0e5 100644 --- a/docs/deployment-environments.md +++ b/docs/deployment-environments.md @@ -22,7 +22,7 @@ __Note: Local storage isn't supported for this deployment method.__ [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fducktors%2Fturborepo-remote-cache&env=NODE_ENV,TURBO_TOKEN,STORAGE_PROVIDER,STORAGE_PATH,S3_ACCESS_KEY,S3_SECRET_KEY,S3_REGION,S3_ENDPOINT&envDescription=The%20server%20needs%20several%20credentials.%20The%20required%20environmental%20variables%20can%20be%20found%20here%3A&envLink=https%3A%2F%2Fgithub.com%2Fducktors%2Fturborepo-remote-cache%23readme) ## Deploy on Docker -You can find the image on the [dockerhub](https://hub.docker.com/r/fox1t/turborepo-remote-cache). +You can find the image on the [dockerhub](https://hub.docker.com/r/ducktors/turborepo-remote-cache). 1. create an `.env` file, containing all of the env vars you need. Check [environment variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables) for more info. ```sh @@ -39,7 +39,7 @@ S3_ENDPOINT= ``` 2. run the image using the `.env` file created on the step one. ```sh -docker run --env-file=.env -p 3000:3000 fox1t/turborepo-remote-cache +docker run --env-file=.env -p 3000:3000 ducktors/turborepo-remote-cache ``` ## Deploy on DigitalOcean