Skip to content

Commit

Permalink
🎉 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin committed Jul 3, 2024
0 parents commit 5170374
Show file tree
Hide file tree
Showing 139 changed files with 17,364 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_BASE_URL=http://localhost:8070
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# tailwind.config.js
98 changes: 98 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],

"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": "**/tsconfig.json"
},
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
"rules": {
"no-unused-vars": "off",
"prefer-const": "error",
"no-use-before-define": "error",
"no-var": "error",
"no-shadow": "error",
"no-undef": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }],
"no-debugger": "error",
"eqeqeq": "error",
"no-eval": "error",
"curly": "error",
"no-implied-eval": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"react/jsx-key": "error",
"react/jsx-no-duplicate-props": "error",
"react/jsx-no-target-blank": "error",
"react/jsx-no-undef": "error",
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/jsx-wrap-multilines": "error",
"react/no-danger": "warn",
"react/no-direct-mutation-state": "error",
"react/no-typos": "error",
"react/no-unused-state": "error",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/self-closing-comp": "error",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["PascalCase", "camelCase", "UPPER_CASE"],
"filter": {
"regex": "Context$",
"match": true
}
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"filter": {
"regex": "^_",
"match": false
}
},
{
"selector": "variable",
"types": ["function"],
"format": ["PascalCase", "camelCase", "UPPER_CASE"],
"filter": {
"regex": "^_",
"match": false
}
}
],
"react/jsx-pascal-case": "error"
},
"overrides": [
{
"files": ["*.d.ts"],
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
}
],
"globals": {
"Flowdapt": "readonly"
}
}
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI Checks
on:
pull_request:
push:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm lint
47 changes: 47 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deployment
on:
push:
tags:
- '*'
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
PLATFORMS: linux/amd64,linux/arm64,linux/arm64/v8,linux/arm/v7
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.PLATFORMS }}
cache-from: type=gha
cache-to: type=gha,mode=max
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release
on:
push:
branches:
- main
permissions:
contents: read
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ vars.GIT_NAME }}
GIT_AUTHOR_EMAIL: ${{ vars.GIT_EMAIL }}
GIT_COMMITTER_NAME: ${{ vars.GIT_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.GIT_EMAIL }}
run: npx semantic-release
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

#npmrc
# .npmrc

# recorded mocks files
mocks/data

# test results
test-results
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm dlx commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged --no-stash
8 changes: 8 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require("path");

const buildEslintCommand = filenames =>
`next lint --fix --file ${filenames.map(f => path.relative(process.cwd(), f)).join(" --file ")}`;

module.exports = {
"*.{js,jsx,ts,tsx}": [buildEslintCommand],
};
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"endOfLine": "lf"
}
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3030"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
],
"compounds": [
{
"name": "Launch Edge Headless and attach DevTools",
"configurations": ["Launch Microsoft Edge in headless mode", "Open Edge DevTools"]
},
{
"name": "Launch Edge and attach DevTools",
"configurations": ["Launch Microsoft Edge", "Open Edge DevTools"]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ARG NODE_VERSION=20

# Alpine image
FROM node:${NODE_VERSION}-alpine AS alpine
RUN apk update
RUN apk add --no-cache libc6-compat

# Setup pnpm on the alpine base
FROM alpine as base
RUN npm install pnpm --global
RUN pnpm config set store-dir ~/.pnpm-store

# Build the project
FROM base AS builder

WORKDIR /app

COPY package.json pnpm-lock.yaml ./

# First install the dependencies (as they change less often)
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile

# Copy source code
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm build
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm prune --prod --no-optional
RUN rm -rf ./**/*/src

# Final image
FROM alpine AS runner

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

WORKDIR /app

COPY --from=builder --chown=nodejs:nodejs /app/next.config.js .
COPY --from=builder --chown=nodejs:nodejs /app/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nodejs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nodejs:nodejs /app/.next/static ./.next/static

WORKDIR /app

ARG PORT=3030
ENV PORT=${PORT}
ENV NODE_ENV=production
EXPOSE ${PORT}

CMD ["node", "server.js"]
Loading

0 comments on commit 5170374

Please sign in to comment.