-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
559 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ iso | |
images | ||
src | ||
tools | ||
docs | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
FROM alpine | ||
USER root | ||
WORKDIR /app | ||
RUN apk add git | ||
RUN apk add wget tar unzip | ||
RUN apk add mercurial | ||
RUN apk add openssh-client | ||
VOLUME /data | ||
VOLUME /images | ||
COPY ./docs/etc/id_rsa /root/.ssh/id_rsa | ||
COPY ./docs/etc/id_rsa.pub /root/.ssh/id_rsa.pub | ||
COPY ./bin/aquila-linux-x86_64 /app/aquila | ||
ENTRYPOINT ["/app/aquila", "--port", "8000", "--db", "/data/access.db"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-----BEGIN OPENSSH PRIVATE KEY----- | ||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn | ||
NhAAAAAwEAAQAAAgEAuILWxMAYcPR+ValpIFtxftpaeYjFmIxLvlpG7KMbZpxf1i2QTl7A | ||
mS8O6e0vHM1KwyY/36dAJQhJdam1oGUyJXcG1aoutgkfuolf8SqMEpCXIgeeLJcC9I92Ow | ||
lkXZwdL4nfF6NjGC7hXUBFltg3UbCmOyWst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QsHgQoFfVqEMVaAkNinap1rdypCxizvUYE/LOGp | ||
NNR1w9ivjpIIopzlJQhAkPCe7HqSw9Vwzz1xCiK20CRWlPGyWrT/mIGypSzzF4NZ/xFi1i | ||
X6jDaRdOluGnDgPjig37BOfmazvuuIoHXcWq44ilUUI+SK/cRGA7owFN2HlcybZA95cSTR | ||
RUgAei2k2T2uWArCTe2J9TXDOMagFaLMtstxz1H6jJkQ5I8xUCUwuDY1inx90yRaWz6iOf | ||
TrvAabmIKCcY7vsyAAABAQDffm6K+hAJRo/3Xi7cugEmxMP24YczDrK723Qoyg91WXEFhG | ||
oPjG+/cAiaM268OUXmVMwqYDOISyHGpNm+Behqa5WgDYNRJFQ8jBVi6bVGDEaD+7wuyQxn | ||
bvjo3NAPRFBZxyXyK/tDDM182x+ydEaiSBajy3a4gPwkGSi8t06seZslf6P4NLZsH/4dRX | ||
lx2dvY15NuPFlVF9wbd9MI2NDNrXQD9iAx5tc+VE/oQBh++avJY7lpN76lH5JDuJdsG4Cf | ||
c7Q+oKm3/NhyZi1tLpzYKBjrDTcZh8K7HlSp4U4YllukY+N/lGx/Noe/9ivaIS95k0qdjV | ||
2li5JhdXzerFizAAABAQDTWOwvtRdvYd38gGmhj7yDICZWRwKC/GT7izjF172zRY3h16FM | ||
+zA/cu3UMNQShMRSyUP2FV68CR5ZTN1CgHHri7SSmdqm0hus9mxF/OQfzeZZw9hngu5Mc4 | ||
zUNneUskAPLTJd0YQiyfM0DKRkopiKndVj9MpiQzmBPXsLgHAeRmlKEmPNfsTEPn8hCKtT | ||
87BrBgjGFt2/DITQypLoy/YcMkD4m/BjZzWD64/HZ9gUoQdORLu7I+IuvvidTPJC42zlYm | ||
g8gKu2FMMyt/NfiXRqVj2N8X0j2HDvzRtaev/u6VLb+KLY0cRW39EIndLYAZk+Ng9PfXwX | ||
3y6swg1ako1VAAAACW1lZ0BuaXhvcwE= | ||
-----END OPENSSH PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4gtbEwBhw9H5VqWkgW3F+2lp5iMWYjEu+WkbsoxtmnF/WLZBOXsCZLw7p7S8czUrDJj/fp0AlCEl1qbWgZTIldwbVqi62CR+6iV/xKowSkJciB54slwL0j3Y7CWRdnB0vid8Xo2MYLuFdQEWW2DdRsKY7Jay02EEl4yaZP72DjnjfDHf9ilSJ6gUwQR7FbYoz0n7IB1ZvtFeBDegSeKH11Aeh6a34Hv2zWhqnT1ccDFkbHz6K7AMNjND1X0CggykbQnBHXAtICFJRpwhK+ODdUG/xpNSmExLvdkxKQtpwXCbKYnRahkcMeXhOKYq9jMp9WPOkIsoMo5vrihDzocm5VVoESK0BBS+PMmnN75D5bHQi9fHsirBfOwkmyM3H7zXpu76gEMolUYorkl9EyYazB6Sh4bBB5vtyBJQA9jcZaYxAbARWRWSzQYti42Y6vKWsJPtAUy2Nnd/crdx2RfDUDBQ6G/2hZ4J1tjq9nVJNG3wWAK07cz/JlQMeVsRZ3bXVA8Qbc3qTUPf9DwL/dojcPV8kXEMuCO8vRe2tq/0W4qguwN7oBmEA7TcZP1LZyKZ0c3zzvoBXDjxNQve8WIEug7T/MXRNtQQdaJolmyWh0/Y61asbErU49O2I8X3eu7JEAjAXZM5FeQLA4h7I8IF06KSRMnsHGpjbzYWrYCoKbw== aquila insecure public key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
The key fingerprint is: | ||
SHA256:qd4LldwWuSZvsv2efgLa5ViyPUa3wm3NGXe36hlhk6A aquila insecure public key | ||
|
||
The key's randomart image is: | ||
+---[RSA 4096]----+ | ||
| | | ||
| . | | ||
| o. | | ||
| . +.o. . | | ||
| SE= = | | ||
| o =o = +.+| | ||
| o .oo% + +B| | ||
| . o.=+ O.Boo| | ||
| . +..=*X. | | ||
+----[SHA256]-----+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// brought over from https://github.com/ziglang/zig/blob/c9006d9/src/WaitGroup.zig | ||
|
||
const std = @import("std"); | ||
const Atomic = std.atomic.Atomic; | ||
const assert = std.debug.assert; | ||
const WaitGroup = @This(); | ||
|
||
const is_waiting: usize = 1 << 0; | ||
const one_pending: usize = 1 << 1; | ||
|
||
state: Atomic(usize) = Atomic(usize).init(0), | ||
event: std.Thread.ResetEvent = .{}, | ||
|
||
pub fn start(self: *WaitGroup) void { | ||
const state = self.state.fetchAdd(one_pending, .Monotonic); | ||
assert((state / one_pending) < (std.math.maxInt(usize) / one_pending)); | ||
} | ||
|
||
pub fn finish(self: *WaitGroup) void { | ||
const state = self.state.fetchSub(one_pending, .Release); | ||
assert((state / one_pending) > 0); | ||
|
||
if (state == (one_pending | is_waiting)) { | ||
self.state.fence(.Acquire); | ||
self.event.set(); | ||
} | ||
} | ||
|
||
pub fn wait(self: *WaitGroup) void { | ||
var state = self.state.fetchAdd(is_waiting, .Acquire); | ||
assert(state & is_waiting == 0); | ||
|
||
if ((state / one_pending) > 0) { | ||
self.event.wait(); | ||
} | ||
} | ||
|
||
pub fn reset(self: *WaitGroup) void { | ||
self.state.store(0, .Monotonic); | ||
self.event.reset(); | ||
} | ||
|
||
pub fn isDone(wg: *WaitGroup) bool { | ||
const state = wg.state.load(.Acquire); | ||
assert(state & is_waiting == 0); | ||
|
||
return (state / one_pending) == 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! https://docs.docker.com/engine/api/v1.41/ | ||
|
||
const std = @import("std"); | ||
const string = []const u8; | ||
const UrlValues = @import("UrlValues"); | ||
const zfetch = @import("zfetch"); | ||
|
||
const max_len = 1024 * 1024 * 5; | ||
|
||
/// https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerCreate | ||
pub fn containerCreate(alloc: std.mem.Allocator, payload: anytype) !std.json.ValueTree { | ||
const url = "http://localhost/v1.41/containers/create"; | ||
var docker_conn = try zfetch.Connection.connect(alloc, .{ .protocol = .unix, .hostname = "/var/run/docker.sock" }); | ||
defer docker_conn.close(); | ||
var req = try zfetch.Request.fromConnection(alloc, docker_conn, url); | ||
var headers = zfetch.Headers.init(alloc); | ||
try headers.appendValue("Content-Type", "application/json"); | ||
try req.do(.POST, headers, try std.json.stringifyAlloc(alloc, payload, .{})); | ||
const r = req.reader(); | ||
const body_content = try r.readAllAlloc(alloc, max_len); | ||
std.log.debug("{d}: {s}", .{ req.status.code, url }); | ||
if (req.status.code != 201) std.log.debug("{s}", .{body_content}); | ||
return try std.json.Parser.init(alloc, false).parse(body_content); | ||
} | ||
|
||
/// https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerStart | ||
pub fn containerStart(alloc: std.mem.Allocator, id: string) !void { | ||
const url = try std.fmt.allocPrint(alloc, "http://localhost/v1.41/containers/{s}/start", .{id}); | ||
var docker_conn = try zfetch.Connection.connect(alloc, .{ .protocol = .unix, .hostname = "/var/run/docker.sock" }); | ||
defer docker_conn.close(); | ||
var req = try zfetch.Request.fromConnection(alloc, docker_conn, url); | ||
var headers = zfetch.Headers.init(alloc); | ||
try headers.appendValue("Content-Type", "application/json"); | ||
try req.do(.POST, headers, "{}"); | ||
std.log.debug("{d}: {s}", .{ req.status.code, url }); | ||
} | ||
|
||
/// https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerInspect | ||
pub fn containerInspect(alloc: std.mem.Allocator, id: string) !std.json.ValueTree { | ||
const url = try std.fmt.allocPrint(alloc, "http://localhost/v1.41/containers/{s}/json", .{id}); | ||
var docker_conn = try zfetch.Connection.connect(alloc, .{ .protocol = .unix, .hostname = "/var/run/docker.sock" }); | ||
defer docker_conn.close(); | ||
var req = try zfetch.Request.fromConnection(alloc, docker_conn, url); | ||
try req.do(.GET, null, null); | ||
const r = req.reader(); | ||
const body_content = try r.readAllAlloc(alloc, max_len); | ||
std.log.debug("{d}: {s}", .{ req.status.code, url }); | ||
return try std.json.Parser.init(alloc, false).parse(body_content); | ||
} | ||
|
||
/// https://docs.docker.com/engine/api/v1.41/#tag/Network/operation/NetworkConnect | ||
pub fn networkConnect(alloc: std.mem.Allocator, network_id: string, container_id: string) !void { | ||
const url = try std.fmt.allocPrint(alloc, "http://localhost/v1.41/networks/{s}/connect", .{network_id}); | ||
var docker_conn = try zfetch.Connection.connect(alloc, .{ .protocol = .unix, .hostname = "/var/run/docker.sock" }); | ||
defer docker_conn.close(); | ||
var req = try zfetch.Request.fromConnection(alloc, docker_conn, url); | ||
var headers = zfetch.Headers.init(alloc); | ||
try headers.appendValue("Content-Type", "application/json"); | ||
try req.do(.POST, headers, try std.json.stringifyAlloc(alloc, .{ .Container = container_id }, .{})); | ||
const r = req.reader(); | ||
const body_content = try r.readAllAlloc(alloc, max_len); | ||
std.log.debug("{d}: {s}", .{ req.status.code, url }); | ||
std.log.debug("{s}", .{body_content}); | ||
} | ||
|
||
/// https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerDelete | ||
pub fn containerDelete(alloc: std.mem.Allocator, id: string) !void { | ||
const url = try std.fmt.allocPrint(alloc, "http://localhost/v1.41/containers/{s}", .{id}); | ||
var docker_conn = try zfetch.Connection.connect(alloc, .{ .protocol = .unix, .hostname = "/var/run/docker.sock" }); | ||
defer docker_conn.close(); | ||
var req = try zfetch.Request.fromConnection(alloc, docker_conn, url); | ||
try req.do(.DELETE, null, null); | ||
std.log.debug("{d}: {s}", .{ req.status.code, url }); | ||
} |
Oops, something went wrong.