Skip to content

Commit

Permalink
add cicd & docker
Browse files Browse the repository at this point in the history
  • Loading branch information
erayaydogdu committed Dec 11, 2023
1 parent 14346c4 commit fbba239
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 18 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/dotnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: dotnet-cicd
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
push_to_docker:
type: boolean
description: Docker Push
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Create Docker Image
run: dotnet publish -c Release -p:ContainerImageName=${{ secrets.DOCKER_USERNAME }}/minimal-url-shortener -p:RuntimeIdentifier=linux-arm64
docker:
name: Docker
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Image to Hub
run: docker push ${{ secrets.DOCKER_USERNAME }}/minimal-url-shortener --all-tags
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/minimal-url-shortener/bin/Debug/net6.0/minimal-url-shortener.dll",
"program": "${workspaceFolder}/minimal-url-shortener/bin/Debug/net8.0/minimal-url-shortener.dll",
"args": [],
"cwd": "${workspaceFolder}/minimal-url-shortener",
"stopAtEntry": false,
Expand Down
31 changes: 19 additions & 12 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
### Minimal URL Shortener with .NET Minimal API, htmx, and DaisyUI

This is a fun and efficient project that combines the power of .NET Minimal API, htmx, and DaisyUI to create a robust web application for shortening and managing URLs. This application is built with C#, LiteDB, Hashids, and leverages the minimal API capabilities for an optimal experience. The addition of htmx ensures lightweight and fast frontend interactions, while DaisyUI provides additional styling with Tailwind CSS.
This is a fun and lightweight project that combines the power of .NET Minimal API, htmx, and DaisyUI to create a robust web application for shortening and managing URLs. This application is built with C#, LiteDB, Hashids, and leverages the minimal API capabilities for an optimal experience. The addition of htmx ensures lightweight and fast frontend interactions, while DaisyUI provides additional styling with Tailwind CSS.

## Getting Started

Follow one of these steps to set up and run the URL shortener service on your local machine:

**Clone the Repository:**
```bash
git clone https://github.com/erayaydogdu/minimal-url-shortener.git
cd minimal-url-shortener
```

**or run Docker:**
```bash
docker run -p 5148:5148 --name mus erayaydogdu/minimal-url-shortener
# When the container is up and running you can visit: http://mus:5148/
```


## Features

Expand All @@ -26,14 +43,4 @@ This project makes use of the following technologies:
- **LiteDB:** A simple and lightweight NoSQL database used for storing URLs.
- **Hashids:** An efficient library for generating unique and human-readable hash-like IDs.
- **htmx:** A JavaScript library that enhances web pages with minimal JavaScript for seamless interactions.
- **DaisyUI with Tailwind CSS:** Additional styling and UI components provided by DaisyUI for a polished and aesthetic interface.

## Getting Started

Follow these steps to set up and run the URL shortener service on your local machine:

1. **Clone the Repository:**
```bash
git clone https://github.com/erayaydogdu/url-shortener.git
cd url-shortener
```
- **DaisyUI with Tailwind CSS:** Additional styling and UI components provided by DaisyUI for a polished and aesthetic interface.
3 changes: 1 addition & 2 deletions src/Frontend/Components/UrlModelDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
</td>

<td class="px-4 py-3 text-xs border">
@* <span class="px-2 py-1 font-semibold leading-tight text-accent bg-green-100 rounded-sm"> Acceptable </span> *@
<button class="btn btn-ghost" onclick="copyText('@Model.ShortUrl');">
<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" data-name="Layer 1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"><title/><path d="M27.2,8.22H23.78V5.42A3.42,3.42,0,0,0,20.36,2H5.42A3.42,3.42,0,0,0,2,5.42V20.36a3.43,3.43,0,0,0,3.42,3.42h2.8V27.2A2.81,2.81,0,0,0,11,30H27.2A2.81,2.81,0,0,0,30,27.2V11A2.81,2.81,0,0,0,27.2,8.22ZM5.42,21.91a1.55,1.55,0,0,1-1.55-1.55V5.42A1.54,1.54,0,0,1,5.42,3.87H20.36a1.55,1.55,0,0,1,1.55,1.55v2.8H11A2.81,2.81,0,0,0,8.22,11V21.91ZM28.13,27.2a.93.93,0,0,1-.93.93H11a.93.93,0,0,1-.93-.93V11a.93.93,0,0,1,.93-.93H27.2a.93.93,0,0,1,.93.93Z"/></svg>
<span class="material-icons">content_copy</span>
</button>
</td>
</tr>
Expand Down
3 changes: 1 addition & 2 deletions src/Frontend/Components/UrlModelList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
</td>

<td class="px-4 py-3 text-xs border">
@* <span class="px-2 py-1 font-semibold leading-tight text-accent bg-green-100 rounded-sm"> Acceptable </span> *@
<button class="btn btn-ghost" onclick="copyText('@item.ShortUrl');">
<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" data-name="Layer 1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"><title/><path d="M27.2,8.22H23.78V5.42A3.42,3.42,0,0,0,20.36,2H5.42A3.42,3.42,0,0,0,2,5.42V20.36a3.43,3.43,0,0,0,3.42,3.42h2.8V27.2A2.81,2.81,0,0,0,11,30H27.2A2.81,2.81,0,0,0,30,27.2V11A2.81,2.81,0,0,0,27.2,8.22ZM5.42,21.91a1.55,1.55,0,0,1-1.55-1.55V5.42A1.54,1.54,0,0,1,5.42,3.87H20.36a1.55,1.55,0,0,1,1.55,1.55v2.8H11A2.81,2.81,0,0,0,8.22,11V21.91ZM28.13,27.2a.93.93,0,0,1-.93.93H11a.93.93,0,0,1-.93-.93V11a.93.93,0,0,1,.93-.93H27.2a.93.93,0,0,1,.93.93Z"/></svg>
<span class="material-icons">content_copy</span>
</button>
</td>
</tr>
Expand Down
13 changes: 12 additions & 1 deletion src/Frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
<title>Minimal Url Shortener</title>
</head>
<body class="container max-w-xl mx-auto">
<h1 class="font-bold text-2xl my-16">Url Shortener Service</h1>
<div class="text-center">
<svg class="w-32 mx-auto text-accent" width="65px" height="65px" viewBox="0 0 400 400" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M74 211.658C99.0457 142.251 155.836 87.1314 226.717 108.765C276.177 123.861 255.428 151.992 274.648 170.486C285.492 178.829 314.933 167.631 322.548 178.047C329.28 187.259 324.416 204.065 322.548 215.097C315.179 258.597 265.313 265 223.065 265" stroke="currentColor" stroke-opacity="0.9" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M325 194C321.518 187.392 313.572 181.214 304 176" stroke="currentColor" stroke-opacity="0.9" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M132.242 181.22C129.728 194.908 90.9731 288.143 131.095 296.086C205.608 306.73 196.665 221.971 196.665 169" stroke="currentColor" stroke-opacity="0.9" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M234 168V173" stroke="currentColor" stroke-opacity="0.9" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<h1 class="font-bold text-2xl my-4">
Url Shortener Service
</h1>
</div>


<form class="grid grid-cols-7 m-4 gap-2"
hx-post="/shorten"
Expand Down

0 comments on commit fbba239

Please sign in to comment.