-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gruz0/feature/init-project
Initialize project
- Loading branch information
Showing
25 changed files
with
1,518 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Dockerfile | ||
.dockerignore | ||
node_modules | ||
npm-debug.log | ||
README.md | ||
.next | ||
out | ||
coverage | ||
.git | ||
.github | ||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ----------------------------------------------------------------------------- | ||
# General settings | ||
# ----------------------------------------------------------------------------- | ||
|
||
export COMPOSE_PROJECT_NAME=checkmvp | ||
|
||
export NEXT_PUBLIC_SITE_URL="http://localhost:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.next | ||
node_modules | ||
yarn.lock | ||
package-lock.json | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,93 @@ | ||
{ | ||
"extends": ["next/core-web-vitals", "next/typescript"] | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:prettier/recommended", | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:react-hooks/recommended", | ||
"plugin:import/recommended", | ||
"plugin:tailwindcss/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:jsx-a11y/recommended", | ||
"plugin:security/recommended-legacy", | ||
"prettier", | ||
"next" | ||
], | ||
"plugins": [ | ||
"react", | ||
"import", | ||
"filenames", | ||
"autofix", | ||
"unused-imports", | ||
"@typescript-eslint", | ||
"jsx-a11y", | ||
"prettier", | ||
"security" | ||
], | ||
"env": { | ||
"jest": true | ||
}, | ||
"rules": { | ||
"no-unused-vars": "off", | ||
"unused-imports/no-unused-imports": "error", | ||
"unused-imports/no-unused-vars": [ | ||
"warn", | ||
{ | ||
"vars": "all", | ||
"varsIgnorePattern": "^_", | ||
"args": "after-used", | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } | ||
], | ||
"arrow-body-style": ["error", "as-needed"], | ||
"react/self-closing-comp": [ | ||
"error", | ||
{ | ||
"component": true, | ||
"html": true | ||
} | ||
], | ||
"autofix/no-unused-vars": [ | ||
"error", | ||
{ | ||
"argsIgnorePattern": "^_", | ||
"ignoreRestSiblings": true, | ||
"destructuredArrayIgnorePattern": "^_" | ||
} | ||
], | ||
"import/order": [ | ||
"error", | ||
{ | ||
"groups": [ | ||
"builtin", | ||
"external", | ||
"parent", | ||
"sibling", | ||
"index", | ||
"object", | ||
"type" | ||
], | ||
"pathGroups": [ | ||
{ | ||
"pattern": "@/**/**", | ||
"group": "parent", | ||
"position": "before" | ||
} | ||
], | ||
"alphabetize": { "order": "asc" } | ||
} | ||
], | ||
"sort-imports": [ | ||
"error", | ||
{ | ||
"ignoreDeclarationSort": true | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'docker' | ||
directory: '/' | ||
schedule: | ||
interval: 'weekly' | ||
|
||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
schedule: | ||
interval: 'weekly' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Docker Image CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: hadolint/[email protected] | ||
with: | ||
dockerfile: Dockerfile | ||
|
||
- name: Prepare .env | ||
run: cp .env.example .env.production | ||
|
||
- name: Build the Docker image | ||
run: make prod-docker-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 22.6.0 | ||
cache: npm | ||
|
||
- name: Prepare .env | ||
run: cp .env.example .env | ||
|
||
- run: npm ci | ||
- run: make lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# NOTE: https://github.com/rails/rails/blob/main/.github/workflows/lint.yml | ||
|
||
name: Spell | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
codespell: | ||
name: Check spelling all files with codespell | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ['3.10'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install codespell==2.1.0 | ||
- name: Check spelling with codespell | ||
run: codespell --ignore-words=codespell.txt --skip "./node_modules,./package-lock.json" || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.next | ||
node_modules | ||
yarn.lock | ||
package-lock.json | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"useTabs": false, | ||
"plugins": [], | ||
"overrides": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Install dependencies only when needed | ||
FROM node:22.6.0-alpine AS base | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
# hadolint ignore=DL3018 | ||
RUN apk add --update --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json ./ | ||
|
||
RUN npm ci | ||
|
||
# Rebuild the source code only when needed | ||
FROM node:22.6.0-alpine AS builder | ||
WORKDIR /app | ||
|
||
COPY --from=base /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN npm run build | ||
|
||
FROM node:22.6.0-alpine AS prod_builder | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
|
||
COPY --from=base /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
RUN npm install && \ | ||
cp -R node_modules prod_node_modules | ||
|
||
# Production image, copy all the files and run next | ||
FROM node:22.6.0-alpine AS runner | ||
RUN apk add --update --no-cache curl=8.9.1-r2 | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
ARG UID=1001 | ||
ENV USER="app" | ||
|
||
RUN adduser -D $USER -u $UID | ||
|
||
# You only need to copy next.config.js if you are NOT using the default configuration | ||
COPY --from=builder --chown=$USER:$USER /app/next.config.mjs ./ | ||
COPY --from=builder --chown=$USER:$USER /app/public ./public | ||
COPY --from=builder --chown=$USER:$USER /app/package.json ./package.json | ||
COPY --from=prod_builder --chown=$USER:$USER /app/prod_node_modules ./node_modules | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=$USER:$USER /app/.next/standalone ./ | ||
COPY --from=builder --chown=$USER:$USER /app/.next/static ./.next/static | ||
|
||
USER $USER | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
|
||
CMD ["node", "server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
NPM := npm | ||
NPM_RUN := ${NPM} run | ||
NPX := npx | ||
|
||
DOCKER_COMPOSE := docker compose | ||
|
||
help: # Show this help | ||
@egrep -h '\s#\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
# | ||
# Development environment | ||
# | ||
|
||
setup: # Install dependencies | ||
@${NPM} install | ||
@${NPM_RUN} prepare | ||
|
||
prepare-dev-env: | ||
@cp .env.development .env | ||
|
||
analyze: prepare-dev-env # Analyze bundles | ||
@${NPM_RUN} analyze | ||
|
||
build: prepare-dev-env # Build project | ||
@${NPM_RUN} build | ||
|
||
dev: prepare-dev-env # Run dev server | ||
@${NPM_RUN} dev | ||
|
||
lint: # Run linters | ||
@${NPM_RUN} lint | ||
|
||
fix: # Run automatically fixes | ||
@${NPM_RUN} next-lint-fix | ||
@${NPX} prettier -w . | ||
|
||
# | ||
# Production environment | ||
# | ||
|
||
prepare-prod-env: | ||
@cp .env.production .env | ||
|
||
prod-docker-build: prepare-prod-env # Build Docker image | ||
@${DOCKER_COMPOSE} -f docker-compose.production.yml build | ||
|
||
prod-docker-start: prepare-prod-env # Run Docker container | ||
@${DOCKER_COMPOSE} -f docker-compose.production.yml up -d | ||
|
||
prod-docker-stop: prepare-prod-env # Stop Docker container | ||
@${DOCKER_COMPOSE} -f docker-compose.production.yml down | ||
|
||
prod-docker-app-cli: prepare-prod-env # Attach to Docker container | ||
@${DOCKER_COMPOSE} -f docker-compose.production.yml exec app sh | ||
|
||
prod-docker-logs: prepare-prod-env # Show production related logs | ||
@${DOCKER_COMPOSE} -f docker-compose.production.yml logs -f |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
env_file: .env | ||
stdin_open: true | ||
tty: true | ||
ports: | ||
- 127.0.0.1:3000:3000 |
Oops, something went wrong.