Add custom nginx conf for kb manager #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Knowledge Manager | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# 1) Create the environment file for Angular (similar to chatbot approach) | |
- name: Create Environment File | |
run: | | |
echo "export const environment = { | |
production: false, | |
backendUrl: '/api', | |
angelosAppApiKey: '${{secrets.ANGELOS_APP_API_KEY}}' | |
};" > src/environments/environment.prod.ts | |
- name: Verify Environment File Creation | |
run: | | |
if [ -f src/environments/environment.prod.ts ]; then | |
echo "Environment file created successfully." | |
else | |
echo "Environment file creation failed." && exit 1 | |
fi | |
- 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: Build and Push Knowledge Manager Image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64, linux/arm64 | |
file: ./Dockerfile | |
context: . | |
tags: ghcr.io/ls1intum/knowledge-manager:latest | |
push: true | |
no-cache: true | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# ------------------------------------------------- | |
# COPY KNOWLEDGE MANAGER DOCKER COMPOSE | |
# ------------------------------------------------- | |
- name: Copy Knowledge Manager Compose to VM | |
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 }}/${{ github.repository }}" | |
# ------------------------------------------------- | |
# COPY REVERSE-PROXY DOCKER COMPOSE + nginx.conf | |
# ------------------------------------------------- | |
- name: Copy Reverse Proxy Compose to VM | |
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: "./reverse-proxy/docker-compose.yml" | |
target: "/home/${{ vars.VM_USERNAME }}/${{ github.repository }}" | |
- name: Copy Reverse Proxy nginx.conf to VM | |
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: "./reverse-proxy/nginx.conf" | |
target: "/home/${{ vars.VM_USERNAME }}/${{ github.repository }}" | |
# ------------------------------------------------- | |
# SSH INTO VM, RUN BOTH KNOWLEDGE MANAGER AND REVERSE PROXY | |
# ------------------------------------------------- | |
- name: SSH to VM and Start Services | |
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: | | |
# 1) Ensure the shared Docker network exists | |
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 | |
fi | |
# 2) Spin up Knowledge Manager | |
cd /home/${{ vars.VM_USERNAME }}/${{ github.repository }} | |
docker compose pull knowledge-manager | |
docker compose up -d --force-recreate --remove-orphans | |
# 3) Spin up Reverse Proxy | |
cd reverse-proxy | |
docker compose pull nginx-proxy || true | |
docker compose up -d --force-recreate --remove-orphans | |
# 4) Optional: Verify running containers | |
docker ps |