Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# Prevent Dockerfile modifications to trigger layer recomputation
build/Dockerfile

# Acelerate ADD build/src . command
build/*/node_modules/
build/*/vpndb.json
build/*/test_files/
build/*/test_files/*
build/*/npm-debug.log
build_*

# Build artifacts
build/src/dist
build/ui_openvpn/build

# Ignore tests
build/src/test
# Local dependencies and build artifacts, rebuilt inside the image
src/node_modules
src/dist
ui_openvpn/node_modules
ui_openvpn/build

# Version data file
.version.json
.git-data.json
.git-data.json
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: "24.x"
- run: npx @dappnode/dappnodesdk github-action build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
34 changes: 28 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,45 @@
run:
working-directory: ./src
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v4
uses: actions/setup-node@v7
with:
node-version: "18.x"
- run: yarn install
node-version: "24.x"
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn build
- run: yarn test
- run: yarn test:int

ui-test:
runs-on: ubuntu-latest
name: UI tests
defaults:
run:
working-directory: ./ui_openvpn
steps:
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: "24.x"
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test
- run: yarn build

release:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Release
runs-on: ubuntu-latest
needs: [unit-test]
needs: [unit-test, ui-test]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: "24.x"
- name: Publish
run: npx @dappnode/dappnodesdk publish patch --dappnode_team_preset
env:
Expand Down
50 changes: 20 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
# Build dependencies
##########################
# --platform=$BUILDPLATFORM is used build javascript source with host arch
# Otherwise webpack builds on emulated archs can be extremely slow (+1h)
FROM --platform=${BUILDPLATFORM:-amd64} node:10.19.0-alpine as build
# Otherwise builds on emulated archs can be extremely slow (+1h)
# All dependencies are pure JavaScript, so node_modules is arch independent
FROM --platform=${BUILDPLATFORM:-amd64} node:24-alpine AS build

WORKDIR /usr/src/app

RUN apk add --update --no-cache \
build-base python libpcap-dev linux-headers bash

COPY src/package.json ./
COPY src/yarn.lock ./
RUN yarn install --production
# Reduces the app dir size from 94.5MB to 71.8MB
RUN npm config set unsafe-perm true
RUN yarn global add modclean && modclean -r
COPY src/package.json src/yarn.lock ./
RUN yarn install --production --frozen-lockfile



##########################
# Build Typescript app
##########################
FROM build as build-src
RUN yarn install
FROM build AS build-src
# Install only --production first to cache them, then install the rest
RUN yarn install --frozen-lockfile
COPY src .
RUN yarn build
# results in /usr/src/app/dist
Expand All @@ -33,11 +27,11 @@ RUN yarn build
##########################
# Compute git data
##########################
FROM --platform=${BUILDPLATFORM:-amd64} node:10.19.0-alpine as git-data
FROM --platform=${BUILDPLATFORM:-amd64} node:24-alpine AS git-data

WORKDIR /usr/src/app

RUN apk add --no-cache git nodejs
RUN apk add --no-cache git
COPY .git .git
COPY dappnode_package.json scripts/getGitData.js ./
RUN node getGitData /usr/src/app/.git-data.json
Expand All @@ -47,32 +41,29 @@ RUN node getGitData /usr/src/app/.git-data.json
##########################
# Build UI
##########################
FROM --platform=${BUILDPLATFORM:-amd64} node:10.19.0-alpine as build-ui
FROM --platform=${BUILDPLATFORM:-amd64} node:24-alpine AS build-ui

WORKDIR /usr/src/app

# ensuring both package.json AND package-lock.json are copied
COPY ui_openvpn/package*.json ./
COPY ui_openvpn/*lock* ./
# install dependencies
RUN yarn install --production
COPY ui_openvpn/package.json ui_openvpn/yarn.lock ./
# install dependencies (the build tooling lives in devDependencies)
RUN yarn install --frozen-lockfile
# copy the contents of the app
COPY ui_openvpn .
# build for production
ENV REACT_APP_CRED_URL_PATHNAME=/cred \
REACT_APP_CRED_URL_QUERY_PARAM=id
RUN yarn run build
RUN node injectToHtml build/index.html build/ui_openvpn.html
# build for production, results in a self-contained build/index.html
ENV VITE_CRED_URL_PATHNAME=/cred \
VITE_CRED_URL_QUERY_PARAM=id
RUN yarn build


##########################
# Final stage
##########################
FROM alpine:3.12.12
FROM alpine:3.24

WORKDIR /usr/src/app

RUN apk add --update \
RUN apk add --no-cache \
openvpn iptables bash easy-rsa openssl nodejs
RUN ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
Expand Down Expand Up @@ -113,10 +104,9 @@ ENV EASYRSA=/usr/share/easy-rsa \

RUN mkdir -p ${OPENVPN_CRED_DIR} ${OPENVPN_CCD_DIR}

# No need for webpack, node_modules is 3.3 MB
COPY --from=build /usr/src/app/node_modules /usr/src/app/node_modules
COPY --from=build-src /usr/src/app/dist /usr/src/app/src
COPY --from=build-ui /usr/src/app/build/ui_openvpn.html $UI_OPENVPN_PATH
COPY --from=build-ui /usr/src/app/build/index.html $UI_OPENVPN_PATH
COPY --from=git-data /usr/src/app/.git-data.json $GIT_DATA_PATH
COPY bin /usr/local/bin

Expand Down
2 changes: 1 addition & 1 deletion bin/ovpn_initpki
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ easyrsa build-ca $nopass

# We use Elliptic Curve so initial DH is not needed.
# easyrsa gen-dh
openvpn --genkey --secret $EASYRSA_PKI/ta.key
openvpn --genkey secret "$EASYRSA_PKI/ta.key"

# Was nice to autoset, but probably a bad idea in practice, users should
# have to explicitly specify the common name of their server
Expand Down
21 changes: 0 additions & 21 deletions src/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion src/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"bracketSameLine": false,
"arrowParens": "avoid"
}
19 changes: 19 additions & 0 deletions src/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ["dist/", "node_modules/"] },
js.configs.recommended,
tseslint.configs.recommended,
{
files: ["**/*.ts"],
languageOptions: {
globals: { ...globals.node, ...globals.mocha }
},
rules: {
// typescript does not understand hoisting
"@typescript-eslint/no-use-before-define": "off"
}
}
);
20 changes: 0 additions & 20 deletions src/index.ts

