Skip to content

Commit

Permalink
Merge pull request #482 from adessoSE/docker-demo-container
Browse files Browse the repository at this point in the history
Docker-demo-container
  • Loading branch information
i3rotlher authored Oct 26, 2023
2 parents 6c1a39f + ea2da49 commit ff59ea9
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 6 deletions.
116 changes: 111 additions & 5 deletions .github/workflows/Build_and_Publish_Images.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Build and Publish Docker Image

on:
push:
tags:
- 'Seed-Test_v*'
release:
types:
- published
- edited

jobs:
build-and-publish:
build-and-publish-release:
runs-on: ubuntu-latest
if: startsWith(github.event.release.name, 'Seed-Test_v')
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Dependencies
run: npm install node-fetch

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -50,4 +55,105 @@ jobs:
- 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
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest
# SINGLE QUICK DEMO CONTAINER
- name: Build Docker Image as Latest
run: |
docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} .
- name: Tag Docker Image as Latest
run: |
docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest
- name: Post susccess message
uses: ./actions/notifyTeams
with:
title: "Publish Release DockerHub 🐳🌐"
text: "Publishing Images for release ${{ github.event.release.name }} successfully."
style: "success"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}

- name: Post error message
if: ${{ failure() }}
uses: ./actions/notifyTeams
with:
title: "Publish Release DockerHub 🐳🌐❌"
text: "Publishing Images for release ${{ github.event.release.name }} failed."
style: "failure"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}

build-and-publish-test:
runs-on: ubuntu-latest
if: startsWith(github.event.release.name, 'Test_v')
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Dependencies
run: npm install node-fetch

- 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\///')
echo "version=${version}" >> ${GITHUB_OUTPUT}
# BACKEND
- name: Build Docker Image
run: |
docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend
docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }}
# FRONTEND
- name: Build Docker Image
run: |
docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend
docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }}
# SINGLE QUICK DEMO CONTAINER
- name: Build Docker Image as Latest
run: |
docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} .
docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }}
- name: Post susccess message
uses: ./actions/notifyTeams
with:
title: "Publish Test-Release DockerHub 🧪🐳🌐"
text: "Publishing Images for test-release ${{ github.event.release.name }} successfully."
style: "success"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}

- name: Post error message
if: ${{ failure() }}
uses: ./actions/notifyTeams
with:
title: "Publish Test-Release DockerHub 🐳🌐❌"
text: "Publishing Images for test-release ${{ github.event.release.name }} failed."
style: "failure"
webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
109 changes: 109 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
FROM node:18.13

RUN apt-get update && apt-get -y install wget

# Set DATABASE_URI to be localhost
ENV DATABASE_URI=mongodb://localhost:27017

# Create app directory
WORKDIR /usr/src/app

# install mongoDB
RUN apt-get -y install gnupg curl
RUN curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \
gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
RUN apt-get update && apt-get -y install mongodb-org
RUN mkdir /data
RUN mkdir /data/db
RUN mongod --fork --logpath /var/log/mongodb.log

# ----- BACKEND (from /backend dockerfile) -----------------------------------------------------------------------

# install chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get -y install ./google-chrome-stable_current_amd64.deb
RUN rm -f google-chrome-stable_current_amd64.deb

# install chromedriver
RUN google-chrome --version | grep -oP '\d+\.\d+\.\d+\.\d+' > chromeversion.txt
RUN apt-get install -yqq unzip curl
RUN wget -O /tmp/chromedriverzip.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$(cat chromeversion.txt)/linux64/chromedriver-linux64.zip
RUN unzip /tmp/chromedriverzip.zip chromedriver-linux64/chromedriver -d /usr/local/bin/
RUN mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver

