Skip to content
Open
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
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.js

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/nodejs.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test, lint and build Thunderhub

on:
push:
branches:
- master
pull_request:
types: [opened, reopened, synchronize]

jobs:
test_lint_build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.18.2'
cache: 'pnpm'

- name: Install pnpm
run: npm install -g pnpm

- name: Install modules
run: pnpm install

- name: Run eslint
run: pnpm run lint:check

- name: Run tests
run: pnpm run test

- name: Setup Docker Buildx Driver
id: docker_driver_setup
uses: docker/setup-buildx-action@v3

- name: Run docker build
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
32 changes: 22 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ FROM node:18.18.2-alpine as deps

WORKDIR /app

# Install dependencies neccesary for node-gyp on node alpine
# Install dependencies necessary for node-gyp on node alpine
RUN apk add --update --no-cache \
libc6-compat \
python3 \
make \
g++

# Install app dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Install pnpm
RUN npm install -g pnpm

# Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./

# Install app dependencies using pnpm
RUN pnpm install --frozen-lockfile

# ---------------
# Build App
Expand All @@ -30,13 +35,15 @@ ARG NODE_ENV="production"
ENV NODE_ENV=${NODE_ENV}
ENV NEXT_TELEMETRY_DISABLED=1

# Build the NestJS and NextJS application
# Copy all source files
COPY . .
RUN npm run build:nest
RUN npm run build:next

# Remove non production necessary modules
RUN npm prune --production
# Build the NestJS and NextJS application
RUN pnpm run build:nest
RUN pnpm run build:next

# Remove non-production dependencies
RUN pnpm prune --prod

# ---------------
# Release App
Expand All @@ -45,14 +52,19 @@ FROM node:18.18.2-alpine as final

WORKDIR /app

# Install pnpm in the final stage
RUN npm install -g pnpm

# Set env variables
ARG BASE_PATH=""
ENV BASE_PATH=${BASE_PATH}
ARG NODE_ENV="production"
ENV NODE_ENV=${NODE_ENV}
ENV NEXT_TELEMETRY_DISABLED=1

# Copy package.json and pnpm-lock.yaml
COPY --from=build /app/package.json ./
COPY --from=build /app/pnpm-lock.yaml ./
COPY --from=build /app/node_modules/ ./node_modules

# Copy NextJS files
Expand All @@ -65,4 +77,4 @@ COPY --from=build /app/dist/ ./dist

EXPOSE 3000

CMD [ "npm", "run", "start:prod" ]
CMD ["pnpm", "run", "start:prod"]
79 changes: 79 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import { defineConfig, globalIgnores } from 'eslint/config';
import _import from 'eslint-plugin-import';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import globals from 'globals';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default defineConfig([
globalIgnores([
'**/.eslintrc.js',
'node_modules/*',
'.next/*',
'src/client/*',
'**/*.generated.tsx',
]),
{
extends: fixupConfigRules(
compat.extends(
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier',
),
),

plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslintEslintPlugin),
'simple-import-sort': simpleImportSort,
import: fixupPluginRules(_import),
},

languageOptions: {
globals: {
...globals.node,
...globals.jest,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
project: 'tsconfig.json',
},
},

rules: {
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-floating-promises': 'off',
'simple-import-sort/imports': 'error',
'import/first': 'error',
'import/no-duplicates': 'error',
'import/no-namespace': 'error',
'import/no-duplicates': 'off',
'import/newline-after-import': 'error',
'import/no-unassigned-import': 'error',
'import/no-namespace': 'off',
},
},
]);
Loading