Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockerHub-Image #451

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7b7ac58
publishing images now
i3rotlher Jul 31, 2023
4b61cbb
added envs
i3rotlher Aug 1, 2023
8415d82
redisgned docker
i3rotlher Aug 3, 2023
b2d52c3
publish images action
i3rotlher Aug 8, 2023
3535357
changed readme
i3rotlher Aug 10, 2023
9a3578b
updated readme
i3rotlher Aug 10, 2023
41056dd
updated readme
i3rotlher Aug 10, 2023
ad27245
removed old files from gitignore
i3rotlher Aug 11, 2023
c276d03
quick test
i3rotlher Aug 15, 2023
9fa6259
updated readme
i3rotlher Aug 10, 2023
8c5512d
removed old files from gitignore
i3rotlher Aug 11, 2023
55372b4
quick test
i3rotlher Aug 15, 2023
c43b964
removed test
i3rotlher Aug 15, 2023
658994d
Merge branch 'DockerHub-Image' of https://github.com/adessoSE/Seed-Te…
i3rotlher Aug 15, 2023
4ddf5fb
test
i3rotlher Aug 15, 2023
58f04e6
test
i3rotlher Aug 15, 2023
db29e22
test
i3rotlher Aug 15, 2023
152382a
old_compose
i3rotlher Aug 15, 2023
a7f3891
redo dokcer-compose
i3rotlher Aug 15, 2023
2c4ddf6
gogo
i3rotlher Aug 15, 2023
11a62e3
Buffering output
i3rotlher Aug 18, 2023
410ef7c
override error
i3rotlher Aug 18, 2023
51dc11f
ops
i3rotlher Aug 18, 2023
aadf12b
sleep
i3rotlher Aug 18, 2023
bdbce24
verbose
i3rotlher Aug 18, 2023
50e3aa9
removed -1 at dbconenctor
i3rotlher Aug 18, 2023
e5eef83
removed exit from dbconnector
i3rotlher Aug 18, 2023
ea26190
Test
i3rotlher Aug 21, 2023
493e2f9
Go
i3rotlher Aug 21, 2023
64c3064
changed command
i3rotlher Aug 21, 2023
eb4cff7
back
i3rotlher Aug 21, 2023
6beebf8
moved compose
i3rotlher Aug 22, 2023
9388586
Test
i3rotlher Aug 22, 2023
7a3bd31
Test
i3rotlher Aug 22, 2023
cbb0528
adding DB
i3rotlher Aug 22, 2023
6df92f7
set env in jest
i3rotlher Aug 22, 2023
e778e10
removed database
i3rotlher Aug 22, 2023
5256c0e
ups
i3rotlher Aug 22, 2023
0cbd8d1
removed volume
i3rotlher Aug 22, 2023
8519a36
tests work, skipped missing
i3rotlher Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/Build_and_Publish_Images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Publish Docker Image

on:
push:
tags:
- 'Seed-Test_v*'

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get Tag Name
id: get_tag_name
run: |
version=$(echo $GITHUB_REF | sed 's/refs\/tags\///' | sed 's/.*_//')
echo "version=${version}" >> ${GITHUB_OUTPUT}

# BACKEND
- name: Build Docker Image
run: docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend

- name: Tag Docker Image as Latest
run: |
docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest

- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest

# FRONTEND
- name: Build Docker Image
run: docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend

- name: Tag Docker Image as Latest
run: |
docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest

- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest
12 changes: 7 additions & 5 deletions .github/workflows/CI_Tests_and_Report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ jobs:

- name: Build and start Docker stack
run: |
chmod +x runDocker.sh
./runDocker.sh
docker compose -f docker-test.yml up -d

- name: Send failure notification
if: ${{ failure() }}
Expand Down Expand Up @@ -89,7 +88,8 @@ jobs:
id: passed-total-backend

- name: Upload Artifact Backend
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
with:
name: test-results-backend
path: |
Expand Down Expand Up @@ -122,7 +122,8 @@ jobs:
id: passed-total-frontend

- name: Upload Artifact Frontend
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
with:
name: test-results-frontend
path: |
Expand Down Expand Up @@ -157,7 +158,8 @@ jobs:
id: passed-total-sanity

- name: Upload Artifact Sanity
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
with:
name: sanity-report
path: |
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/SonarCloud-PR.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
on:
# Trigger analysis when pushing in master or pull requests, and when creating
# a pull request.
pull_request:
types: [opened, synchronize, reopened]
branches:
- "nie"
gollum
name: SonarCloud
jobs:
sonarcloud:
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ backend/features/reporting_html*.html
*.bat
*.sh
*.ps1
!runDocker.bat
!runDocker.sh

# Website Deployment with IIS
**/web.config
Expand All @@ -79,4 +77,6 @@ backend/features/reporting_html*.html
backend/logs/

