Skip to content

Commit

Permalink
nix: minimize + compress resulting binary (#4)
Browse files Browse the repository at this point in the history
* nix: add package

* nix: add container image

* nix: minimize + compress resulting binary

---------

Co-authored-by: Lars Sjöström <lars@radicore.se>
  • Loading branch information
dln and lsjostro authored Oct 1, 2024
1 parent 6cbd91e commit cd4ff48
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
];
in
{
packages = {

packages = rec {
default = pkgs.buildGo123Module {
pname = "envoy-oidc-authserver";
version = "main";
src = ./.;

ldflags = [ "-s -w" ];
CGO_ENABLED = "0";

meta = {
desciption = "Envoy OIDC Authserver";
homepage = "https://github.com/shelmangroup/envoy-oidc-authserver";
Expand All @@ -61,13 +65,17 @@
prePatch = ''
HOME="$TMPDIR" ${pkgs.buf}/bin/buf generate
'';

postInstall = ''
${pkgs.upx}/bin/upx $out/bin/envoy-oidc-authserver
'';
};

container = pkgs.dockerTools.buildImage {
name = "envoy-oidc-authserver";
tag = "latest";
copyToRoot = [ self.packages.${system}.default ];
config.Entrypoint = [ (lib.getExe self.packages.${system}.default) ];
copyToRoot = [ default ];
config.Entrypoint = [ "${default}/bin/envoy-oidc-authserver" ];
};
};

Expand Down

0 comments on commit cd4ff48

Please sign in to comment.