Skip to content

Commit

Permalink
Added step "Check Production Build Correctness" to test pipeline; add…
Browse files Browse the repository at this point in the history
…ed docker-compose.local.yml + .dockerignore to test locally production deployment; fixed pre-commit hook; re-organized dependencies to ensure that only production dependencies are install during deployment; disabled linting in Next in order to restrict ESLint dependencies to dev build (linting should be performed during testing and other checks, not during deployment)
  • Loading branch information
annstriganova committed Feb 4, 2024
1 parent d841302 commit a09881b
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 209 deletions.
61 changes: 61 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Various IDEs
.idea/
.vscode/
*.iml
*.idea
*.vs

# Git and version control
.git/
.gitignore

# Docker override files
docker-compose.local.yml
docker-compose.override.yaml

# Environment files
.env.local
.env.local.dist
.env.*

# Dependency directories
**/node_modules/
**/bower_components/

# Log files
logs/
*.log

# Compiled output
/dist
/tmp
/out
/target
/build

# Others
**/README.md
**/LICENSE
**/CODE_OF_CONDUCT.md
**/SECURITY.md
**/START.md
*.md

# Operating system files
.DS_Store
Thumbs.db

# Test directories and libs
__tests__/
coverage/
jest*

# CI/CD
.github/
.gitlab-ci.yml
.travis.yml
.husky

# Documentation
docs/

6 changes: 5 additions & 1 deletion .github/workflows/dev-branch-pr-build-and-test-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ jobs:
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- name: Check Production Build Correctness
run: rm -rf node_modules && npm ci --omit=dev && npm run build
34 changes: 33 additions & 1 deletion START.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

1. `npm ci` - install dependencies into the `node_modules/` directory using `package-lock.json`
2. `npx husky install` - setup precommit eslint typescript checks
3. `echo 'NEXT_PUBLIC_API_HOST_REMOTE=https://iced-latte.uk/backend/api/v1' > .env` - create `.env`
3. `echo 'NEXT_PUBLIC_API_HOST_REMOTE=https://<be-server>/api/v1' > .env` - create `.env`
4. `npm run build` - build artifacts
5. `npm run dev` - run project on `localhost:3000` (if on the main page u do not see list of products due to CORS error, run dev server with `yarn next dev --hostname 127.0.0.1`)

Expand All @@ -27,4 +27,36 @@ npm run lint -- --fix

## Misc

### Production Build

Similar to commands from `Dockerfile`, that is used for deployment:

```bash
rm -rf node_modules && npm ci --omit=dev
npm run build
npm run start
```

### Docker

Start the application container with the latest build:

```bash
docker-compose -f docker-compose.local.yml up -d --build
```

View logs:

```bash
docker-compose -f docker-compose.local.yml logs iced-latte-frontend -f
```

Stop running container:

```bash
docker-compose -f docker-compose.local.yml down
```

### Links

Backend API reference: https://iced-latte.uk/backend/api/docs/swagger-ui/index.html
21 changes: 21 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3.5"

networks:
iced-latte-network:
name: iced-latte-network
attachable: true

services:
iced-latte-frontend:
image: 'zufarexplainedit/iced-latte-frontend:latest'
container_name: iced-latte-frontend
environment:
- .env
build:
context: .
dockerfile: Dockerfile
restart: 'always'
ports:
- '3000:3000'
networks:
- iced-latte-network
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {

// Lint then format TypeScript and JavaScript files
'src/**/*.(ts|tsx|js)': (filenames) => [
`npm run eslint --fix ${filenames.join(' ')}`,
`npx eslint --fix ${filenames.join(' ')}`,
`npx prettier --write ${filenames.join(' ')}`,
],

Expand Down
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const nextConfig = {
images: {
domains: ['134.209.25.111', '172.19.0.7', '172.19.0.2'],
},
eslint: {
// use pre-commit hooks and explicit `npm run lint`
ignoreDuringBuilds: true,
},
}

module.exports = nextConfig
Loading

0 comments on commit a09881b

Please sign in to comment.