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

Git clone cache #451

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

defaults: &defaults
docker:
- image: cimg/node:14.17.6
- image: cimg/node:16.18.0
working_directory: ~/broker

commands:
Expand Down Expand Up @@ -41,6 +41,18 @@ jobs:
- run:
name: Run tests
command: npm test && npm run test:bin
pkg:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/broker
- run:
name: Package
command: "npm run prepare && rm ./dist/client-templates/github && npx --yes pkg . --compress Brotli"
- store_artifacts:
path: binary-releases/snyk-broker-x64
destination: artifact-snyk-broker
release:
<<: *defaults
steps:
Expand All @@ -63,6 +75,10 @@ workflows:
name: Test
requires:
- Install DEV
- pkg:
name: Package
requires:
- Test
- release:
name: Release to GitHub
context: nodejs-lib-release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ accept.json
package-lock.json
/dist
.eslintcache
binary-releases


# Test coverage reports
Expand Down
4 changes: 3 additions & 1 deletion dockerfiles/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

FROM ubuntu:20.04

# Have to use apt-get for git, otherwise apt autoremove removes it!
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node \
&& apt update && apt upgrade -y && apt install gpg curl xz-utils -y
Expand Down Expand Up @@ -50,6 +51,7 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& node --version \
&& npm --version

RUN apt remove gpg curl xz-utils libsqlite3-0 -y && apt autoremove -y --purge
# Have to install Git here otherwise it gets removed by apt autoremove, despite being marked as manually installed!
RUN apt remove gpg curl xz-utils libsqlite3-0 -y && apt autoremove -y --purge && apt install -y git

USER node
19 changes: 19 additions & 0 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const socket = require('./socket');
const relay = require('../relay');
const logger = require('../log');
const version = require('../version');
const promBundle = require('express-prom-bundle');

module.exports = ({ port = null, config = {}, filters = {} }) => {
logger.info({ version }, 'running in client mode');
Expand All @@ -25,6 +26,24 @@ module.exports = ({ port = null, config = {}, filters = {} }) => {
// start the local webserver to listen for relay requests
const { app, server } = require('../webserver')(config, port);

// This is gross, but the tests run both servers in the same VM so without this we get an error about duplicate metrics...
if (!process.env.TAP && process.env.NODE_ENV !== 'test') {
// basic prometheus metrics
const metricsMiddleware = promBundle({
buckets: [0.5, 1, 2, 5, 10, 30, 60, 120, 300],
includeMethod: true,
includePath: false,
metricsPath: '/metrics',
promClient: {
collectDefaultMetrics: {
timeout: 3000,
},
},
});

app.use(metricsMiddleware);
}

// IMPORTANT: defined before relay (`app.all('/*', ...`)
app.get(config.brokerHealthcheckPath || '/healthcheck', (req, res) => {
// healthcheck state depends on websocket connection status
Expand Down