This file was deleted.

88 changes: 41 additions & 47 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,58 @@
{
"name": "dnp_vpn",
"version": "0.2.0",
"private": true,
"description": "",
"main": "index.js",
"main": "dist/index.js",
"engines": {
"node": ">=24"
},
"scripts": {
"start": "node src/index.js",
"dev": "TEST=true DAPPNODE_OTP_URL=https://dappnode.github.io/DAppNode_OTP/ node src/index",
"start": "node dist/index.js",
"build": "tsc",
"test": "npm run test:file \"./{,!(node_modules)/**}/*.test.ts\"",
"test:int": "npm run test:int:file \"./{,!(node_modules)/**}/*.test.int.ts\"",
"test:file": "TEST=true mocha -r ts-node/register --exit ",
"test:int:file": "mocha -r ts-node/register --timeout 30000 --exit",
"coverage": "./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls",
"lint": "eslint . --ext .ts --fix",
"pre-commit": "npm run lint && npm run test"
"test": "TEST=true mocha --import=tsx --exit \"test/**/*.test.ts\"",
"test:int": "mocha --import=tsx --timeout 30000 --exit \"test/**/*.test.int.ts\"",
"lint": "eslint . --fix",
"pre-commit": "yarn lint && yarn test"
},
"keywords": [],
"author": "dappLion & vdo",
"license": "ISC",
"dependencies": {
"async-retry": "^1.3.1",
"chalk": "^2.4.2",
"dargs": "^7.0.0",
"express": "^4.17.1",
"got": "^11.5.0",
"ip": "^1.1.5",
"lodash": "^4.17.19",
"prettyjson": "^1.2.1",
"async-retry": "^1.3.3",
"express": "^5.3.0",
"prettyjson": "^1.2.5",
"qrcode-terminal": "^0.12.0",
"source-map-support": "^0.5.19",
"stack-trace": "^0.0.10",
"tweetnacl": "^1.0.1",
"yargs": "^15.4.1"
"source-map-support": "^0.5.21",
"stack-trace": "^1.0.0",
"tweetnacl": "^1.0.3",
"yargs": "^18.2.0"
},
"devDependencies": {
"@types/async-retry": "^1.4.2",
"@types/body-parser": "^1.19.0",
"@types/chai": "^4.2.11",
"@types/express": "^4.17.6",
"@types/ip": "^1.1.0",
"@types/lodash": "^4.14.157",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.27",
"@types/prettyjson": "^0.0.29",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.4",
"@types/stack-trace": "^0.0.29",
"@types/yargs": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"chai": "^4.1.2",
"coveralls": "^3.0.6",
"eslint": "^6.4.0",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"prettier": "^1.16.4",
"@eslint/js": "^10.0.1",
"@types/async-retry": "^1.4.9",
"@types/chai": "^5.2.3",
"@types/express": "^5.0.6",
"@types/mocha": "^10.0.10",
"@types/node": "^24.0.0",
"@types/prettyjson": "^0.0.33",
"@types/proxyquire": "^1.3.31",
"@types/sinon": "^22.0.2",
"@types/yargs": "^17.0.35",
"chai": "^6.3.0",
"eslint": "^10.15.0",
"globals": "^17.14.0",
"mocha": "^12.0.3",
"prettier": "^3.10.1",
"proxyquire": "^2.1.3",
"sinon": "^7.4.2",
"sinon-chai": "^3.1.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.6"
"sinon": "^22.1.0",
"tsx": "^4.23.15",
"typescript": "~6.0.3",
"typescript-eslint": "^8.74.0"
},
"resolutions": {
"mocha/glob": "^14.0.6",
"mocha/**/minimatch": "^11.0.9",
"mocha/minimatch": "^11.0.9"
}
}
Loading