# local testing for step-definition development
backend/features/step_definitions/testing.js
backend/features/step_definitions/testing.js

/act
79 changes: 58 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,33 @@ It will download NodeJs and the browsers with their correct driver on it's own.

For this [docker](https://www.docker.com/products/docker-desktop/) needs to be installed.

#### Installing Seed
#### And that's it!

After installing docker you just simply need to clone the repository and launch the runDocker script matching your OS:
#### Installation of Seed

Windows:
Once you have Docker installed, the process of setting up Seed is straightforward. Follow these steps:

```
runDocker.bat
```
1. **Download the Release:**

Linux:
- Go to the [releases page](https://github.com/adessoSE/Seed-Test/releases) of Seed on GitHub.
- Download the `docker-compose.yml` file from the assets for the specific release you want.
2. **Place the File:**

```
runDocker.sh
```
- Choose a directory where you want to set up Seed (e.g., `C:/seed-test/`).
- Move the downloaded `docker-compose.yml` file to that directory.
3. **Navigate and Execute:**

And that's it!
- Open a terminal.
- Navigate to the directory where you placed the `docker-compose.yml` file using the `cd` command. For instance:
```
cd C:/seed-test
```
- Execute the following command to start the Seed application in the background:
```
docker compose up -d
```

With these steps, you'll have Seed up and running using Docker and the downloaded `docker-compose.yml` file. This will initiate the necessary services and configurations for the applicationvb (mongoDB, seed-test-frontend, seed-test-backend).

Seed-Test can now be accessed via `http://localhost:4200/login`

Expand All @@ -56,25 +66,52 @@ Seed-Test now runs within docker with default values which means the following:
- GitHub functionalities don't work:
To get GitHub functionalities to work you need to create and link a [GitHub OAuth App](https://docs.github.com/de/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app).
- Salt and secrets are defaults:They should be changed for generating secure passwords!
- The mongoDB used has a default username and password. This should be changed for a secure database:To change this change the values in the docker-compose.yml
- The mongoDB used has a default username and password:
This should be changed for a secure databas.

To know how to change this look at the configure section below.

#### ⚙️ Configuration:

Seed-Test's front- and backend can be configured sepreratly.
To configure anything when running seed via docker, you can simply adjust the environment variables for each container in the docker-compose.yml file and rerun the command:

##### Backend:
##### Backend

To configure the backend create a file with the name ".env" in the /backend directory.
Now you can configure the backend by adding parameters shown in the .env.example file.
| Variable | Description |
| :----------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| DATABASE_URI* | The mongoDB Connection String URI. This can be replaced with your own mongoDB.<br />If you are using the MongoDB provided by docker-compose, this needs to match the values set for the mongoDB in the docker compose. |
| REPORT_DELETION_TIME | Time (in minutes) after which the report is deleted. |
| SESSION_SECRET | Session secret to establish a secure connection and prevent session hijacking (used in /backend/src/server.js).<br />See https://www.npmjs.com/package/express-session |
| JIRA_SECRET | Jira Integration : values used for the encryption of sensible data.<br />Choose a strong Secret like for example generated by RandomKeygen. |
| JIRA_SALT | The salt should be a random string of at least 16 bytes length. |
| Unassigned_AVATAR_URL | 'https://cdn.pixabay.com/photo/2016/08/08/09/17/avatar-1577909_960_720.png' |
| EMAIL_AUTH | Mail adress to send password reset mails (used in /backend/src/nodemailer.js) |
| EMAIL_PW | Mail password credentials to send password reset mails (used in /backend/src/nodemailer.js) |
| EMAIL_PORT | Mail server port to send password reset mails (used in /backend/src/nodemailer.js) |
| EMAIL_HOST | Mail server adress to send password reset mails (used in /backend/src/nodemailer.js) |
| GITHUB_CLIENT_SECRET | GitHub integration. Check out GitHub´s Guide on Autorizing OAuth Apps. |
| GITHUB_CLIENT_ID | GitHub integration. Check out GitHub´s Guide on Autorizing OAuth Apps. |
| PASSPORT_GITHUB_LOCAL_PW_FIELD | GitHub integration. Check out GitHub´s Guide on Autorizing OAuth Apps. |
| MAX_SAVED_REPORTS | The amount of maximum saved reports. |

##### Frontend:
*If you are not using the mongoDB provided by tis docker-compose you can complete delete the seedmongodb section from the docker-compose.yml

To configure the frontend create a file with the name ".env" in the /frontend directory.
Now you can configure the frontend by adding parameters shown in the .env.example file.
##### Frontend

The dockerRun script needs to be run after any changes to the ".env" files.
| Variable | Meaning |
| :--------------- | :--------------------------------------------------------------------------------- |
| GITHUB_CLIENT_ID | GitHub integration. Check out GitHub´s Guide on Autorizing OAuth Apps. |
| VERSION | This controls if the demo warning is shown. Set this to "set" to make it disapear. |

##### Database

| Variable | Meaning |
| :-------------------------- | :-------------------------------------------------- |
| MONGO_INITDB_ROOT_USERNAME* | The username which should be used for the database. |
| MONGO_INITDB_ROOT_PASSWORD* | The password which should be used for the database. |
| MONGO_INITDB_DATABASE* | The name which should be used for the database. |

*By modifying any of these variables, remember to adjust the corresponding database URI in the backend configuration as well.

### 🤙 By hand:

Expand Down Expand Up @@ -165,7 +202,7 @@ Now you can configure the backend by adding parameters shown in the .env.example
##### Frontend:

To configure the frontend create a file with the name ".env" in the /frontend directory.
Now you can configure the frontendby adding parameters shown in the .env.example file.
Now you can configure the frontend by adding parameters shown in the .env.example file.

## Database

Expand Down
6 changes: 4 additions & 2 deletions actions/fullReport/indexReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function postMessage() {

// Helper function to parse environment variables or fallback to "-"
const parseValueOrDefault = (value) => {
return value ? parseInt(value) : "-";
return value ? parseInt(value) : 0;
};

function calculatePercentage(num1, num2) {
Expand All @@ -34,12 +34,14 @@ async function postMessage() {
}

function getStatus(passed, total) {
if (passed === 0) return "⚠️";
return passed === total ? "✅" : "⚠️";
}

function calcTotal(dockerStatus, num1, num2) {
if (!dockerStatus) return "-";
if (isNaN(num1) || isNaN(num2)) return "-";
if (isNaN(num1)) num1 = 0;
if (isNaN(num2)) num1 = 0;
return num1+num2;
}

Expand Down
48 changes: 28 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: "2.12"

services:

seedmongodb:
container_name: "Seed-MongoDB"
image: mongo
Expand All @@ -15,36 +14,45 @@
- MONGO_INITDB_ROOT_PASSWORD=SeedTest
- MONGO_INITDB_DATABASE=Seed
restart: always

backend:
build:
context: ./backend
dockerfile: Dockerfile
args:
- BUILD_DATE=${BUILD_DATE:-$$(date -u +"%Y-%m-%dT%H:%M:%SZ")}
- VCS_REF=${VCS_REF:-$$(git rev-parse --short HEAD)}
- IMAGE_NAME=seed-test-backend:latest
image: seed-test-backend:latest
image: seedtest/seed-test-backend:latest
ports:
- "${BACKENDPORT}:${BACKENDPORT}"
- "8080:8080"
container_name: "Seed-backend"
depends_on:
- seedmongodb
restart: always

environment:
DATABASE_URI: mongodb://SeedAdmin:SeedTest@seedmongodb:27017

Check failure

Code scanning / SonarCloud

Sensitive secrets should not be disclosed Critical

Make sure this MongoDB database password gets changed and removed from the code. See more on SonarCloud
REPORT_DELETION_TIME: 5
TESTACCOUNT_NAME:
TESTACCOUNT_REPO:
TESTACCOUNT_TOKEN:
SESSION_SECRET: 'secretSessionKey'
JIRA_SECRET: 'secretJiraKey'
JIRA_SALT: 'BJ1yJTJ7AFql'
Unassigned_AVATAR_URL: 'https://cdn.pixabay.com/photo/2016/08/08/09/17/avatar-1577909_960_720.png'
EMAIL_AUTH:
EMAIL_PW:
EMAIL_PORT:
EMAIL_HOST:
GITHUB_CLIENT_SECRET:
GITHUB_CLIENT_ID:
PASSPORT_GITHUB_LOCAL_PW_FIELD: 'id'
MAX_SAVED_REPORTS:

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
- BUILD_DATE=${BUILD_DATE:-$$(date -u +"%Y-%m-%dT%H:%M:%SZ")}
- VCS_REF=${VCS_REF:-$$(git rev-parse --short HEAD)}
- IMAGE_NAME=seed-test-frontend:latest
image: seed-test-frontend:latest
image: seedtest/seed-test-frontend:latest
ports:
- "${FRONTENDPORT}:${FRONTENDPORT}"
- "4200:4200"
container_name: "Seed-frontend"
depends_on:
- backend
restart: always
environment:
GITHUB_CLIENT_ID:
VERSION:

volumes:
seedDB:
24 changes: 24 additions & 0 deletions docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "2.12"

services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
image: seed-test-backend:latest
ports:
- "8080:8080"
container_name: "Seed-backend"
restart: always

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
image: seed-test-frontend:latest
ports:
- "4200:4200"
container_name: "Seed-frontend"
depends_on:
- backend
restart: always
Loading
Loading