Stop using a Cabal library to achieve reasonable Docker image sizes
This commit is contained in:
		
							
								
								
									
										77
									
								
								Purr.cabal
									
									
									
									
									
								
							
							
						
						
									
										77
									
								
								Purr.cabal
									
									
									
									
									
								
							| @ -13,26 +13,11 @@ extra-source-files: | ||||
|     README | ||||
|     ChangeLog.md | ||||
|  | ||||
| library | ||||
|   exposed-modules: | ||||
|       Core.Configuration | ||||
|       Core.HTTP | ||||
|       Core.SQLite | ||||
|       Core.Templates | ||||
|       Core.Types | ||||
|       Feature.Generation.HTTP | ||||
|       Feature.Generation.Links | ||||
|       Feature.Generation.Passwords | ||||
|       Feature.Generation.Shared | ||||
|       Feature.Generation.Templates | ||||
|       Feature.Sharing.HTTP | ||||
|       Feature.Sharing.SQLite | ||||
|       Feature.Sharing.Templates | ||||
|       Lib | ||||
|   other-modules: | ||||
|       Paths_Purr | ||||
| executable Purr | ||||
|   main-is: Main.hs | ||||
|   hs-source-dirs: | ||||
|       src | ||||
|       app | ||||
|       , src | ||||
|   default-extensions: | ||||
|       ConstraintKinds | ||||
|       DeriveGeneric | ||||
| @ -41,6 +26,7 @@ library | ||||
|       GeneralizedNewtypeDeriving | ||||
|       OverloadedStrings | ||||
|       ScopedTypeVariables | ||||
|   ghc-options: -threaded -rtsopts -with-rtsopts=-N -optl-pthread -fPIC | ||||
|   build-depends: | ||||
|     base >=4.7 | ||||
|     , base64-bytestring >=1.2.0.0 | ||||
| @ -63,44 +49,19 @@ library | ||||
|     , utf8-string ==1.0.2 | ||||
|     , wai-extra >=3.1.12.1 | ||||
|     , wai-middleware-static >=0.5 | ||||
|   default-language: Haskell2010 | ||||
|  | ||||
| executable Purr | ||||
|   main-is: Main.hs | ||||
|   other-modules: | ||||
|       Paths_Purr | ||||
|   hs-source-dirs: | ||||
|       app | ||||
|   default-extensions: | ||||
|       ConstraintKinds | ||||
|       DeriveGeneric | ||||
|       FlexibleContexts | ||||
|       FlexibleInstances | ||||
|       GeneralizedNewtypeDeriving | ||||
|       OverloadedStrings | ||||
|       ScopedTypeVariables | ||||
|   ghc-options: -threaded -rtsopts -with-rtsopts=-N -optl-pthread -fPIC | ||||
|   build-depends: | ||||
|       Purr | ||||
|     , base >=4.7 | ||||
|     , base64-bytestring >=1.2.0.0 | ||||
|     , blaze-html >=0.9.1.0 | ||||
|     , bytestring >=0.10.12.1 | ||||
|     , containers >=0.6.4.1 | ||||
|     , dhall >=1.40 | ||||
|     , file-embed ==0.0.15.0 | ||||
|     , http-types >=0.12.3 | ||||
|     , iso8601-time >=0.1.5 | ||||
|     , mtl >=2.2.2 | ||||
|     , random >=1.2 | ||||
|     , saltine >=0.2.0.0 | ||||
|     , scotty >=0.12 | ||||
|     , shakespeare >=2.0.20 | ||||
|     , split >=0.2.3.4 | ||||
|     , sqlite-simple >=0.4.18.0 | ||||
|     , text >=1.2.5.0 | ||||
|     , time >=1.9 | ||||
|     , utf8-string ==1.0.2 | ||||
|     , wai-extra >=3.1.12.1 | ||||
|     , wai-middleware-static >=0.5 | ||||
|     Core.Configuration | ||||
|     Core.HTTP | ||||
|     Core.SQLite | ||||
|     Core.Templates | ||||
|     Core.Types | ||||
|     Feature.Generation.HTTP | ||||
|     Feature.Generation.Links | ||||
|     Feature.Generation.Passwords | ||||
|     Feature.Generation.Shared | ||||
|     Feature.Generation.Templates | ||||
|     Feature.Sharing.HTTP | ||||
|     Feature.Sharing.SQLite | ||||
|     Feature.Sharing.Templates | ||||
|     Lib | ||||
|   default-language: Haskell2010 | ||||
|  | ||||
							
								
								
									
										52
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										52
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							| @ -18,7 +18,56 @@ | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-utils_2": { | ||||
|       "locked": { | ||||
|         "lastModified": 1653893745, | ||||
|         "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nix2container": { | ||||
|       "inputs": { | ||||
|         "flake-utils": "flake-utils_2", | ||||
|         "nixpkgs": "nixpkgs" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1677791117, | ||||
|         "narHash": "sha256-zL4Fc5133KMqX7zCzcPODaBPEblUfgQt2UccNBm34Pc=", | ||||
|         "owner": "nlewo", | ||||
|         "repo": "nix2container", | ||||
|         "rev": "85670cab354f7df69dd4af097c27cf9bc5826cb2", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "nlewo", | ||||
|         "repo": "nix2container", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs": { | ||||
|       "locked": { | ||||
|         "lastModified": 1677612629, | ||||
|         "narHash": "sha256-yC+9LfhfwOd5sXFW8TLnDmqVMNYiHXYPGy9BbdpRqfU=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "111ca8e0378e88d9decaa1c6dd7597f35d8bc67f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs_2": { | ||||
|       "locked": { | ||||
|         "lastModified": 1683159243, | ||||
|         "narHash": "sha256-Fh41KQcZTswb4NyYfSsbNEhDS/Im0/Id6m3k7qZ6/Xw=", | ||||
| @ -36,7 +85,8 @@ | ||||
|     "root": { | ||||
|       "inputs": { | ||||
|         "flake-utils": "flake-utils", | ||||
|         "nixpkgs": "nixpkgs" | ||||
|         "nix2container": "nix2container", | ||||
|         "nixpkgs": "nixpkgs_2" | ||||
|       } | ||||
|     }, | ||||
|     "systems": { | ||||
|  | ||||
							
								
								
									
										19
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								flake.nix
									
									
									
									
									
								
							| @ -4,22 +4,29 @@ | ||||
|   inputs = { | ||||
|     nixpkgs.url = "github:NixOS/nixpkgs"; | ||||
|     flake-utils.url = "github:numtide/flake-utils"; | ||||
|     nix2container.url = "github:nlewo/nix2container"; | ||||
|   }; | ||||
|  | ||||
|   outputs = { self, nixpkgs, flake-utils }: | ||||
|   outputs = { self, nixpkgs, flake-utils, nix2container }: | ||||
|     flake-utils.lib.eachDefaultSystem (system: | ||||
|       let | ||||
|         pkgs              = nixpkgs.legacyPackages.${system}; | ||||
|         packageName       = "purr"; | ||||
|         dockerPackageName = "${packageName}-docker"; | ||||
|  | ||||
|         nix2containerPkgs = nix2container.packages.x86_64-linux; | ||||
|  | ||||
|         haskellPackages = pkgs.haskellPackages; | ||||
|  | ||||
|         enableSharedExecutables = false; | ||||
|         enableSharedLibraries = false; | ||||
|  | ||||
|         purr = pkgs.haskell.lib.justStaticExecutables self.packages.${system}.default; | ||||
|  | ||||
|       in { | ||||
|  | ||||
|         packages.${packageName} = | ||||
|           haskellPackages.callCabal2nix packageName self rec { | ||||
|           }; | ||||
|           haskellPackages.callCabal2nix packageName self rec {}; | ||||
|  | ||||
|         packages.default = self.packages.${system}.${packageName}; | ||||
|         defaultPackage = self.packages.${system}.default; | ||||
| @ -33,17 +40,19 @@ | ||||
|         }; | ||||
|  | ||||
|         devShell = self.devShells.${system}.default; | ||||
|  | ||||
|         packages.${dockerPackageName} = pkgs.dockerTools.buildImage { | ||||
|           name = "purr"; | ||||
|  | ||||
|           copyToRoot = pkgs.buildEnv { | ||||
|             name = "image-root"; | ||||
|             paths = [ self.packages.${system}.default ]; | ||||
|             paths = [ purr ]; | ||||
|             pathsToLink = [ "/bin" ]; | ||||
|           }; | ||||
|           tag = "latest"; | ||||
|           config = { | ||||
|             Cmd = [ | ||||
|               "/bin/Purr-musl" | ||||
|               "/bin/Purr" | ||||
|             ]; | ||||
|             ExposedPorts = { | ||||
|               "3000/tcp" = {}; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user