Add installation instructions for Docker & NixOS
Diff
.dockerignore | 2 ++-
.github/workflows/docker-publish.yml | 45 +++++++++++++++++++++++++++++++++++-
Dockerfile | 21 +++++++++++++++++-
README.md | 47 +++++++++++++++++++++++++++++++++++++-
4 files changed, 115 insertions(+)
@@ -0,0 +1,2 @@
target
Dockerfile
@@ -0,0 +1,45 @@
name: Docker
on:
schedule:
- cron: '45 20 * * *'
push:
branches: [ master ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
@@ -0,0 +1,21 @@
FROM rust:1.71-slim AS builder
RUN apt-get update && apt-get install -y libsodium-dev pkg-config
COPY . /sources
WORKDIR /sources
RUN cargo build --release
RUN chown nobody:nogroup /sources/target/release/pisshoff-server
FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y libsodium23 && rm -rf /var/lib/apt/lists/*
COPY --from=builder /sources/target/release/pisshoff-server /pisshoff-server
COPY --from=builder /sources/pisshoff-server/config.toml /config.toml
RUN touch audit.jsonl && chown nobody audit.jsonl
USER nobody
EXPOSE 2233
ENTRYPOINT ["/pisshoff-server", "-c", "/config.toml"]
@@ -185,8 +185,55 @@ $ cat audit.log | tail -n 2 | jq
## Running the server
### From source
An [example configuration][] is provided within the repository, running the server is as simple
as building the binary using [`cargo build --release`][] and calling `./pisshoff-server -c config.toml`.
[example configuration]: https://github.com/w4/pisshoff/blob/master/pisshoff-server/config.toml
[`cargo build --release`]: https://www.rust-lang.org/
### NixOS
Running pisshoff on NixOS is extremely simple, simply import the module into your flake.nix and use the provided service:
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
pisshoff = {
url = "github:w4/pisshoff";
inputs.nixpkgs = "nixpkgs";
};
};
outputs = { nixpkgs, ... }: {
nixosConfigurations.mySystem = nixpkgs.lib.nixosSystem {
modules = [
pisshoff.nixosModules.default
{
services.pisshoff = {
enable = true;
settings = {
listen-address = "127.0.0.1:2233";
access-probability = "0.2";
audit-output-file = "/var/log/pisshoff/audit.jsonl";
};
};
}
...
];
};
};
}
```
### Docker
Running pisshoff in Docker is also simple:
```bash
$ docker run -d --name pisshoff ghcr.io/w4/pisshoff:master
$ docker exec -it pisshoff tail -f audit.jsonl
```