Skip to content

Commit 5275eb6

Browse files
committed
Initial project setup
0 parents  commit 5275eb6

37 files changed

+6954
-0
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.next
3+
.dockerignore
4+
Dockerfile

.editorconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 2
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.bat]
15+
end_of_line = crlf
16+
17+
[*.twig]
18+
insert_final_newline = false
19+
20+
[*.md]
21+
indent_size = 2
22+
max_line_length = 0
23+
trim_trailing_whitespace = false
24+
25+
[Makefile]
26+
indent_style = tab

.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env.example

.env.example

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## General ##
2+
#############
3+
4+
COMPOSE_PROJECT_NAME=dp
5+
NODE_ENV=development # development, production
6+
TARGET_ENV=development # development, production
7+
8+
## API ##
9+
#########
10+
11+
API_URL=https://api.dp.localhost/
12+
13+
## APP ##
14+
#########
15+
16+
APP_PORT=3040

.eslintrc.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
project: 'tsconfig.json',
6+
sourceType: 'module',
7+
tsconfigRootDir: __dirname,
8+
},
9+
plugins: ['@typescript-eslint'],
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:react/recommended',
13+
'plugin:@typescript-eslint/recommended',
14+
'prettier',
15+
'prettier/@typescript-eslint',
16+
'plugin:prettier/recommended',
17+
],
18+
settings: { react: { version: 'detect' } },
19+
env: {
20+
node: true,
21+
jest: true,
22+
},
23+
ignorePatterns: ['.eslintrc.js', 'next.config.js'],
24+
rules: {
25+
'@typescript-eslint/interface-name-prefix': 'off',
26+
'@typescript-eslint/explicit-function-return-type': 'off',
27+
'@typescript-eslint/explicit-module-boundary-types': 'off',
28+
'@typescript-eslint/no-explicit-any': 'off',
29+
'react/react-in-jsx-scope': 'off',
30+
},
31+
}

.github/workflows/build.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
build-packages:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Build frontend
16+
run: yarn build

.github/workflows/docker-build.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build docker image
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
build-packages:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
IMAGE_NAME: frontend
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Build frontend
19+
run: |
20+
docker build . \
21+
--file ./Dockerfile \
22+
--target production \
23+
--build-arg NODE_ENV=production \
24+
--tag $IMAGE_NAME \
25+
--tag $IMAGE_NAME:ci-run

.github/workflows/lint.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Lint
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
build-packages:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Lint frontend
16+
run: yarn lint
17+
18+
- name: Lint styles
19+
run: yarn lint:styles

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# compiled output Next.js
2+
.next
3+
node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# OS
14+
.DS_Store
15+
16+
# Tests
17+
coverage
18+
.nyc_output
19+
20+
# IDEs and editors
21+
.idea
22+
.project
23+
.classpath
24+
.c9/
25+
*.launch
26+
.settings/
27+
*.sublime-workspace
28+
29+
# IDE - VSCode
30+
.vscode/*
31+
!.vscode/settings.json
32+
!.vscode/tasks.json
33+
!.vscode/launch.json
34+
!.vscode/extensions.json

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.next
3+
yarn.lock
4+
package-lock.json
5+
public

.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": true,
4+
"semi": false,
5+
"trailingComma": "all",
6+
"printWidth": 100,
7+
"jsxBracketSameLine": true,
8+
"arrowParens": "always"
9+
}

.stylelintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "stylelint-config-sass-guidelines"
3+
}

Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Pull node image from docker hub
2+
FROM node:14 AS development
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
ARG NODE_ENV=development
8+
9+
# Add `/app/node_modules/.bin` to $PATH
10+
ENV PATH=/app/node_modules/.bin:$PATH \
11+
NODE_ENV="$NODE_ENV"
12+
13+
# Install and cache app dependencies
14+
COPY package.json yarn.lock /app/
15+
RUN cd /app/ && yarn install --production=false
16+
17+
# Copy existing application directory contents
18+
COPY . /app
19+
20+
EXPOSE 3040
21+
22+
CMD [ "yarn", "dev" ]
23+
24+
25+
# Build target production #
26+
###########################
27+
FROM development AS production
28+
ARG NODE_ENV=production
29+
WORKDIR /app
30+
RUN yarn build
31+
CMD [ "yarn", "start" ]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Дарителска Платформа
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Дарителска Платформа - Frontend
2+
3+
## What's in the box
4+
5+
- [Typescript](https://www.typescriptlang.org/)
6+
- [Next.js](https://nextjs.org/)
7+
- [MaterialUI](https://material-ui.com/)
8+
- [MobX](https://mobx.js.org/)
9+
- [SCSS](https://sass-lang.com/)
10+
- [SCSS Guidelines](https://github.com/bjankord/stylelint-config-sass-guidelines)
11+
- [ESlint](https://eslint.org/)
12+
- [Prettier](https://prettier.io/)
13+
- [Stylelint](https://stylelint.io/)
14+
- [Github Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference)
15+
- [Docker Compose](https://docs.docker.com/compose/)
16+
17+
## Initial setup
18+
19+
```shell
20+
git clone [email protected]:daritelska-platforma/frontend.git
21+
cd frontend
22+
23+
# Symlink dev environment
24+
ln -s .env.example .env
25+
```
26+
27+
## Development
28+
29+
```shell
30+
yarn dev
31+
```
32+
33+
Visit <http://localhost:3040/>
34+
35+
### Run via Docker Compose
36+
37+
Install the binary via <https://docs.docker.com/compose/install/>
38+
39+
#### Start the container in foreground
40+
41+
```shell
42+
docker-compose up
43+
```
44+
45+
#### Start the container in background
46+
47+
```shell
48+
docker-compose up -d
49+
docker-compose logs -f
50+
```
51+
52+
Stop the docker container with `docker-compose down`
53+
54+
## Linting
55+
56+
```shell
57+
yarn lint
58+
yarn lint:styles
59+
yarn format
60+
yarn type-check
61+
```
62+
63+
## Production
64+
65+
### Build frontend
66+
67+
```shell
68+
yarn build
69+
```
70+
71+
### Build Docker image
72+
73+
```shell
74+
docker build . \
75+
--file ./Dockerfile \
76+
--target production \
77+
--build-arg NODE_ENV=production
78+
```

docker-compose.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3.8'
2+
services:
3+
frontend:
4+
container_name: ${COMPOSE_PROJECT_NAME?}-frontend
5+
6+
build:
7+
context: ./
8+
dockerfile: ./Dockerfile
9+
target: ${TARGET_ENV}
10+
args:
11+
NODE_ENV: ${NODE_ENV}
12+
13+
networks:
14+
- net-frontend
15+
16+
ports:
17+
- '${APP_PORT}:3040'
18+
19+
volumes:
20+
# Local:Container mounting points
21+
- ./src:/app/src
22+
- ./public:/app/public
23+
24+
environment:
25+
API_URL: ${API_URL}
26+
27+
networks:
28+
net-frontend:
29+
driver: bridge

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

next.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
sassOptions: {
5+
includePaths: [path.join(__dirname, 'src/styles')],
6+
},
7+
publicRuntimeConfig: {
8+
API_URL: process.env.API_URL,
9+
},
10+
}

0 commit comments

Comments
 (0)