Skip to content

Commit

Permalink
Merge branch 'develop' into diego/set-static-ip
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo authored Feb 20, 2024
2 parents f1766a8 + 55fc9c7 commit 0147ac2
Show file tree
Hide file tree
Showing 1,292 changed files with 52,746 additions and 24,686 deletions.
69 changes: 38 additions & 31 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
# Prevent Dockerfile modifications to trigger layer recomputation
build/Dockerfile
Dockerfile

# Dependencies
node_modules/

# Accelerate COPY build/src . command
packages/*/node_modules/
packages/*/tmp_dnp_repo/
packages/*/dnp_repo/
packages/*/DNCORE/
packages/*/cache/
packages/*/dappmanagerdb.json
packages/*/npm-debug.log
packages/*/yarn-error.log

# Compiled files
packages/*/build/
packages/*/dist

# Test artifacts
test_build/
test_build/*
test_build/.git/
test_build/.git/*
packages/*/undefined/
packages/*/test_files/
packages/*/test_files/*
packages/*/test_mountpoints_*/
packages/*/test_mountpoints_*/*
packages/*/.temp-transfer/
packages/*/.temp-transfer/*

# Test files
packages/admin-ui/src/__tests__
packages/dappmanager/test
packages/*/*test*
packages/*/src/*test*

# Version data file
.version.json
# Dev artifacts
packages/*/.prettierrc*
packages/*/.prettierignore
#packages/*/.eslintrc*
packages/*/.eslintignore
packages/*/.mocharc*

# UI
packages/*/node_modules
packages/*/npm-debug.log
# README files
README.md
packages/*/README.md

# Mock server is only for developing
packages/*/server-mock
# Version data file
.version.json

# Version builds
build_*/
build_*/

# Package admin-ui files
packages/admin-ui/server-mock
packages/admin-ui/__mock-backend__
packages/admin-ui/tsconfig.server-mock.json
packages/admin-ui/nodemon.json

# Package dappmanager files
packages/dappmanager/dnp_repo
packages/dappmanager/DNCORE
packages/dappmanager/maindb.json
packages/dappmanager/test_mountpoints

# toolkit files
packages/toolkit/truffle/*
packages/toolkit/theGraph/*
packages/toolkit/fixTypesImports.js
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ assignees:

**DAppNode version:**

<!--Print the DAppNode versions and info found in http://my.dappnode/#/support/report -->
<!--Print the DAppNode versions and info found in http://my.dappnode/support/report -->

- Package version: <!-- v0.1.14, upstream: prysm-1.0.0-beta -->
- OS: <!-- Ubuntu, Debian, DAppNode Mini, DAppNode Advance -->
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: npx @dappnode/dappnodesdk github-action build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,29 @@ jobs:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: "16.15.0"
node-version: "20"
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn lint
- run: yarn server-mock:check-types
working-directory: packages/admin-ui
env:
INFURA_MAINNET_KEY: ${{ secrets.INFURA_MAINNET_KEY }}

integration-test:
runs-on: ubuntu-latest
name: In app integration tests
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: "16.15.0"
node-version: "20"
- run: yarn # Caching only saves 30s
- run: yarn build
- run: yarn test:int
Expand All @@ -60,11 +62,11 @@ jobs:
run: |
[[ "$BUMP_TYPE" == "patch" ]] || [[ "$BUMP_TYPE" == "minor" ]] || \
[[ "$BUMP_TYPE" == "major" ]] || { echo "Wrong input, it must be: patch | minor | major"; exit 1;}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: "16.15.0"
node-version: "20"
- name: Publish
run: npx @dappnode/dappnodesdk publish ${BUMP_TYPE} --dappnode_team_preset
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Setup node version 14 for node-sass 4.14 https://stackoverflow.com/questions/60394291/error-node-modules-node-sass-command-failed
- uses: actions/setup-node@v2
with:
node-version: "16"
node-version: "20"
# Install dependencies
- run: yarn install
# Generate schemas
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: NPM Release

on:
workflow_dispatch:
inputs:
packageName:
description: "Package Name (schemas, types, toolkit)"
required: true
version:
description: "Version to publish (e.g., 1.0.0)"
required: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate package name
run: |
if [[ ${{ github.event.inputs.packageName }} != "schemas" && ${{ github.event.inputs.packageName }} != "types" && ${{ github.event.inputs.packageName }} != "toolkit" ]]; then
echo "Error: Invalid package name"
exit 1
fi
- name: Validate version
run: |
if ! [[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format"
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies and build
run: yarn && yarn build

- name: Build and Publish
run: |
cd packages/${{ github.event.inputs.packageName }}
yarn publish --new-version ${{ github.event.inputs.version }} --access public --non-interactive --no-git-tag-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
token: ${{ secrets.NPM_TOKEN }}
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ packages/common/src/validation/schemas
# Version data file
.version.json

# Git data .git-data.json
packages/*/.git-data.json

