Skip to content

Commit

Permalink
Merge pull request #2 from ls1intum/cicd
Browse files Browse the repository at this point in the history
added ci cd pipeline
  • Loading branch information
Unischneider authored Oct 24, 2024
2 parents daf502d + ed0b387 commit fcd6ab7
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 7 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Deploy Angelos-UI

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Check if Docker network exists and create it if not
run: |
if ! docker network inspect angelos-network >/dev/null 2>&1; then
echo "Network 'angelos-network' does not exist, creating it..."
docker network create angelos-network
else
echo "Network 'angelos-network' already exists."
fi
- name: Build and Push to GitHub Container Registry
uses: docker/build-push-action@v6
with:
platforms: amd64, arm64
file: ./Dockerfile
context: .
tags: ghcr.io/ls1intum/eunomnia:latest
push: true

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- name: Copy Docker Compose File From Repo to VM Host
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
source: "./docker-compose.yml"
target: /home/${{ vars.VM_USERNAME }}


- name: SSH to VM and Execute Docker-Compose Up
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
docker compose -f /home/${{ vars.VM_USERNAME }}/docker-compose.yml --env-file=.env.prod up --pull=always -d
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:20-alpine AS build
WORKDIR /app

COPY package.json package-lock.json ./
RUN npm install

COPY . ./
RUN npm install
RUN npm run build -- --configuration=production

FROM nginx:stable-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist/angelos-ui/browser /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
8 changes: 7 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
"sourceMap": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "production"
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
angelos-ui:
image: "ghcr.io/ls1intum/angelos-ui:latest"
ports:
- "80:80"
container_name: angelos-ui
expose:
- "80"
networks:
- angelos-network

networks:
angelos-network:
external: true
16 changes: 16 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {

listen 80;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}

}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "angelos-ui",
"version": "0.0.0",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build": "ng build --configuration production",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
Expand Down Expand Up @@ -36,4 +36,4 @@
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.5.2"
}
}
}
3 changes: 2 additions & 1 deletion src/app/services/chatbot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ChatMessage } from '../chat/chat.component';
import { Observable } from 'rxjs';
import { environment } from '../../environments/environment.development';

@Injectable({
providedIn: 'root'
Expand All @@ -11,6 +12,6 @@ export class ChatbotService {
constructor(private http: HttpClient) { }

getBotResponse(chatHistory: ChatMessage[], study_program: string): Observable<any> {
return this.http.post('http://localhost:8000/api/v1/question/chat', { messages: chatHistory, study_program: study_program });
return this.http.post(environment.angelosUrl, { messages: chatHistory, study_program: study_program });
}
}
4 changes: 4 additions & 0 deletions src/environments/environment.development.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const environment = {
production: false,
angelosUrl: 'http://localhost:8000/api/v1/question/chat'
};
4 changes: 4 additions & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const environment = {
production: true,
angelosUrl: 'http://angelos-app:8000/api/v1/question/chat'
};

0 comments on commit fcd6ab7

Please sign in to comment.