Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Push Docker Image

on:
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- uses: nixbuild/nix-quick-install-action@v28
with:
nix_conf: experimental-features = nix-command flakes

# Log in to GHCR
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Create a docker image
- run: nix run .#packages.x86_64-linux.container.copyToDockerDaemon
- run: docker tag perfly:latest ghcr.io/artificialio/perfly:${{ github.event.release.tag_name }}

# Build and push the image
- name: Build and Push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/artificialio/perfly:latest
ghcr.io/artificialio/perfly:${{ github.event.release.tag_name }}
36 changes: 35 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
hell.url = "github:chrisdone/hell?ref=551133cecdafed1d6d3f4da7d8a466df2eed8af5";

nix2container.url = "github:nlewo/nix2container";
};
outputs = inputs@{ self, nixpkgs, flake-parts, hell, ... }:

outputs = inputs@{ self, nixpkgs, flake-parts, hell, nix2container, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
Expand Down Expand Up @@ -52,6 +53,25 @@

# Hook up tests so `nix flake check` runs them
checks.default = self'.packages.perfly;

packages.container = nix2container.packages.${system}.nix2container.buildImage {
name = "perfly";
tag = "latest";
config = {
Cmd = [ "/perfly" ];
WorkingDir = "/";
};
# Extract ONLY the binary, nothing else
copyToRoot = pkgs.runCommand "perfly-only" {} ''
mkdir -p $out
# Copy just the binary, not the entire package closure
cp ${self'.packages.perfly}/bin/perfly $out/perfly
# Strip debug symbols
${pkgs.binutils}/bin/strip $out/perfly 2>/dev/null || true
# Make executable
chmod +x $out/perfly
'';
};
};
};
}