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 |     README | ||||||
|     ChangeLog.md |     ChangeLog.md | ||||||
|  |  | ||||||
| library | executable Purr | ||||||
|   exposed-modules: |   main-is: Main.hs | ||||||
|       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 |  | ||||||
|   hs-source-dirs: |   hs-source-dirs: | ||||||
|       src |       app | ||||||
|  |       , src | ||||||
|   default-extensions: |   default-extensions: | ||||||
|       ConstraintKinds |       ConstraintKinds | ||||||
|       DeriveGeneric |       DeriveGeneric | ||||||
| @ -41,6 +26,7 @@ library | |||||||
|       GeneralizedNewtypeDeriving |       GeneralizedNewtypeDeriving | ||||||
|       OverloadedStrings |       OverloadedStrings | ||||||
|       ScopedTypeVariables |       ScopedTypeVariables | ||||||
|  |   ghc-options: -threaded -rtsopts -with-rtsopts=-N -optl-pthread -fPIC | ||||||
|   build-depends: |   build-depends: | ||||||
|     base >=4.7 |     base >=4.7 | ||||||
|     , base64-bytestring >=1.2.0.0 |     , base64-bytestring >=1.2.0.0 | ||||||
| @ -63,44 +49,19 @@ library | |||||||
|     , utf8-string ==1.0.2 |     , utf8-string ==1.0.2 | ||||||
|     , wai-extra >=3.1.12.1 |     , wai-extra >=3.1.12.1 | ||||||
|     , wai-middleware-static >=0.5 |     , wai-middleware-static >=0.5 | ||||||
|   default-language: Haskell2010 |  | ||||||
|  |  | ||||||
| executable Purr |  | ||||||
|   main-is: Main.hs |  | ||||||
|   other-modules: |   other-modules: | ||||||
|       Paths_Purr |     Core.Configuration | ||||||
|   hs-source-dirs: |     Core.HTTP | ||||||
|       app |     Core.SQLite | ||||||
|   default-extensions: |     Core.Templates | ||||||
|       ConstraintKinds |     Core.Types | ||||||
|       DeriveGeneric |     Feature.Generation.HTTP | ||||||
|       FlexibleContexts |     Feature.Generation.Links | ||||||
|       FlexibleInstances |     Feature.Generation.Passwords | ||||||
|       GeneralizedNewtypeDeriving |     Feature.Generation.Shared | ||||||
|       OverloadedStrings |     Feature.Generation.Templates | ||||||
|       ScopedTypeVariables |     Feature.Sharing.HTTP | ||||||
|   ghc-options: -threaded -rtsopts -with-rtsopts=-N -optl-pthread -fPIC |     Feature.Sharing.SQLite | ||||||
|   build-depends: |     Feature.Sharing.Templates | ||||||
|       Purr |     Lib | ||||||
|     , 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 |  | ||||||
|   default-language: Haskell2010 |   default-language: Haskell2010 | ||||||
|  | |||||||
							
								
								
									
										52
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										52
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							| @ -18,7 +18,56 @@ | |||||||
|         "type": "github" |         "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": { |     "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": { |       "locked": { | ||||||
|         "lastModified": 1683159243, |         "lastModified": 1683159243, | ||||||
|         "narHash": "sha256-Fh41KQcZTswb4NyYfSsbNEhDS/Im0/Id6m3k7qZ6/Xw=", |         "narHash": "sha256-Fh41KQcZTswb4NyYfSsbNEhDS/Im0/Id6m3k7qZ6/Xw=", | ||||||
| @ -36,7 +85,8 @@ | |||||||
|     "root": { |     "root": { | ||||||
|       "inputs": { |       "inputs": { | ||||||
|         "flake-utils": "flake-utils", |         "flake-utils": "flake-utils", | ||||||
|         "nixpkgs": "nixpkgs" |         "nix2container": "nix2container", | ||||||
|  |         "nixpkgs": "nixpkgs_2" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "systems": { |     "systems": { | ||||||
|  | |||||||
							
								
								
									
										19
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								flake.nix
									
									
									
									
									
								
							| @ -4,22 +4,29 @@ | |||||||
|   inputs = { |   inputs = { | ||||||
|     nixpkgs.url = "github:NixOS/nixpkgs"; |     nixpkgs.url = "github:NixOS/nixpkgs"; | ||||||
|     flake-utils.url = "github:numtide/flake-utils"; |     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: |     flake-utils.lib.eachDefaultSystem (system: | ||||||
|       let |       let | ||||||
|         pkgs              = nixpkgs.legacyPackages.${system}; |         pkgs              = nixpkgs.legacyPackages.${system}; | ||||||
|         packageName       = "purr"; |         packageName       = "purr"; | ||||||
|         dockerPackageName = "${packageName}-docker"; |         dockerPackageName = "${packageName}-docker"; | ||||||
|  |  | ||||||
|  |         nix2containerPkgs = nix2container.packages.x86_64-linux; | ||||||
|  |  | ||||||
|         haskellPackages = pkgs.haskellPackages; |         haskellPackages = pkgs.haskellPackages; | ||||||
|  |  | ||||||
|         enableSharedExecutables = false; |         enableSharedExecutables = false; | ||||||
|  |         enableSharedLibraries = false; | ||||||
|  |  | ||||||
|  |         purr = pkgs.haskell.lib.justStaticExecutables self.packages.${system}.default; | ||||||
|  |  | ||||||
|       in { |       in { | ||||||
|  |  | ||||||
|         packages.${packageName} = |         packages.${packageName} = | ||||||
|           haskellPackages.callCabal2nix packageName self rec { |           haskellPackages.callCabal2nix packageName self rec {}; | ||||||
|           }; |  | ||||||
|  |  | ||||||
|         packages.default = self.packages.${system}.${packageName}; |         packages.default = self.packages.${system}.${packageName}; | ||||||
|         defaultPackage = self.packages.${system}.default; |         defaultPackage = self.packages.${system}.default; | ||||||
| @ -33,17 +40,19 @@ | |||||||
|         }; |         }; | ||||||
|  |  | ||||||
|         devShell = self.devShells.${system}.default; |         devShell = self.devShells.${system}.default; | ||||||
|  |  | ||||||
|         packages.${dockerPackageName} = pkgs.dockerTools.buildImage { |         packages.${dockerPackageName} = pkgs.dockerTools.buildImage { | ||||||
|           name = "purr"; |           name = "purr"; | ||||||
|  |  | ||||||
|           copyToRoot = pkgs.buildEnv { |           copyToRoot = pkgs.buildEnv { | ||||||
|             name = "image-root"; |             name = "image-root"; | ||||||
|             paths = [ self.packages.${system}.default ]; |             paths = [ purr ]; | ||||||
|             pathsToLink = [ "/bin" ]; |             pathsToLink = [ "/bin" ]; | ||||||
|           }; |           }; | ||||||
|           tag = "latest"; |           tag = "latest"; | ||||||
|           config = { |           config = { | ||||||
|             Cmd = [ |             Cmd = [ | ||||||
|               "/bin/Purr-musl" |               "/bin/Purr" | ||||||
|             ]; |             ]; | ||||||
|             ExposedPorts = { |             ExposedPorts = { | ||||||
|               "3000/tcp" = {}; |               "3000/tcp" = {}; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user