diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8b7b85f --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1747179050, + "narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..79e1e72 --- /dev/null +++ b/flake.nix @@ -0,0 +1,60 @@ +{ + description = "ConvertX"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; }; + appSrc = ./.; + + app = pkgs.dockerTools.buildLayeredImage { + name = "convertx"; + tag = "latest"; + + contents = [ + pkgs.bun + pkgs.resvg + pkgs.ffmpeg + pkgs.graphicsmagick + pkgs.ghostscript + pkgs.vips + pkgs.pandoc + pkgs.texlive.combined.scheme-full + pkgs.calibre + pkgs.inkscape + pkgs.poppler_utils + pkgs.assimp + pkgs.jxrlib + pkgs.libheif + pkgs.libjxl + pkgs.python3Packages.numpy + ]; + + config = { + Env = [ + "NODE_ENV=production" + "PATH=/bin:/usr/bin" + ]; + WorkingDir = "/app"; + Cmd = [ "bun" "run" "./src/index.tsx" ]; + ExposedPorts = { + "3000/tcp" = {}; + }; + }; + + extraCommands = '' + export PATH=${pkgs.bun}/bin:$PATH + mkdir -p /app + cp -r ${./dist}/* /app/ + ''; + }; + + in { + packages.default = app; + } + ); +} diff --git a/package.json b/package.json index 24c6102..b9f4740 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "scripts": { "dev": "bun run --watch src/index.tsx", "hot": "bun run --hot src/index.tsx", + "start": "bun run src/index.tsx", "format": "eslint --fix .", "build": "bunx @tailwindcss/cli -i ./src/main.css -o ./public/generated.css", "lint": "run-p 'lint:*'", @@ -51,4 +52,4 @@ "typescript": "^5.8.3", "typescript-eslint": "^8.32.0" } -} \ No newline at end of file +}