Skip to content

Commit

Permalink
Add installation instructions for Docker & NixOS
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Aug 14, 2023
1 parent 250f055 commit 62439b2
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
Dockerfile
45 changes: 45 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Docker

on:
schedule:
- cron: '45 20 * * *'
push:
branches: [ master ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
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 }}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 62439b2

Please sign in to comment.