This commit is contained in:
39
.gitea/workflows/work.yaml
Normal file
39
.gitea/workflows/work.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITEA_DOMAIN: git.tesses.org
|
||||||
|
GITEA_REGISTRY_USER: tesses50
|
||||||
|
RESULT_IMAGE_NAME: tesses50/myfirstkube
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Log in to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.GITEA_DOMAIN }}
|
||||||
|
username: ${{ env.GITEA_REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.PACKAGE_AND_BREW }}
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.GITEA_DOMAIN }}/${{ env.RESULT_IMAGE_NAME }}:latest
|
||||||
|
- name: Set up kubectl
|
||||||
|
uses: azure/setup-kubectl@v3
|
||||||
|
- name: Configure kubectl
|
||||||
|
run: echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
|
||||||
|
- name: Deploy to cluster
|
||||||
|
run: |
|
||||||
|
kubectl apply -f kubernetes/deployment.yaml
|
||||||
|
kubectl apply -f kubernetes/service.yaml
|
||||||
|
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
bin
|
||||||
|
obj
|
||||||
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM git.tesses.org/tesses50/crosslang-withshell:latest AS build
|
||||||
|
|
||||||
|
COPY . /src
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
RUN crosslang build
|
||||||
|
|
||||||
|
FROM git.tesses.org/tesses50/crosslang:latest
|
||||||
|
|
||||||
|
COPY --from=build /src/bin/myfirstkube-1.0.0.0-prod.crvm /mykube.crvm
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/env", "crossvm", "/mykube.crvm"]
|
||||||
8
cross.json
Normal file
8
cross.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https:\/\/crosslang.tesseslanguage.com\/\/schema\/cross-json-schema.json",
|
||||||
|
"info": {
|
||||||
|
"type": "console"
|
||||||
|
},
|
||||||
|
"name": "myfirstkube",
|
||||||
|
"version": "1.0.0.0-prod"
|
||||||
|
}
|
||||||
27
kubernetes/deployment.yaml
Normal file
27
kubernetes/deployment.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myfirstkube
|
||||||
|
labels:
|
||||||
|
app: myfirstkube
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: myfirstkube
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: myfirstkube
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: myfirstkube
|
||||||
|
image: git.tesses.org/tesses50/myfirstkube:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 4206
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 500Mi
|
||||||
|
limits:
|
||||||
|
memory: 600Mi
|
||||||
11
kubernetes/service.yaml
Normal file
11
kubernetes/service.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: myfirstkube
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: myfirstkube
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 4206
|
||||||
|
targetPort: 4206
|
||||||
BIN
res/favicon.ico
Normal file
BIN
res/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
BIN
res/image.png
Normal file
BIN
res/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
1
res/simple.min.css
vendored
Normal file
1
res/simple.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
src/components/counter.tcross
Normal file
5
src/components/counter.tcross
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var count = 0;
|
||||||
|
func Components.Counter()
|
||||||
|
{
|
||||||
|
return <p>Count is {++count}</p>;
|
||||||
|
}
|
||||||
38
src/components/shell.tcross
Normal file
38
src/components/shell.tcross
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
func Components.Shell(title,pages,body)
|
||||||
|
{
|
||||||
|
return <!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>myfirstkube - {title}</title>
|
||||||
|
<link rel="stylesheet" href="./css/simple.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>myfirstkube</h1>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<each(var item : pages)>
|
||||||
|
<li>
|
||||||
|
<if(item.active)>
|
||||||
|
<true>
|
||||||
|
<a aria-current="page" href={item.route}>{item.text}</a>
|
||||||
|
</true>
|
||||||
|
<false>
|
||||||
|
<a aria-current="page" href={item.route}>{item.text}</a>
|
||||||
|
</false>
|
||||||
|
</if>
|
||||||
|
</li>
|
||||||
|
</each>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<h1>{title}</h1>
|
||||||
|
<raw(body)>
|
||||||
|
<footer>
|
||||||
|
<p>Created using <a href="https://crosslang.tesseslanguage.com/">CrossLang</a> and <a href="https://simplecss.org/">SimpleCSS</a></p>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>;
|
||||||
|
}
|
||||||
26
src/pages/about.tcross
Normal file
26
src/pages/about.tcross
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
func Pages.About()
|
||||||
|
{
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/counter",
|
||||||
|
text = "Counter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = true,
|
||||||
|
route = "/about",
|
||||||
|
text = "About"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return Components.Shell(
|
||||||
|
"About Me",
|
||||||
|
pages,
|
||||||
|
<null><img src="./image.png"><p>{ipsum}</p></null>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
var ipsum="";
|
||||||
25
src/pages/counter.tcross
Normal file
25
src/pages/counter.tcross
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
func Pages.Counter()
|
||||||
|
{
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = true,
|
||||||
|
route = "/counter",
|
||||||
|
text = "Counter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/about",
|
||||||
|
text = "About"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return Components.Shell(
|
||||||
|
"Counter",
|
||||||
|
pages,
|
||||||
|
<null><h1>This is a counter</h1><raw(Components.Counter())></null>
|
||||||
|
);
|
||||||
|
}
|
||||||
32
src/pages/echo.tcross
Normal file
32
src/pages/echo.tcross
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
func Pages.Echo(text)
|
||||||
|
{
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/counter",
|
||||||
|
text = "Counter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/about",
|
||||||
|
text = "About"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return Components.Shell(
|
||||||
|
"Echo",
|
||||||
|
pages,
|
||||||
|
<if(text != null)>
|
||||||
|
<true>
|
||||||
|
<plink(text)>
|
||||||
|
</true>
|
||||||
|
<false>
|
||||||
|
<p>No text available</p>
|
||||||
|
</false>
|
||||||
|
</if>
|
||||||
|
);
|
||||||
|
}
|
||||||
27
src/pages/index.tcross
Normal file
27
src/pages/index.tcross
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
func Pages.Index()
|
||||||
|
{
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = true,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/counter",
|
||||||
|
text = "Counter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/about",
|
||||||
|
text = "About"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return Components.Shell("Main Page",pages,<section>
|
||||||
|
<form action="./echo" method="GET">
|
||||||
|
<input type="text" name="text" placeholder="Text to echo">
|
||||||
|
<input type="submit" value="Echo it">
|
||||||
|
</form>
|
||||||
|
<p>1 John 4:4: You, dear children, are from God and have overcome them, because the one who is in you is greater than the one who is in the world.</p>
|
||||||
|
</section>);
|
||||||
|
}
|
||||||
42
src/program.tcross
Normal file
42
src/program.tcross
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
var count = 0;
|
||||||
|
func main(args)
|
||||||
|
{
|
||||||
|
Net.Http.ListenSimpleWithLoop((ctx)=>{
|
||||||
|
if(ctx.Path == "/")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("text/html").SendText(Pages.Index());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(ctx.Path == "/counter")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("text/html").SendText(Pages.Counter());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(ctx.Path == "/about")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("text/html").SendText(Pages.About());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(ctx.Path == "/echo")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("text/html").SendText(Pages.Echo(ctx.QueryParams.TryGetFirst("text")));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(ctx.Path == "/image.png")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("image/png").SendBytes(embed("image.png"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(ctx.Path == "/css/simple.min.css")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("text/css").SendBytes(embed("simple.min.css"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(ctx.Path == "/favicon.ico")
|
||||||
|
{
|
||||||
|
ctx.WithMimeType("image/x-icon").SendBytes(embed("favicon.ico"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},4206);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user