Skip to content

Commit

Permalink
ci/di
Browse files Browse the repository at this point in the history
  • Loading branch information
arunas-smala committed Jul 4, 2023
1 parent 3ec8bcc commit e0d23c8
Show file tree
Hide file tree
Showing 12 changed files with 462 additions and 43 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Continuous integration

on:
push:
branches: [ main ]
pull_request:

jobs:
build-test:
name: Build and test
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v3

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: yarn

- name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache

- name: Run tests
run: yarn test --passWithNoTests

- name: Build
run: yarn run build

eslint:
name: ESLint
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
security-events: write
actions: read
contents: read

steps:
- uses: actions/checkout@v3

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: yarn

- name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache

- name: Run ESLint
run: yarn run lint:sarif
continue-on-error: true

- name: Upload ESLint analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
category: ESLint

validate-docker-build:
name: Validate if docker image builds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build & tag docker image
uses: AplinkosMinisterija/reusable-workflows/.github/actions/docker-build-tag-push@main
with:
environment: test
push: false
16 changes: 16 additions & 0 deletions .github/workflows/deploy-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy to Development

on:
workflow_dispatch:

jobs:
deploy-development:
name: Deploy development
uses: AplinkosMinisterija/reusable-workflows/.github/workflows/biip-deploy.yml@main
secrets: inherit
permissions:
contents: read
packages: write
with:
environment: Development
docker-image: ghcr.io/AplinkosMinisterija/biip-waste-calculator-web
17 changes: 17 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy to Production
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
deploy-production:
name: Deploy production
uses: AplinkosMinisterija/reusable-workflows/.github/workflows/biip-deploy.yml@main
secrets: inherit
permissions:
contents: read
packages: write
with:
environment: Production
docker-image: ghcr.io/AplinkosMinisterija/biip-waste-calculator-web
17 changes: 17 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy to Staging

on:
push:
branches: [ main ]

jobs:
deploy-staging:
name: Deploy staging
uses: AplinkosMinisterija/reusable-workflows/.github/workflows/biip-deploy.yml@main
secrets: inherit
permissions:
contents: read
packages: write
with:
environment: Staging
docker-image: ghcr.io/AplinkosMinisterija/biip-waste-calculator-web
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing

Thank you for considering contributing to this repository! We welcome any contributions that can
help make this project better.

## Submitting a pull request

