feat: website autodeploy scripts
Some checks failed
/ mirror (push) Successful in 4s
/ deploy (push) Failing after 9s

This commit is contained in:
ange 2024-11-28 03:35:42 +00:00
parent 9cd0c612dd
commit c7e348c190
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
30 changed files with 246 additions and 20735 deletions

View File

@ -0,0 +1,37 @@
on:
push:
paths:
- website/**
jobs:
deploy:
runs-on: debian
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@v1
- name: setup env
run: |
. ./.env || true
if [ "${{ gitea.ref_name }}" == prod ] && [ -n "$PROD_URL" ]; then
BASE_URL="$PROD_URL"
else
BASE_URL="${{ gitea.ref_name }}.$(tr / '\n' <<< "${{ gitea.repository }}" | tac | tr '\n' .)k8s.gmoker.com"
fi
REGISTRY="$(sed 's .*:// ' <<< ${{ gitea.server_url }})"
cat <<EOF >> .env
BASE_URL="$BASE_URL"
REGISTRY="$REGISTRY"
IMAGEAPP="$REGISTRY/${{ gitea.repository }}:${{ gitea.ref_name }}"
EOF
cat .env
- uses: actions/kaniko@v1
with:
password: "${{ secrets.PKGRW }}"
- uses: actions/k8sdeploy@v1
with:
kubeconfig: "${{ secrets.K8S }}"
registry_password: "${{ secrets.PKGRW }}"

1
website/.env Normal file
View File

@ -0,0 +1 @@
PROD_URL=icing.gmoker.com

42
website/.gitignore vendored
View File

@ -1,23 +1,27 @@
.DS_Store
node_modules
/dist
# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go
### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# local env files
.env.local
.env.*.local
# Test binary, built with `go test -c`
*.test
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
# End of https://www.toptal.com/developers/gitignore/api/go

14
website/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
ARG VER=1.23
FROM "docker.io/golang:$VER" as build
WORKDIR /build/
ARG VER
COPY main.go .
RUN printf "module yw5n\ngo $VER" > go.mod && CGO_ENABLED=0 go build -o /app
FROM scratch
COPY --from=build /app /app
COPY static/ /static/
COPY html/ /html/
EXPOSE 3000
CMD ["/app"]

View File

@ -1,24 +0,0 @@
# my-vue-app
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@ -1,5 +0,0 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

6
website/compose.yaml Normal file
View File

@ -0,0 +1,6 @@
---
services:
app:
build: .
ports:
- "3000:3000"

12
website/html/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Icing</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<img src="static/logo.webp" alt="Logo">
<p>Hello, World!</p>
</body>
</html>

11
website/html/style.css Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,19 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

32
website/main.go Normal file
View File

@ -0,0 +1,32 @@
package main
import (
"log"
"net/http"
"path/filepath"
)
func route(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/style.css" {
http.ServeFile(w, r, "/html/style.css")
return
}
if len(r.URL.Path) > len("/static/") && r.URL.Path[:len("/static/")] == "/static/" {
http.ServeFile(w, r, r.URL.Path)
return
}
if r.URL.Path == "/" {
http.ServeFile(w, r, "/html/index.html")
return
}
http.ServeFile(w, r, filepath.Join("/html", r.URL.Path + ".html"))
}
func main() {
http.HandleFunc("/", route)
err := http.ListenAndServe(":3000", nil)
if err != nil {
log.Fatal(err)
}
}

36
website/manifests/bin/deploy.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash -e
set -o pipefail
function kapply() {
for f in "$@"; do
kubectl apply -f \
<(envsubst "$(env | xargs printf '$%s ')" < "manifests/$f")
done
}
function kcreatesec() {
kubectl create secret generic --save-config --dry-run=client -oyaml "$@" | kubectl apply -f-
}
function kcreatecm() {
kubectl create configmap --dry-run=client -oyaml "$@" | kubectl apply -f-
}
function kgseckey() {
local sec="$1"; shift
local key="$1"; shift
kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d
}
function kgcmkey() {
local cm="$1"; shift
local key="$1"; shift
kubectl get configmap "$cm" -o jsonpath="{.data.$key}"
}
kapply common/app.yaml
kubectl rollout restart deployment app

5
website/manifests/bin/devel.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash -e
export NB_REPLICAS=1
. ./manifests/bin/deploy.sh

5
website/manifests/bin/prod.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash -e
export NB_REPLICAS=3
. ./manifests/bin/deploy.sh

View File

@ -0,0 +1,64 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: nginx
tls:
- secretName: tls-app
hosts:
- "$BASE_URL"
rules:
- host: "$BASE_URL"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app
port:
name: http
---
apiVersion: v1
kind: Service
metadata:
name: app
labels:
app: app
spec:
selector:
app: app
ports:
- name: http
port: 80
targetPort: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
labels:
app: app
spec:
replicas: $NB_REPLICAS
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
imagePullSecrets:
- name: regcred
containers:
- name: app
image: "$IMAGEAPP"
imagePullPolicy: Always
ports:
- name: http
containerPort: 3000

View File

View File

20230
website/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
{
"name": "my-vue-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"vue": "^3.2.13",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -1,19 +0,0 @@
<!-- App.vue -->
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'App',
};
</script>
<style>
/* Global styles can be added here */
body {
margin: 0;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -1,58 +0,0 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

View File

@ -1,36 +0,0 @@
<!-- src/components/Home.vue -->
<template>
<div id="home">
<h1 class="centered">
<router-link to="/description" class="no-underline">ICING</router-link>
</h1>
</div>
</template>
<script>
export default {
name: 'HomePage',
};
</script>
<style>
.centered {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-size: 3em;
margin: 0;
}
.no-underline {
text-decoration: none;
color: inherit;
}
body {
margin: 0;
}
</style>

View File

@ -1,230 +0,0 @@
<!-- src/components/Description.vue -->
<template>
<div id="description" class="content">
<h1 class="title">Project Description</h1>
<div class="project-overview">
<h2 class="section-title">What is Icing?</h2>
<p>
Icing is a simple, lightweight, and efficient dialer designed to replace your everyday phone app. It ensures end-to-end encryption of telephone communications by implementing a home-made, analogic-based voice encryption. Inspired by SRTP (Secure Real-time Transport Protocol), using ECDH (Elliptic Curve Diffie-Hellman).
</p>
</div>
<div class="features">
<h2 class="section-title">Key Features</h2>
<ul>
<li><strong>End-to-End Encryption:</strong> Secure your calls with robust encryption protocols.</li>
<li><strong>Transparent:</strong> If your peer doesn't use Icing, the call remains completely normal.</li>
<li><strong>Analogic-based:</strong> An open-source, exportable, protocol that <strong>works without internet.</strong></li>
</ul>
</div>
<div class="how-it-works">
<h2 class="section-title">How It Works</h2>
<p>
Icing generates a cryptographic key pair for you. Share your public key with a neat QR code.
</p>
<p>
During a call between two Icing users, voices are encrypted, compressed, and transmitted via the telephone network using the Icing Acoustic Protocol.
</p>
</div>
<div class="team">
<h2 class="section-title">Our Team</h2>
<p>
We are a team of five dedicated individuals working on this solution:
</p>
<ul class="team-list">
<li><a href="https://github.com/Bartoszkk/" target="_blank">Bartoszkk</a></li>
<li><a href="https://github.com/AustralEpitech/" target="_blank">AustralEpitech</a></li>
<li><a href="https://github.com/STCB/" target="_blank">STCB</a></li>
<li><a href="https://github.com/FlorianGRIFFON/" target="_blank">Florian GRIFFON</a></li>
<li><a href="https://github.com/AlexisDanlos/" target="_blank">Alexis Danlos</a></li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: 'ProjectDescription',
};
</script>
<style scoped>
/* Theme colors */
:root {
--primary-color: #000000; /* Green accent color */
--background-color: #f5f5f5; /* Light background */
--text-color: #333; /* Dark text */
--secondary-text-color: #777; /* Secondary text color */
}
/* Base styles */
.content {
margin: 20px auto;
max-width: 900px;
padding: 40px;
background-color: var(--background-color);
color: var(--text-color);
border-radius: 8px;
font-family: 'Open Sans', Arial, sans-serif;
position: relative;
overflow: hidden;
}
.title {
font-size: 2.5em;
color: var(--primary-color);
margin-bottom: 30px;
text-align: center;
animation: fadeInDown 1s ease;
}
.section-title {
font-size: 1.8em;
color: var(--primary-color);
margin-top: 40px;
margin-bottom: 20px;
position: relative;
animation: fadeInLeft 1s ease;
}
.section-title::after {
content: '';
width: 50px;
height: 3px;
background-color: var(--primary-color);
position: absolute;
bottom: -10px;
left: 0;
}
p, li {
line-height: 1.6;
font-size: 1.1em;
animation: fadeIn 1s ease;
}
ul {
margin-left: 20px;
list-style-type: disc;
}
.features ul li {
margin-bottom: 10px;
}
.team-list {
list-style-type: none;
padding: 0;
}
.team-list li {
margin-bottom: 8px;
font-weight: bold;
color: var(--text-color);
}
.back-link-container {
text-align: center;
margin-top: 40px;
animation: fadeInUp 1s ease;
}
.back-link {
text-decoration: none;
color: var(--primary-color);
font-weight: bold;
border: 2px solid var(--primary-color);
padding: 10px 20px;
border-radius: 5px;
transition: background-color 0.3s, color 0.3s;
}
.back-link:hover {
background-color: var(--primary-color);
color: #fff;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-20px);
} to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInLeft {
from {
opacity: 0;
transform: translateX(-20px);
} to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
} to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
} to {
opacity: 1;
}
}
/* Responsive Design */
@media (max-width: 768px) {
.content {
padding: 20px;
}
.title {
font-size: 2em;
}
.section-title {
font-size: 1.5em;
}
p, li {
font-size: 1em;
}
}
@media (max-width: 480px) {
.content {
padding: 15px;
}
.title {
font-size: 1.8em;
}
.section-title {
font-size: 1.2em;
}
p, li {
font-size: 0.9em;
}
}
a {
color: var(--primary-color);
text-decoration: none;
}
</style>

View File

@ -1,6 +0,0 @@
// src/main.js
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
createApp(App).use(router).mount('#app');

View File

@ -1,24 +0,0 @@
// src/router.js
import { createRouter, createWebHistory } from 'vue-router';
import HomePage from './components/HomePage.vue';
import ProjectDescription from './components/ProjectDescription.vue';
const routes = [
{
path: '/',
name: 'HomePage',
component: HomePage,
},
{
path: '/description',
name: 'ProjectDescription',
component: ProjectDescription,
},
];
const router = createRouter({
history: createWebHistory(),
routes,
});
export default router;

BIN
website/static/logo.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,4 +0,0 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})