# install firefox
RUN wget -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"
RUN tar xjf ~/FirefoxSetup.tar.bz2 -C /opt/
RUN ln -s /opt/firefox/firefox /usr/local/bin/
RUN apt-get update && apt-get install -y wget bzip2 libxtst6 libgtk-3-0 libx11-xcb-dev libdbus-glib-1-2 libxt6 libpci-dev && rm -rf /var/lib/apt/lists/*

# install edge
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
RUN install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
RUN rm microsoft.gpg
RUN apt-get update && apt-get install -y microsoft-edge-stable
# include in path
RUN export PATH=$PATH:/opt/microsoft/msedge/
ENV PATH="${PATH}:/opt/microsoft/msedge/"

# install msedgedriver
# # Extract the latest stable version of edge
RUN msedge --version | sed 's/.*Edge \([0-9.]*\).*/\1/' > latest_stable.txt

# # Remove the driver-pagehtml
RUN wget -O /tmp/msedgedriver.zip https://msedgedriver.azureedge.net/$(cat latest_stable.txt)/edgedriver_linux64.zip
RUN unzip /tmp/msedgedriver.zip msedgedriver -d /usr/local/bin/
RUN rm -f latest_stable.txt

# Clean up the cache after installing all necessary packages
RUN apt-get update && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app/backend
# Bundle app source
COPY ./backend .

RUN npm ci
# If you are building your code for production
# RUN npm ci --only=production

EXPOSE 8080

# Start dbus-daemon for google-chrome
RUN service dbus start

# ----- FRONTEND (from /frontend dockerfile) ---------------------------------------------------------------------

# Create app directory
WORKDIR /usr/src/app/frontend

# Copy package.json and package-lock.json
COPY ./frontend/package*.json ./

# Install dependencies
RUN npm ci --ignore-scripts

# Install Angular CLI
RUN npm install --ignore-scripts -g @angular/cli

COPY ./frontend .

EXPOSE 4200
EXPOSE 27017-27019
RUN npm run build

# -----------------------------------------------------------------------------------------------------------------

# Create a startup script
RUN echo "#!/bin/sh" > /usr/src/app/start.sh && \
echo "mongod --fork --logpath /var/log/mongodb.log" >> /usr/src/app/start.sh && \
echo "cd /usr/src/app/backend && npm run database && npm run database-examples && npm run start &" >> /usr/src/app/start.sh && \
echo "cd /usr/src/app/frontend && node server.js" >> /usr/src/app/start.sh

# Make the script executable
RUN chmod +x /usr/src/app/start.sh

# Set the script as the ENTRYPOINT
ENTRYPOINT ["/usr/src/app/start.sh"]
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ Seed-Test is a website user interface testing tool, which uses approaches of beh

Please contact us via mail [email protected]

Seed-Test can be installed via docker or by hand.

## 🚀Give Seed-Test Demo a Try!

Seed-Test offers a handy demo version that's ready for you to dive into. If you're just looking to test out Seed-Test, you can easily do so by installing this demo.

#### Prerequisites

Before you begin, make sure you have [Docker](https://www.docker.com/products/docker-desktop/) installed.

#### Installation

Follow these simple steps to get up and running:

- Open your terminal and run this command:

```
docker run -p 4200:4200 -p 8080:8080 seedtest/seed-test-demo:latest
```

**Try Seed-Test in Your Browser**

Now, you can experience Seed-Test in your web browser at http://localhost:4200.

An example user account is ready for you to explore.

- <b>E-Mail:</b> `[email protected]`
- <b>Password:</b> `seedtest`

<b>Have Fun! 🚀🌟</b>

#### ⚠️ Important Note

Please note that Seed-Test's demo version is for testing purposes only and should not be used in a production environment. For production use, consider using the full version of Seed-Test. Check out the Installation section bellow.

## Installation

Seed-Test can be installed via docker or by hand.
Expand Down
5 changes: 4 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "jest --verbose",
"test-coverage": "jest --coverage",
"database": "node src/database/installDatabase.js",
"database-examples": "node src/database/insertExampleData.js",
"clean": "rimraf ./dist",
"tsc": "tsc",
"lint": "./node_modules/.bin/eslint src/database --fix",
Expand Down Expand Up @@ -69,6 +70,8 @@
"<rootDir>/spec/serverHelper.spec.js",
"<rootDir>/node_modules/"
],
"setupFiles": ["./spec/setupTest.js"]
"setupFiles": [
"./spec/setupTest.js"
]
}
}
Loading

0 comments on commit ff59ea9

Please sign in to comment.