railwayapp / nixpacks

App source + Nix packages + Docker = Image
https://nixpacks.com
MIT License
2.47k stars 232 forks source link

Add support for custom host to docker client mapping in Docker builder #945

Closed 9trocode closed 1 year ago

9trocode commented 1 year ago

This PR adds support for docker host mapping in the docker build

----------------------------- Working example on how to use the docker host and tls flag ----------------------------

cargo run -- build examples/node --name node --docker-host tcp://127.0.0.1:2375 --docker-tls-verify 0                                                                                                                                                                                                                                                                                                                        ─╯
   Compiling nixpacks v1.12.0 (/Users/nitrocode/PipeOps/pipeopsv1/nixpacks)
    Finished dev [unoptimized + debuginfo] target(s) in 5.33s
     Running `target/debug/nixpacks build examples/node --name node --docker-host 'tcp://127.0.0.1:2375' --docker-tls-verify 0`

╔═════════ Nixpacks v1.12.0 ════════╗
║ setup      │ nodejs-16_x, npm-8_x ║
║───────────────────────────────────║
║ install    │ npm ci               ║
║───────────────────────────────────║
║ start      │ npm run start        ║
╚═══════════════════════════════════╝

[+] Building 79.2s (4/12)                                                                                                                                                                                                                                                                                                                                                                                           docker:default
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                                                                             0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                                                                               0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                                                                          0.0s
 => => transferring dockerfile: 868B                                                                                                                                                                                                                                                                                                                                                                                          0.0s
 => [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1690243402                                                                                                                                                                                                                                                                                                                                                3.8s
 => [stage-0 1/8] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1690243402@sha256:1a7dc562bf1f13299c20e55f8a72a287cb16dfea072fe4d20d084cfe23494afd                                                                                                                                                                                                                                                                                 75.3s
 => => resolve ghcr.io/railwayapp/nixpacks:ubuntu-1690243402@sha256:1a7dc562bf1f13299c20e55f8a72a287cb16dfea072fe4d20d084cfe23494afd                                                                                                                                                                                                                                                                                          0.0s
 => => sha256:f8d7456877cb31ae8e78b641455964a813e7f934beeca0c22ded064ea2ddd801 19.92MB / 33.46MB                                                                                                                                                                                                                                                                                                                             75.3s
 => => sha256:1a7dc562bf1f13299c20e55f8a72a287cb16dfea072fe4d20d084cfe23494afd 1.61kB / 1.61kB                                                                                                                                                                                                                                                                                                                                0.0s
 => => sha256:0c01b5a4a7b24ce55b86fc836ae66110a37b20271b1fe5c2166aca0aca692d9f 868B / 868B                                                                                                                                                                                                                                                                                                                                    0.0s
 => => sha256:bd59017d458c559ec6fd3d5df0b6e22967b7384628ccb635c5b72bf4e7ac1a90 4.67kB / 4.67kB                                                                                                                                                                                                                                                                                                                                0.0s
 => => sha256:3153aa388d026c26a2235e1ed0163e350e451f41a8a313e1804d7e1afb857ab4 22.02MB / 29.53MB                                                                                                                                                                                                                                                                                                                             75.3s
 => => sha256:01195a80795df2cfcb15d378ed321326e52abd75804cb52a62881010d1b48da3 17.83MB / 30.15MB                                                                                                                                                                                                                                                                                                                             75.3s
 => [internal] load build context                                                                                                                                                                                                                                                                                                                                                                                             0.0s
 => => transferring context: 2.27kB                            

cargo run -- build examples/node --name node --docker-host tcp://192.168.100.228:2375 --docker-tls-verify 0                                                                                                                                                                                                                                                                                                                  ─╯
    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
     Running `target/debug/nixpacks build examples/node --name node --docker-host 'tcp://192.168.100.228:2375' --docker-tls-verify 0`

╔═════════ Nixpacks v1.12.0 ════════╗
║ setup      │ nodejs-16_x, npm-8_x ║
║───────────────────────────────────║
║ install    │ npm ci               ║
║───────────────────────────────────║
║ start      │ npm run start        ║
╚═══════════════════════════════════╝

[+] Building 0.9s (2/3)                                                                                                                                                                                                                                                                                                                                                                                             docker:default
[+] Building 1.0s (3/3) FINISHED                                                                                                                                                                                                                                                                                                                                                                                    docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                                                                          0.0s
 => => transferring dockerfile: 868B                                                                                                                                                                                                                                                                                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                                                                             0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                                                                               0.0s
 => CANCELED [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1690243402                                                                                                                                                                                                                                                                                                                                       1.0s
ERROR: failed to solve: Canceled: context canceled              
9trocode commented 1 year ago

Thanks!

@coffee-cup i fixed the linting issue here already

github-actions[bot] commented 1 year ago

This pull request is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days