Skip to content

Commit

Permalink
feat: setup
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyNico43 committed Jun 28, 2024
1 parent 385a6ed commit 4bc647e
Show file tree
Hide file tree
Showing 34 changed files with 9,349 additions and 2,659 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.github
.husky
.next
.vscode
dist
node_modules
.gitignore
.lintstagedrc.cjs
.nvmrc
example.env
next-env.d.ts
nodemon.json
README.md
76 changes: 75 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
{
"extends": "next/core-web-vitals"
"env": {
"node": true,
"es6": true
},
"extends": ["eslint:recommended", "next"],
"ignorePatterns": ["node_modules/*", ".next/*", ".out/*", "!.prettierrc"],
"overrides": [
{
"files": ["**/*.ts", "**/*.tsx"],
"parser": "@typescript-eslint/parser",
"settings": {
"react": { "version": "detect" },
"import/ignore": [".css$", "node_modules/*"]
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": [
"plugin:@next/next/recommended",
"next/core-web-vitals",
"eslint:recommended",
"plugin:@typescript-eslint/recommended", // TypeScript rules
"plugin:react/recommended", // React rules
"plugin:jsx-a11y/recommended" // Accessibility rules
],
"rules": {
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],

"react/prop-types": "off",
"react/react-in-jsx-scope": "off",

"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true,
"allowConciseArrowFunctionExpressionsStartingWithVoid": true
}
],
"@typescript-eslint/no-explicit-any": ["error"],
"@typescript-eslint/no-floating-promises": ["error"],
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/label-has-associated-control": "off",
"jsx-a11y/no-noninteractive-element-interactions": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/mouse-events-have-key-events": "off",

"@next/next/no-img-element": "off",

"valid-jsdoc": [
"error",
{
"requireReturn": false,
"requireReturnType": false,
"requireParamType": false
}
]
}
}
],
"parserOptions": {
"ecmaVersion": 8,
"project": ["./tsconfig.json"]
},
"plugins": ["prettier"],
"root": true
}
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
27 changes: 27 additions & 0 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Builder

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm run build
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run precommit
4 changes: 4 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'**/*.{ts,tsx}': 'eslint',
'**/*.ts?(x)': () => 'tsc --noEmit',
};
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://registry.npmjs.org/
@easyflow-chat:registry=https://npm.pkg.github.com/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.14.0
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
.vscode
package-lock.json
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"endOfLine": "auto",
"arrowParens": "avoid",
"plugins": ["prettier-plugin-tailwindcss", "prettier-plugin-sort-json"]
}
76 changes: 76 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FROM node:20-alpine as builder

# Variables
ARG NODE_AUTH_TOKEN

WORKDIR /app

#Copy everything
COPY . .

#Install packages as in package-lock
RUN npm ci

#Linting
RUN npm run lint

#Build
RUN npm run build

#Remove packages
RUN rm -rf node_modules

#Install prod packages
RUN npm ci --omit=dev --omit=optional

FROM node:20-alpine as production

# Variables
ARG CLOUDFLARE_ORIGIN_CERTIFICATE
ARG CLOUDFLARE_ORIGIN_CA_KEY

# Uninstall yarn and npm not needed in prod
RUN npm uninstall -g yarn
RUN npm uninstall -g npm

RUN addgroup -g 2000 -S appgroup
RUN adduser -DH -s /sbin/nologin -u 2000 -G appgroup -S appuser


WORKDIR /app

#Copy needed files
COPY --chown=appuser:appgroup --from=builder /app/.next /app/.next
COPY --chown=appuser:appgroup --from=builder /app/node_modules /app/node_modules
COPY --chown=appuser:appgroup --from=builder /app/public /app/public
COPY --chown=appuser:appgroup --from=builder /app/entrypoint.sh /app/entrypoint.sh
COPY --chown=appuser:appgroup --from=builder /app/next.config.mjs /app/next.config.mjs
COPY --chown=appuser:appgroup --from=builder /app/nginx.conf /etc/nginx/nginx.conf

# Set type module
RUN echo '{"type": "module"}' > /app/package.json

# Create certificates
RUN echo "${CLOUDFLARE_ORIGIN_CERTIFICATE}" > /etc/ssl/easyflow.pem
RUN echo "${CLOUDFLARE_ORIGIN_CA_KEY}" > /etc/ssl/easyflow.key
RUN chown -R appuser:appgroup /etc/ssl/

# add nginx
RUN apk add nginx

# Create the necessary directories with correct permissions
RUN mkdir -p /var/ /run/ /logs/ && \
chown -R appuser:appgroup /var/ /run/ /logs/

USER appuser

LABEL org.opencontainers.image.authors="nico.benninger43@gmail.com"
LABEL org.opencontainers.image.source="https://github.com/easyflow-chat/easyflow-backend"
LABEL org.opencontainers.image.title="Easyflow Frontend"
LABEL org.opencontainers.image.description="Backend for Easyflow chat application"

ENV APPLICATION_ROOT="/app"
ENV NODE_ENV="production"

RUN chmod +x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
52 changes: 18 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
This is the Frontend application for the easyflow chat application. It is build with [NextJS](https://nextjs.org)

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
1. Populate the env file as described in the example.env

3. Install needed packages

```bash
npm install
```
4. Run the development server
```bash
npm run dev
```
Or build the project with
```bash
npm run build
```

Now you are of to start contributing. Have fun!
9 changes: 9 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
#Exit when error happens
set -e

#Start application
NODE_ENV=production node dist/server/index.js &

#Start nginx in the forground
nginx -g 'daemon off;'
15 changes: 15 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
REMOTE_URL=http://localhost:4000/

#App
BASE_URL=http://localhost:3000/

#Node
NODE_AUTH_TOKEN=token

# Cloudflare origin ca
CLOUDFLARE_ORIGIN_CA_KEY="-----BEGIN PRIVATE KEY-----
content
-----END PRIVATE KEY-----"
CLOUDFLARE_ORIGIN_CERTIFICATE="-----BEGIN CERTIFICATE-----
content
-----END CERTIFICATE-----"
8 changes: 8 additions & 0 deletions i18n.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Config } from 'next-i18n-router/dist/types';

const i18nConfig: Config = {
locales: ['en', 'de', 'placeholder'],
defaultLocale: 'placeholder',
};

export default i18nConfig;
Loading

0 comments on commit 4bc647e

Please sign in to comment.