1. Fork the repository to your own GitHub account
2. Create a new branch with a descriptive name for your contribution
3. Make your changes in the branch
4. Push to your fork
5. Test your changes thoroughly to ensure they are functional and do not introduce any new issues
6. Submit a pull request, detailing the changes you have made and the rationale behind them

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
- [Writing good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM node:20-alpine as build

# Working directory
WORKDIR /app

# Install dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Copy source
COPY . .

# Build and cleanup
RUN yarn build

# Caddy stage
FROM caddy:2.6-alpine

# Set default NODE_ENV
ENV NODE_ENV=production

# Expose port
EXPOSE 80

# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD wget -qO- http://localhost/ || exit 1

# Copy Caddyfile
COPY ./caddy/Caddyfile /etc/caddy/Caddyfile

# Copy built files from the build stage
COPY --from=build /app/build /srv
97 changes: 71 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,91 @@
# Getting Started with Create React App
# BĮIP XXXXXX WEB

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/AplinkosMinisterija/biip-zuvinimas-web/badge)](https://securityscorecards.dev/viewer/?platform=github.com&org={AplinkosMinisterija}&repo={biip-zuvinimas-web})
[![License](https://img.shields.io/github/license/AplinkosMinisterija/biip-zuvinimas-web)](https://github.com/AplinkosMinisterija/biip-zuvinimas-web/blob/main/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/AplinkosMinisterija/biip-zuvinimas-web)](https://github.com/AplinkosMinisterija/biip-zuvinimas-web/issues)
[![GitHub stars](https://img.shields.io/github/stars/AplinkosMinisterija/biip-zuvinimas-web)](https://github.com/AplinkosMinisterija/biip-zuvinimas-web/stargazers)

## Available Scripts
This repository contains the source code and documentation for the BĮIP Žuvinimas WEB, developed by the Aplinkos
Ministerija.

In the project directory, you can run:
## Table of Contents

### `npm start`
- [About the Project](#about-the-project)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Deployment](#deployment)
- [Contributing](#contributing)
- [License](#license)

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
## About the Project

The page will reload if you make edits.\
You will also see any lint errors in the console.
The BĮIP Žuvinimas WEB is designed to provide information and functionalities related to fish stocking activities. It
aims to support the management and conservation of fish populations, as well as the sustainability of fishing practices.

### `npm test`
This is a client application that utilizes
the [BĮIP Žuvinimas API](https://github.com/AplinkosMinisterija/biip-zuvinimas-api).

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
Key features of the WEB include:

### `npm run build`
- Retrieving fish stocking data, such as planned fish stockings and historical information.
- Managing fish stocking data.

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
## Getting Started

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
To get started with the BĮIP Žuvinimas WEB, follow the instructions below.

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### Installation

### `npm run eject`
1. Clone the repository:

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
```bash
git clone https://github.com/AplinkosMinisterija/biip-zuvinimas-web.git
```

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
2. Install the required dependencies:

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
```bash
cd biip-zuvinimas-web
yarn install
```

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
### Usage

## Learn More
1. Start the WEB server:

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
```bash
yarn start
```

To learn React, check out the [React documentation](https://reactjs.org/).
The WEB will be available at `http://localhost:8080`.

## Deployment

### Production

To deploy the application to the production environment, create a new GitHub release:

1. Go to the repository's main page on GitHub.
2. Click on the "Releases" tab.
3. Click on the "Create a new release" button.
4. Provide a version number, such as `1.2.3`, and other relevant information.
5. Click on the "Publish release" button.

### Staging

The `main` branch of the repository is automatically deployed to the staging environment. Any changes pushed to the main
branch will trigger a new deployment.

### Development

To deploy any branch to the development environment use the `Deploy to Development` GitHub action.

## Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a
pull request. For more information, see the [contribution guidelines](./CONTRIBUTING.md).

## License

This project is licensed under the [MIT License](./LICENSE).
23 changes: 23 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Security Policy

This repository is committed to ensuring the security of its code and the protection of its users'
data. We take security concerns seriously and strive to address them as quickly as possible.

## Reporting a Vulnerability

If you discover a security vulnerability in this repository, please notify us by
using [private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
Please do not create a public issue, as doing so could potentially put the security of the repository and its users at
risk.

Please do not create a public issue, as this could potentially put the security of
the repository and its users at risk.

When reporting a vulnerability, please provide us with as much detail as possible, including:

- A description of the vulnerability
- Steps to reproduce the vulnerability
- Any potential impact of the vulnerability
- Your contact information, so we can follow up with you regarding the issue

We will investigate all reported vulnerabilities and provide updates as we work to address them.
7 changes: 7 additions & 0 deletions caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:80 {
root * /srv
encode gzip

try_files {path} {file} /index.html
file_server
}
3 changes: 0 additions & 3 deletions docker-compose.env

This file was deleted.

19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "biip-rusys",
"name": "biip-waste-calculator",
"version": "0.1.0",
"private": true,
"dependencies": {
Expand Down Expand Up @@ -54,18 +54,11 @@
"scripts": {
"start": "export PORT=8080 && react-scripts start",
"start-win": "set PORT=8080 && react-scripts start",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:sarif": "set SARIF_ESLINT_EMBED=true && yarn run lint --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dc:up": "docker-compose -p rusys-frontend up --build -d",
"dc:dev:up": "docker-compose -p rusys-frontend-dev up --build -d",
"dc:prod:up": "docker-compose -p rusys-frontend-prod -f docker-compose.prod.yml up --build -d",
"dc:staging:up": "docker-compose -p rusys-frontend-staging -f docker-compose.staging.yml up --build -d",
"dc:logs": "docker-compose -p rusys-frontend logs -f",
"dc:down": "docker-compose -p rusys-frontend down",
"dc:dev:down": "docker-compose -p rusys-frontend-dev down",
"dc:prod:down": "docker-compose -p rusys-frontend-prod down",
"dc:staging:down": "docker-compose -p rusys-frontend-staging down"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
Expand All @@ -86,6 +79,7 @@
]
},
"devDependencies": {
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@types/leaflet": "^1.7.9",
"@types/react-datepicker": "^4.4.1",
"@types/react-google-recaptcha": "^2.1.5",
Expand All @@ -94,5 +88,8 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.6.2"
},
"engines": {
"node": ">=20.0.0 <21.0.0"
}
}
Loading

0 comments on commit e0d23c8

Please sign in to comment.