# Extra
node_modules/\.yarn-integrity

Expand All @@ -48,4 +51,8 @@ packages/*/package-lock.json
# Dev links
packages/dappmanager/dist
packages/dappmanager/DNCORE
packages/dappmanager/dnp_repo
packages/dappmanager/dnp_repo

# Specific from toolkit
#packages/toolkit/src/typechain/*
packages/toolkit/truffle/contracts_build/*
129 changes: 28 additions & 101 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,125 +1,52 @@
ARG NODE_VERSION=19.2.0

############
# GIT-DATA #
############
FROM --platform=${BUILDPLATFORM:-amd64} node:${NODE_VERSION}-alpine as git-data

WORKDIR /usr/src/app
RUN apk add --no-cache git

COPY .git .git
COPY dappnode_package.json .
COPY docker/getGitData.js .

RUN node getGitData /usr/src/app/.git-data.json

##################
# BUILD-BINARIES #
##################
FROM --platform=${BUILDPLATFORM:-amd64} node:${NODE_VERSION}-alpine as build-binaries

RUN apk add --no-cache bind-tools docker curl
RUN curl -L https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-$(uname -m) > /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
ARG NODE_VERSION=20.3.0

# Common base so it's cached
# --platform=$BUILDPLATFORM is used build javascript source with host arch
# Otherwise webpack builds on emulated archs can be extremely slow (+1h)
ARG BASE_IMAGE=node:${NODE_VERSION}-alpine3.18

#############
# BUILD-SRC #
#############
FROM --platform=${BUILDPLATFORM:-amd64} node:${NODE_VERSION}-alpine as build-src
# Initial stage to gather git data
FROM --platform=${BUILDPLATFORM:-amd64} ${BASE_IMAGE} as git-data
WORKDIR /usr/src/app
RUN apk add --no-cache git
COPY .git dappnode_package.json docker/getGitData.js ./
RUN node getGitData /usr/src/app/.git-data.json

# Build source files
FROM --platform=${BUILDPLATFORM:-amd64} ${BASE_IMAGE} as build-src
WORKDIR /app
RUN apk add --no-cache python3 build-base

# Copy and install deps first to cache
COPY package.json yarn.lock lerna.json tsconfig.json ./
COPY patches patches/
RUN yarn --frozen-lockfile --non-interactive --ignore-scripts --ignore-optional
COPY packages/admin-ui/package.json \
packages/admin-ui/
COPY packages/dappmanager/package.json \
packages/dappmanager/
COPY packages/common/package.json \
packages/common/
RUN yarn --frozen-lockfile --non-interactive --ignore-optional

# Build common
WORKDIR /app/packages/common/
COPY packages/common/ .
RUN yarn build
# Results in dist/*

# Build admin-ui
WORKDIR /app/packages/admin-ui/
COPY packages/admin-ui/ .
COPY packages packages
# For the admin-ui
ENV REACT_APP_API_URL /
RUN yarn build
# Results in build/*

# Build dappmanager
WORKDIR /app/packages/dappmanager/
COPY packages/dappmanager/ .
RUN yarn build
# Results in dist/*

##############
# BUILD-DEPS #
##############

FROM --platform=${BUILDPLATFORM:-amd64} node:${NODE_VERSION}-alpine as build-deps
RUN yarn --frozen-lockfile --non-interactive --ignore-optional && \
yarn build && \
yarn clean:libraries && \
yarn install --non-interactive --frozen-lockfile --production --force --ignore-optional
RUN rm -rf yarn.lock packages/*/node_modules packages/*/src packages/*/tsconfig.json packages/*/.eslint*

WORKDIR /usr/src/app
RUN apk add --no-cache python3
COPY --from=build-src /app .
RUN yarn install --non-interactive --frozen-lockfile --production --force --ignore-optional

##############
# PRODUCTION #
##############
# Production stage
FROM node:${NODE_VERSION}-alpine

ENV COMPOSE_HTTP_TIMEOUT=300 \
DOCKER_CLIENT_TIMEOUT=300 \
DOCKER_HOST=unix:///var/run/docker.sock \
UI_FILES_PATH=/usr/src/app/packages/admin-ui/build \
GIT_DATA_PATH=.git-data.json
WORKDIR /usr/src/app

# TODO: consider moving all these binaries to the build-binaries stage
RUN apk add --no-cache bind-dev xz libltdl miniupnpc zip unzip dbus bind avahi-tools

# Copy docker
COPY docker/rndc.conf /etc/bind/
COPY docker/update_local_dyndns.sh /usr/local/bin/update_local_dyndns
# TODO: Remove bind modules when we don't use Bind package?
# These packages create several files
RUN apk add --no-cache docker curl docker-cli-compose xz zip unzip libltdl bind bind-dev bind-tools avahi-tools dbus miniupnpc

# Copy git data
COPY --from=git-data /usr/src/app/.git-data.json $GIT_DATA_PATH

# Copy binaries
COPY --from=build-binaries /usr/bin/nsupdate /usr/bin/nsupdate
COPY --from=build-binaries /usr/bin/docker /usr/bin/docker
COPY --from=build-binaries /usr/local/bin/docker-compose /usr/local/bin/docker-compose

# Copy scripts and services
COPY packages/dappmanager/hostScripts /usr/src/app/hostScripts
COPY packages/dappmanager/hostServices /usr/src/app/hostServices
# Copy scripts
COPY packages/hostScriptsServices/hostScripts hostScripts
COPY packages/hostScriptsServices/hostServices hostServices
COPY packages/hostScriptsServices/hostTimers hostTimers

# Copy root app
COPY --from=build-deps /usr/src/app/node_modules ./node_modules
COPY --from=build-deps /usr/src/app/package.json ./package.json
# Copy common
COPY --from=build-deps /usr/src/app/packages/common/dist ./packages/common/dist
COPY --from=build-deps /usr/src/app/packages/common/node_modules ./packages/common/node_modules
COPY --from=build-deps /usr/src/app/packages/common/package.json ./packages/common/package.json
# Copy admin-ui
COPY --from=build-deps /usr/src/app/packages/admin-ui/build ./packages/admin-ui/build
# Copy dappmanager
COPY --from=build-deps /usr/src/app/packages/dappmanager/dist /usr/src/app/packages/dappmanager/dist
COPY --from=build-deps /usr/src/app/packages/dappmanager/node_modules /usr/src/app/packages/dappmanager/node_modules
COPY --from=build-deps /usr/src/app/packages/dappmanager/package.json /usr/src/app/packages/dappmanager/package.json
COPY package.json ./
COPY --from=build-src /app/packages ./packages
COPY --from=build-src /app/node_modules ./node_modules

CMD [ "node", "packages/dappmanager/dist/index" ]
Loading

0 comments on commit 0147ac2

Please sign in to comment.