now with online downloads and docs.

This commit is contained in:
Erik Brakkee 2024-07-21 15:33:31 +02:00
parent dedbc39144
commit 91cc99fdfe
9 changed files with 165 additions and 0 deletions

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM alpine:3.20.0 as builder
RUN apk update && apk add go
RUN mkdir -p /opt/converge/bin
COPY . /opt/converge/
WORKDIR /opt/converge
RUN go mod download
COPY . /opt/converge/
#RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main .
RUN go build -ldflags "-linkmode 'external' -extldflags '-static'" -o bin ./cmd/...
#RUN mkdir -p /opt/converge/downloads/
FROM scratch
COPY --from=builder /opt/converge/bin/converge /opt/converge/bin/
COPY --from=builder /opt/converge/bin/agent /opt/converge/bin/tcptows /opt/converge/downloads/
COPY --from=builder /opt/converge/static/ /opt/converge/downloads/
ENTRYPOINT ["/opt/converge/bin/converge", "/opt/converge/downloads" ]

27
cmd/agent/hostkey.pem Normal file
View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEApoRgwjZ46YumMcUAj9XMqVffRPgYx1C76jEtY7mJpEEujJfh
JoJOhJWlSJdZDTmkt7HUY3KMUgidipWlfmuLm7quu8/3EbGuv5GE/g5SvvSpYLdN
xiz8YvqwLRSm/Aa0mPqOz+/2vHo0PfKWuOaXaHrbpZFHyu9ZnRMdjlY67jO8lXF9
h7Vlg/VVb6uLa6PYUDMAYb5jk3ugIBKi3zEq1o1C6rKwzz6iVdsnuWwJuso5pMQu
T07Z7nNUC4bL2JoLfA/avta6OiMzoU6Wr+oZvatXyvrW2Tqxm0ll6GRB4TEvP8SU
8UXB4gSLrKt98YMFXMluMYHu8K1Gv1qJph1OiQIDAQABAoIBAHg9xxD2/MDIUq5F
r24t2KfACD1pWZsztT4bXMdSRw4Q82galD6WgdRDqyKMB4YBRexPwSo+oQzro7da
8DIlvp4pY9vDBIoGYEV88yfxd9bkHRr1wneELIvcsjMbY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KTsY9O0RqB7KVAg6c0qKzVeKa7EBIWzfnJK/mbRojL9o=
-----END RSA PRIVATE KEY-----

View File

@ -26,6 +26,7 @@ func main() {
if len(os.Args) == 2 { if len(os.Args) == 2 {
downloadDir = os.Args[1] downloadDir = os.Args[1]
} }
log.Println("Doanload directory", downloadDir)
admin := converge.NewAdmin() admin := converge.NewAdmin()
registrationService := websocketutil.WebSocketService{ registrationService := websocketutil.WebSocketService{

9
compose.yaml Normal file
View File

@ -0,0 +1,9 @@
services:
converge:
image: your.repo.com/converge:1.0
build:
context: .
ports:
- 8000:8000

6
static/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

94
static/index.html Normal file
View File

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/bootstrap.min.css"
crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Converge</title>
</head>
<body>
<script src="js/bootstrap.bundle.min.js"
crossorigin="anonymous"></script>
<div class="container">
<h1>Usage</h1>
<h2>Continous integration jobs</h2>
<p>
In a continous integration job, download the agent, chmod it and run it.
</p>
<pre>
# for HTTP hosted server
curl http://HOSTPORT/downloads/agent > agent
./agent ws://HOST:PORT/agent/ID
chmod 755 agent
# for HTTPS hosted server
curl https://HOSTPORT/downloads/agent > agent
./agent wss://HOST:PORT/agent/ID
chmod 755 agent
</pre>
<p>
Above, HOST:PORT is the hostname:port of the converge server and ID is a unique id
for the job. This should not conflict with other ids.
This connects the agent to the converge server. Clients can now connect to converge
to establish a connection to the CI job through converge.
</p>
<h2>Local clients</h2>
<p>
Local clients can connect using regular ssh and sftp commands through a tunnel that
translates a local TCP port to a websocket connection in converge.
First step is to download the tcptows program (see below):
</p>
<pre>
# for HTTP hosted server
curl http://HOST:PORT/downloads/wstotcp > wstotcp
chmod 755 wstotcp
./wstotcp 10000 ws://HOST:PORT/client/ID
# for HTTPS hosted server
curl https://HOST:PORT/downloads/wstotcp > wstotcp
chmod 755 wstotcp
./wstotcp 10000 wss://HOST:PORT/client/ID
</pre>
<p>
This runs a local client that allows SSH to port 10000 and connects to converge using
a websocket connection.</p>
<p>
Next step is to run a local SSH of SFTP client:
</p>
<pre>
ssh -p 10000 abc@localhost
sftp -oPort 10000 abc@localhost
</pre>
<p>
<code>abc</code> is a fixed user defined by converge. It has a very exciting password.
</p>
<h1>Downloads</h1>
<ul>
<li><a href="/downloads/agent">agent</a>: The agent to run inside aa CI job
</li>
<li><a href="/downloads/tcptows">tcptows</a>: TCP to WS tunnel for allowing regular
SSH and SFTP clients to connect to converge.
</li>
</ul>
</div>
</body>
</html>

7
static/js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long