forked from MIrrors/bin
Compare commits
15 Commits
dependabot
...
v2.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 186f6c217b | |||
| 0cd4560ee7 | |||
| 503b97a2ed | |||
| bcf1eab953 | |||
|
|
8d02b31688 | ||
|
|
dc6f9b5ec6 | ||
|
|
793c2476af | ||
| 89fe9a15a0 | |||
| ac93a7d379 | |||
| dc04017e67 | |||
| 322b131550 | |||
| 316cad44d8 | |||
| 8353c82b63 | |||
|
|
4fe099fd3e | ||
|
|
cc0591f813 |
35
.gitea/workflows/docker.yaml
Normal file
35
.gitea/workflows/docker.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Docker Image Creation
|
||||
run-name: ${{ gitea.actor }} building Docker image
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build-docker:
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Gitea Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.bluequartz.xyz
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: git.bluequartz.xyz/kellen/bin
|
||||
|
||||
- name: Build and Push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
result
|
||||
|
||||
21
.woodpecker.yml
Normal file
21
.woodpecker.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
# Pushes a Docker image without needing access to the Docker daemon
|
||||
#
|
||||
# Pushing an image to a container registry authenticated:
|
||||
# DOCKER_USERNAME - Woodpecker CI Secret which is the container registry username
|
||||
# DOCKER_PASSWORD - Woodpecker CI Secret which is container registry password
|
||||
#
|
||||
# Adjust branches to test things.
|
||||
#
|
||||
pipeline:
|
||||
publish-docker-image:
|
||||
image: plugins/kaniko
|
||||
settings:
|
||||
registry: core.harbor.0.tus.us.bluequartz.xyz
|
||||
repo: core.harbor.0.tus.us.bluequartz.xyz/k8s/bin
|
||||
tags: latest,v2.0.0-${CI_COMMIT_SHA:0:8}
|
||||
dockerfile: Dockerfile
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
branches: master
|
||||
35
Cargo.lock
generated
35
Cargo.lock
generated
@@ -404,7 +404,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
"shell-words",
|
||||
"syntect 4.6.0",
|
||||
"syntect",
|
||||
"thiserror",
|
||||
"unicode-width",
|
||||
"walkdir",
|
||||
@@ -431,7 +431,7 @@ dependencies = [
|
||||
"pretty_env_logger",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"syntect 5.0.0",
|
||||
"syntect",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@@ -510,9 +510,9 @@ checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.1.0"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
||||
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1428,9 +1428,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.13.1"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e"
|
||||
checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
|
||||
|
||||
[[package]]
|
||||
name = "onig"
|
||||
@@ -1887,29 +1887,6 @@ dependencies = [
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syntect"
|
||||
version = "5.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6c454c27d9d7d9a84c7803aaa3c50cd088d2906fe3c6e42da3209aa623576a8"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bitflags",
|
||||
"flate2",
|
||||
"fnv",
|
||||
"lazy_static",
|
||||
"once_cell",
|
||||
"onig",
|
||||
"plist",
|
||||
"regex-syntax",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"walkdir",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sys-info"
|
||||
version = "0.9.1"
|
||||
|
||||
@@ -12,9 +12,9 @@ argh = "0.1"
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.4"
|
||||
linked-hash-map = "0.5"
|
||||
once_cell = "1.13"
|
||||
once_cell = "1.14"
|
||||
parking_lot = "0.12"
|
||||
bytes = { version = "1.1", features = ["serde"] }
|
||||
bytes = { version = "1.2", features = ["serde"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
rand = { version = "0.8" }
|
||||
gpw = "0.1"
|
||||
@@ -23,7 +23,7 @@ actix-web = "4.0"
|
||||
htmlescape = "0.3"
|
||||
askama = "0.11"
|
||||
bat = "0.20"
|
||||
syntect = "5.0"
|
||||
syntect = "4.6"
|
||||
tokio = { version = "1.20", features = ["sync"] }
|
||||
futures = "0.3"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM rust:1-slim AS builder
|
||||
FROM rust:1-slim-bookworm AS builder
|
||||
|
||||
RUN apt update && apt install -y libclang-dev
|
||||
|
||||
@@ -7,8 +7,7 @@ WORKDIR /sources
|
||||
RUN cargo build --release
|
||||
RUN chown nobody:nogroup /sources/target/release/bin
|
||||
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
FROM gcr.io/distroless/cc-debian12
|
||||
COPY --from=builder /sources/target/release/bin /pastebin
|
||||
|
||||
USER nobody
|
||||
|
||||
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
version: '3'
|
||||
services:
|
||||
bin:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8000:8000"
|
||||
77
flake.lock
generated
Normal file
77
flake.lock
generated
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"nodes": {
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1662220400,
|
||||
"narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "naersk",
|
||||
"rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "master",
|
||||
"repo": "naersk",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1670118144,
|
||||
"narHash": "sha256-tdh9H4oomljZaKpCkZox8jmwt8p78oGLpK9cjFBy3Qk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "95f1ec721652d91a2993311d6cf537d3724690be",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1670118144,
|
||||
"narHash": "sha256-tdh9H4oomljZaKpCkZox8jmwt8p78oGLpK9cjFBy3Qk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "95f1ec721652d91a2993311d6cf537d3724690be",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
83
flake.nix
Normal file
83
flake.nix
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
inputs = {
|
||||
naersk.url = "github:nix-community/naersk/master";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, naersk }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
naersk-lib = pkgs.callPackage naersk { };
|
||||
in
|
||||
{
|
||||
defaultPackage = naersk-lib.buildPackage ./.;
|
||||
devShell = with pkgs; mkShell {
|
||||
buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ];
|
||||
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
||||
};
|
||||
|
||||
nixosModules.default = { config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.paste-bin;
|
||||
in
|
||||
{
|
||||
options.services.paste-bin = {
|
||||
enable = mkEnableOption "paste-bin";
|
||||
bindAddress = mkOption {
|
||||
default = "[::]:8000";
|
||||
description = "Address and port to listen on";
|
||||
type = types.str;
|
||||
};
|
||||
maxPasteSize = mkOption {
|
||||
default = 32768;
|
||||
description = "Max allowed size of an individual paste";
|
||||
type = types.int;
|
||||
};
|
||||
bufferSize = mkOption {
|
||||
default = 1000;
|
||||
description = "Maximum amount of pastes to store at a time";
|
||||
type = types.int;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.bin = {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
serviceConfig = {
|
||||
Type = "exec";
|
||||
ExecStart = "${self.defaultPackage."${system}"}/bin/bin --buffer-size ${toString cfg.bufferSize} --max-paste-size ${toString cfg.maxPasteSize} ${cfg.bindAddress}";
|
||||
Restart = "on-failure";
|
||||
|
||||
CapabilityBoundingSet = "";
|
||||
NoNewPrivileges = true;
|
||||
PrivateDevices = true;
|
||||
PrivateTmp = true;
|
||||
PrivateUsers = true;
|
||||
PrivateMounts = true;
|
||||
ProtectHome = true;
|
||||
ProtectClock = true;
|
||||
ProtectProc = "noaccess";
|
||||
ProcSubset = "pid";
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHostname = true;
|
||||
RestrictSUIDSGID = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictNamespaces = true;
|
||||
LockPersonality = true;
|
||||
RemoveIPC = true;
|
||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user