Hello World.

Welcome to my overview site, a .NET 8 web app built using ASP.NET Core with Razor Pages, Dockerized for smooth development and deployment workflows.

Technologies Used

.NET 8 Logo

.NET 8 - An iteration of the .NET platform, providing performance improvements and enhanced features for building modern applications.

Containerization with Docker

Docker Logo

Docker - Docker containers are used to package the app for consistency across development and production environments, ensuring reliability and scalability.

Environments

Windows 11 Logo

Windows 11 Dev Machine - Development environment utilizing Windows 11 for building and testing the application locally using Visual Studio and Docker.

Ubuntu 22.04 Logo

Ubuntu 22.04 Prod Machine - The app runs in a production environment using Ubuntu 22.04 for stability, performance, and security in containerized Docker environments.

Dockerization

The app is containerized using Docker, allowing it to be easily deployed and run consistently across different environments (Windows, Linux).

Script for building and pushing code to Git from Windows 11 Dev Machine


REM Navigate to the project directory
cd C:\Users\kevsi\source\repos\Overview

REM Ensure we are on the correct branch, check current status
git status

REM Switch to the dev branch (if not already on it)
git checkout dev

REM Add all changes to staging
git add .

REM Commit changes with a message
git commit -m "Automated commit for Docker image update."

REM Push changes to the remote dev branch
git push -u origin dev

REM Pause to see output
pause

                

Script for pushing to Docker Hub and deploying on Ubuntu 22.04 with Discord Notifications from Git Actions


name: CI - Development

on:
  push:
    branches:
      - "dev"  # This triggers the workflow when changes are pushed to the 'dev' branch

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

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

      - name: Build and push Docker image to dev tag
        uses: docker/build-push-action@v6
        with:
          context: .
          file: Overview/Dockerfile
          push: true
          tags: kevinsiraki/overview:dev  # This will push the image with a "dev" tag

      - name: SSH and run dev deploy script on remote server
        env:
          SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
        run: |
          # Set up SSH
          mkdir -p ~/.ssh
          echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa

          # SSH into the server and run the dev deploy script with sudo
          ssh -o StrictHostKeyChecking=no -p 47441 kevinsiraki@donttrip.org << EOF
            export SERVER_PASSWORD="${SERVER_PASSWORD}"
            echo "$SERVER_PASSWORD" | sudo -S /home/kevinsiraki/overview/deploy-dev.sh  # Run dev-specific deploy script
          EOF

      - name: Send success message to Discord
        env:
          DISCORD_WEBHOOK_DEV: ${{ secrets.DISCORD_WEBHOOK_DEV }}  # Your webhook URL stored as a secret
        run: |
          # Send a message to Discord indicating the success of the deployment
          curl -X POST $DISCORD_WEBHOOK_DEV \
            -H "Content-Type: application/json" \
            -d '{"content": "Deployment to the dev environment was successful! 🚀"}'

                

Bash script on Ubuntu 22.04 server that is triggered via Git Actions


#!/bin/bash

sudo docker rm -f overview-container-dev

# Pull the latest version of the kevin siraki overview image
echo "Pulling the latest kevin siraki overview image..."
sudo docker pull kevinsiraki/overview:dev

# Run the Docker container
echo "Running the container..."
sudo docker run -d -p 8083:8080 -p 8084:8081 --name overview-container-dev kevinsiraki/overview:dev