From 55c6dcda4e7b139ed46ae77cda5269b75a1dfa1a Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sat, 30 Jul 2022 14:37:44 +0200 Subject: [PATCH 01/34] Add a Windows platform native image (WCOW) --- .dockerignore | 13 ++++- .gitignore | 3 ++ Dockerfile | 4 +- README.md | 3 +- go.mod | 35 +++++++------ go.sum | 122 +++++++++++++++++++++++++++++++-------------- main.go | 6 +-- windows/Dockerfile | 19 +++++++ 8 files changed, 141 insertions(+), 64 deletions(-) create mode 100644 windows/Dockerfile diff --git a/.dockerignore b/.dockerignore index ee995cd..1ca6a33 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,11 @@ -/bin/ -/vendor/ +.DS_Store +.idea/ +.vscode/ + +vendor/ +bin/ + +moby-ryuk +moby-ryuk.exe + +Dockerfile diff --git a/.gitignore b/.gitignore index 4d3aa75..5a04a02 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ vendor/ bin/ + +moby-ryuk +moby-ryuk.exe diff --git a/Dockerfile b/Dockerfile index 3310409..07bfd3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM golang:1.17.6 as workspace +FROM golang:1.18 as workspace WORKDIR /go/src/github.com/testcontainers/moby-ryuk COPY go.mod go.sum ./ RUN go mod download COPY . ./ RUN make build -FROM alpine:3.13.6 +FROM alpine:3.16.1 RUN apk --no-cache add ca-certificates COPY --from=workspace /go/src/github.com/testcontainers/moby-ryuk/bin/moby-ryuk /app CMD ["/app"] diff --git a/README.md b/README.md index 5a4ef5c..ada957e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ This project helps you to remove containers/networks/volumes/images by given fil $ ./bin/moby-ryuk -p 8080 $ # You can also run it with Docker - $ docker run -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 quay.io/testcontainers/ryuk + $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 testcontainers/ryuk + $ docker run --rm -v "//./pipe/docker_engine://./pipe/docker_engine" -p 8080:8080 testcontainers/ryuk 1. Connect via TCP: diff --git a/go.mod b/go.mod index 822fce1..738a1f5 100644 --- a/go.mod +++ b/go.mod @@ -1,29 +1,28 @@ module github.com/testcontainers/moby-ryuk -go 1.17 +go 1.18 require ( - github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35 + github.com/docker/docker v20.10.17+incompatible gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e ) require ( - github.com/Microsoft/go-winio v0.4.6 // indirect - github.com/Sirupsen/logrus v1.0.4 // indirect + github.com/Microsoft/go-winio v0.5.2 // indirect github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 // indirect - github.com/docker/distribution v2.6.0-rc.1.0.20180105232752-277ed486c948+incompatible // indirect - github.com/docker/go-connections v0.3.0 // indirect - github.com/docker/go-units v0.3.3-0.20171221200356-d59758554a3d // indirect - github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect + github.com/docker/distribution v2.8.1+incompatible // indirect + github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-units v0.4.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 // indirect - github.com/opencontainers/go-digest v1.0.0-rc1 // indirect - github.com/pkg/errors v0.8.1-0.20171216070316-e881fd58d78e // indirect - github.com/sirupsen/logrus v1.6.0 // indirect - github.com/stretchr/testify v1.5.1 // indirect - golang.org/x/crypto v0.0.0-20180112200814-13931e22f9e7 // indirect - golang.org/x/net v0.0.0-20180906233101-161cd47e91fd // indirect - golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e // indirect - gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect - gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect - gopkg.in/yaml.v2 v2.2.4 // indirect + github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect + github.com/morikuni/aec v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/sirupsen/logrus v1.9.0 // indirect + golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 // indirect + golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 // indirect + golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect + gotest.tools/v3 v3.3.0 // indirect ) diff --git a/go.sum b/go.sum index fb5844c..5595124 100644 --- a/go.sum +++ b/go.sum @@ -1,52 +1,98 @@ -github.com/Microsoft/go-winio v0.4.6 h1:Tu8dlnF1wvUKKqr011GFneCoyIn7D+Q2uq6AKmQnGrA= -github.com/Microsoft/go-winio v0.4.6/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Sirupsen/logrus v1.0.4 h1:yilvuj073Hm7wwwz12E96GjrdivMNuTMJk9ddjde+D8= -github.com/Sirupsen/logrus v1.0.4/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= +github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/distribution v2.6.0-rc.1.0.20180105232752-277ed486c948+incompatible h1:PVtvnmmxSMUcT5AY6vG7sCCzRg3eyoW6vQvXtITC60c= -github.com/docker/distribution v2.6.0-rc.1.0.20180105232752-277ed486c948+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35 h1:/C46Ovt6t+BTjgMe2c6K1sOJYyxGR2TY/uOP6zzO09M= -github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o= -github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.3.3-0.20171221200356-d59758554a3d h1:dVaNRYvaGV23AdNdsm+4y1mPN0tj3/1v6taqKMmM6Ko= -github.com/docker/go-units v0.3.3-0.20171221200356-d59758554a3d/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= -github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= +github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE= +github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 h1:JAEbJn3j/FrhdWA9jW8B5ajsLIjeuEHLi8xE4fk997o= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= -github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/pkg/errors v0.8.1-0.20171216070316-e881fd58d78e h1:osn9cOzd93npXpRuTFR/MPjiTvTSNHA7pqbXkPyLqQ4= -github.com/pkg/errors v0.8.1-0.20171216070316-e881fd58d78e/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= +github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= +github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -golang.org/x/crypto v0.0.0-20180112200814-13931e22f9e7 h1:bRxAJcr/ZrJIZeEC8Bv1hjCWUfDzHzppUajRw7oCDEY= -golang.org/x/crypto v0.0.0-20180112200814-13931e22f9e7/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 h1:UreQrH7DbFXSi9ZFox6FNT3WBooWmdANpU+IfkT1T4I= +golang.org/x/net v0.0.0-20220728211354-c7608f3a8462/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk= +golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7KdJwhuybIU+FckUHgoyQ= +golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e h1:bJHzu9Qwc9wQRWJ/WVkJGAfs+riucl/tKAFNxf9pzqk= gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e/go.mod h1:tve0rTLdGlwnXF7iBO9rbAEyeXvuuPx0n4DvXS/Nw7o= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= +gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= +gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= diff --git a/main.go b/main.go index 6d4ed23..562c753 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ func main() { flag.Parse() log.Println("Pinging Docker...") - cli, err := client.NewEnvClient() + cli, err := client.NewClientWithOpts(client.FromEnv) if err == nil { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -99,7 +99,7 @@ func processRequests(deathNote *sync.Map, connectionAccepted chan<- net.Addr, co args.Add(filterType, value) } } - param, err := filters.ToParam(args) + param, err := filters.ToJSON(args) if err != nil { log.Println(err) @@ -178,7 +178,7 @@ func prune(cli *client.Client, deathNote *sync.Map) { param := fmt.Sprint(note) log.Printf("Deleting %s\n", param) - args, err := filters.FromParam(param) + args, err := filters.FromJSON(param) if err != nil { log.Println(err) return true diff --git a/windows/Dockerfile b/windows/Dockerfile new file mode 100644 index 0000000..a1118da --- /dev/null +++ b/windows/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:1.18.4-nanoserver AS workspace +LABEL builder=true + +ENV CGO_ENABLED=0 +#ENV GO111MODULE=on + +WORKDIR /go/src/github.com/testcontainers/moby-ryuk +COPY go.mod go.sum ./ +RUN go mod download +COPY . ./ +RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ + && go build \ + -v -a \ + -ldflags "-s -w -extldflags \"-static\"" \ + -o /bin/main main.go + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +COPY --from=workspace /bin/main /app +CMD ["/app"] From 86b1cc1903e7936b60622f732004417e7443b571 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sun, 31 Jul 2022 12:03:25 +0200 Subject: [PATCH 02/34] Revert to an older docker module --- go.mod | 15 ++++------- go.sum | 84 +++++++-------------------------------------------------- main.go | 6 ++--- 3 files changed, 18 insertions(+), 87 deletions(-) diff --git a/go.mod b/go.mod index 738a1f5..cbb30bd 100644 --- a/go.mod +++ b/go.mod @@ -3,26 +3,21 @@ module github.com/testcontainers/moby-ryuk go 1.18 require ( - github.com/docker/docker v20.10.17+incompatible + github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35 gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e ) require ( github.com/Microsoft/go-winio v0.5.2 // indirect - github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 // indirect + github.com/Sirupsen/logrus v1.0.6 // indirect github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 // indirect - github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect - github.com/morikuni/aec v1.0.0 // indirect + github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 // indirect golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 // indirect - golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect - gotest.tools/v3 v3.3.0 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect ) diff --git a/go.sum b/go.sum index 5595124..792bada 100644 --- a/go.sum +++ b/go.sum @@ -1,98 +1,34 @@ -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= -github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/Sirupsen/logrus v1.0.6 h1:HCAGQRk48dRVPA5Y+Yh0qdCSTzPOyU1tBJ7Q9YzotII= +github.com/Sirupsen/logrus v1.0.6/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE= -github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35 h1:/C46Ovt6t+BTjgMe2c6K1sOJYyxGR2TY/uOP6zzO09M= +github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 h1:JAEbJn3j/FrhdWA9jW8B5ajsLIjeuEHLi8xE4fk997o= -github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= -github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= -github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= +github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= -github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 h1:UreQrH7DbFXSi9ZFox6FNT3WBooWmdANpU+IfkT1T4I= golang.org/x/net v0.0.0-20220728211354-c7608f3a8462/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk= golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7KdJwhuybIU+FckUHgoyQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e h1:bJHzu9Qwc9wQRWJ/WVkJGAfs+riucl/tKAFNxf9pzqk= gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e/go.mod h1:tve0rTLdGlwnXF7iBO9rbAEyeXvuuPx0n4DvXS/Nw7o= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= -gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= -gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= diff --git a/main.go b/main.go index 562c753..6d4ed23 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ func main() { flag.Parse() log.Println("Pinging Docker...") - cli, err := client.NewClientWithOpts(client.FromEnv) + cli, err := client.NewEnvClient() if err == nil { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -99,7 +99,7 @@ func processRequests(deathNote *sync.Map, connectionAccepted chan<- net.Addr, co args.Add(filterType, value) } } - param, err := filters.ToJSON(args) + param, err := filters.ToParam(args) if err != nil { log.Println(err) @@ -178,7 +178,7 @@ func prune(cli *client.Client, deathNote *sync.Map) { param := fmt.Sprint(note) log.Printf("Deleting %s\n", param) - args, err := filters.FromJSON(param) + args, err := filters.FromParam(param) if err != nil { log.Println(err) return true From 14b5825ade14fca3efa2ae9c1544af4e6d422015 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sun, 31 Jul 2022 14:40:42 +0200 Subject: [PATCH 03/34] Publish multi-arch images including Windows --- .github/workflows/build-docker-image.yml | 68 ++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index e52f68c..2537aaf 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -8,7 +8,7 @@ on: pull_request: jobs: - build: + build-linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -22,10 +22,10 @@ jobs: # Setup for buildx - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 # Debugging information - name: Docker info @@ -44,3 +44,65 @@ jobs: push: ${{ github.event_name == 'release' && github.event.action == 'published' }} # Use a 'temp' tag, that won't be pushed, for non-release builds tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} + + build-windows: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v2 + - name: Login to Docker Hub + # Only if we need to push an image + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Debugging information + - name: Docker info + run: docker info + + # Build and (optionally) push the image + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: windows/Dockerfile + platforms: windows/amd64 + # Only push if we are publishing a release + push: ${{ github.event_name == 'release' && github.event.action == 'published' }} + # Use a 'temp' tag, that won't be pushed, for non-release builds + tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}-windows.amd64 + + publish-multi-arch: + # Only if we need to push an image + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + needs: + - build-linux + - build-windows + runs-on: ubuntu-latest + steps: + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Setup for buildx + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + with: + version: v0.6.1 + + # Debugging information + - name: Docker info + run: docker info + - name: Buildx inspect + run: docker buildx inspect + + - name: Docker Manifest + run: | + docker buildx imagetools create -t testcontainers/ryuk:${{ github.event.release.tag_name }} \ + testcontainers/ryuk:${{ github.event.release.tag_name }}-linux \ + testcontainers/ryuk:${{ github.event.release.tag_name }}-windows.amd64 +... From 13ce99082be3ed0c6892dfea42ddd65d546eb237 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sun, 7 Aug 2022 11:34:21 +0200 Subject: [PATCH 04/34] Bump Golang to 1.19 --- Dockerfile | 2 +- go.mod | 14 ++++++++++---- go.sum | 32 ++++++++++++++++++++++++++------ windows/Dockerfile | 2 +- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07bfd3f..1b529a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as workspace +FROM golang:1.19 as workspace WORKDIR /go/src/github.com/testcontainers/moby-ryuk COPY go.mod go.sum ./ RUN go mod download diff --git a/go.mod b/go.mod index cbb30bd..f0a4155 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/testcontainers/moby-ryuk -go 1.18 +go 1.19 require ( github.com/docker/docker v1.4.2-0.20170502054910-90d35abf7b35 @@ -10,14 +10,20 @@ require ( require ( github.com/Microsoft/go-winio v0.5.2 // indirect github.com/Sirupsen/logrus v1.0.6 // indirect + github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 // indirect github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect + github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/sirupsen/logrus v1.9.0 // indirect + github.com/stretchr/testify v1.7.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect - golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 // indirect - golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/net v0.0.0-20220805013720-a33c5aa5df48 // indirect + golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 // indirect + golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect + gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect + gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect ) diff --git a/go.sum b/go.sum index 792bada..4236fa7 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,10 @@ github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VM github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Sirupsen/logrus v1.0.6 h1:HCAGQRk48dRVPA5Y+Yh0qdCSTzPOyU1tBJ7Q9YzotII= github.com/Sirupsen/logrus v1.0.6/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U= +github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= +github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= @@ -13,22 +17,38 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= +github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 h1:JAEbJn3j/FrhdWA9jW8B5ajsLIjeuEHLi8xE4fk997o= +github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 h1:UreQrH7DbFXSi9ZFox6FNT3WBooWmdANpU+IfkT1T4I= -golang.org/x/net v0.0.0-20220728211354-c7608f3a8462/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220805013720-a33c5aa5df48 h1:N9Vc/rorQUDes6B9CNdIxAn5jODGj2wzfrei2x4wNj4= +golang.org/x/net v0.0.0-20220805013720-a33c5aa5df48/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk= -golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 h1:9vYwv7OjYaky/tlAeD7C4oC9EsPTlaFl1H2jS++V+ME= +golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= +gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e h1:bJHzu9Qwc9wQRWJ/WVkJGAfs+riucl/tKAFNxf9pzqk= gopkg.in/matryer/try.v1 v1.0.0-20150601225556-312d2599e12e/go.mod h1:tve0rTLdGlwnXF7iBO9rbAEyeXvuuPx0n4DvXS/Nw7o= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/windows/Dockerfile b/windows/Dockerfile index a1118da..f439755 100644 --- a/windows/Dockerfile +++ b/windows/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18.4-nanoserver AS workspace +FROM golang:1.19-nanoserver AS workspace LABEL builder=true ENV CGO_ENABLED=0 From 54947b0125d55584bc97bd81d3dd6f42f776112e Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 8 Aug 2022 17:41:59 +0200 Subject: [PATCH 05/34] Fix Windows platform build --- .github/workflows/build-docker-image.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 2537aaf..08b20d8 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -48,11 +48,11 @@ jobs: build-windows: runs-on: windows-2022 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Login to Docker Hub # Only if we need to push an image if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -61,17 +61,15 @@ jobs: - name: Docker info run: docker info - # Build and (optionally) push the image - name: Build image - uses: docker/build-push-action@v2 - with: - context: . - file: windows/Dockerfile - platforms: windows/amd64 - # Only push if we are publishing a release - push: ${{ github.event_name == 'release' && github.event.action == 'published' }} - # Use a 'temp' tag, that won't be pushed, for non-release builds - tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}-windows.amd64 + # Use a 'temp' tag, that won't be pushed, for non-release builds + run: | + docker build -f windows/Dockerfile -t testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}-windows.amd64 . + - name: Push image + # Only push if we are publishing a release + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + run: | + docker push testcontainers/ryuk:${{ github.event.release.tag_name }}-windows.amd64 publish-multi-arch: # Only if we need to push an image From fa2f720566b360b5558e9267907afef6e644c8dc Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 8 Aug 2022 17:58:00 +0200 Subject: [PATCH 06/34] add workflow_dispatch trigger to ease debugging --- .github/workflows/build-docker-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 08b20d8..0ee5575 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -6,6 +6,7 @@ on: push: branches: [master] pull_request: + workflow_dispatch: jobs: build-linux: From b11ece32d5428f728453998aed1f0859b74d2086 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 8 Aug 2022 18:10:00 +0200 Subject: [PATCH 07/34] linux/s390x builds currently fail with tls issues ``` RUN go mod download go: github.com/Sirupsen/logrus@v1.0.6: Get "https://proxy.golang.org/github.com/%21sirupsen/logrus/@v/v1.0.6.mod": tls: invalid signature by the server certificate: ECDSA verification failure ``` --- .github/workflows/build-docker-image.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 0ee5575..97c8a9f 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -40,7 +40,9 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x +# s390x disabled, trying to debug strange tls cert issues +# platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le # Only push if we are publishing a release push: ${{ github.event_name == 'release' && github.event.action == 'published' }} # Use a 'temp' tag, that won't be pushed, for non-release builds From 1ee680f75bebee63698f922bc298fbfec332913c Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 8 Aug 2022 18:17:30 +0200 Subject: [PATCH 08/34] try to fix linux/s390x --- .github/workflows/build-docker-image.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 97c8a9f..0ee5575 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -40,9 +40,7 @@ jobs: with: context: . file: ./Dockerfile -# s390x disabled, trying to debug strange tls cert issues -# platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x # Only push if we are publishing a release push: ${{ github.event_name == 'release' && github.event.action == 'published' }} # Use a 'temp' tag, that won't be pushed, for non-release builds From 20825a4634641f4839ca89474b0f2565484c7fa6 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 8 Aug 2022 18:25:55 +0200 Subject: [PATCH 09/34] add a hint about potential tls issues for linux/s390x build --- .github/workflows/build-docker-image.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 0ee5575..b77dfbe 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -6,7 +6,6 @@ on: push: branches: [master] pull_request: - workflow_dispatch: jobs: build-linux: @@ -40,6 +39,9 @@ jobs: with: context: . file: ./Dockerfile + # In case linux/s390x fails with tls issues: + # see https://github.com/testcontainers/moby-ryuk/pull/26 + # and https://github.com/testcontainers/moby-ryuk/pull/40 platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x # Only push if we are publishing a release push: ${{ github.event_name == 'release' && github.event.action == 'published' }} From 8667d985fe461e1c7ce9d51aeff92fb28e1f1235 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Tue, 9 Aug 2022 14:10:00 +0200 Subject: [PATCH 10/34] chore --- .github/workflows/build-docker-image.yml | 2 +- Dockerfile | 11 ------- Makefile | 38 ------------------------ linux/Dockerfile | 21 +++++++++++++ windows/Dockerfile | 9 +++--- 5 files changed, 27 insertions(+), 54 deletions(-) delete mode 100644 Dockerfile delete mode 100644 Makefile create mode 100644 linux/Dockerfile diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index b77dfbe..a3cc763 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -38,7 +38,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile + file: ./linux/Dockerfile # In case linux/s390x fails with tls issues: # see https://github.com/testcontainers/moby-ryuk/pull/26 # and https://github.com/testcontainers/moby-ryuk/pull/40 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1b529a8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM golang:1.19 as workspace -WORKDIR /go/src/github.com/testcontainers/moby-ryuk -COPY go.mod go.sum ./ -RUN go mod download -COPY . ./ -RUN make build - -FROM alpine:3.16.1 -RUN apk --no-cache add ca-certificates -COPY --from=workspace /go/src/github.com/testcontainers/moby-ryuk/bin/moby-ryuk /app -CMD ["/app"] diff --git a/Makefile b/Makefile deleted file mode 100644 index d983c55..0000000 --- a/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -.PHONY: compile build build_all fmt lint test vet - -SOURCE_FOLDER := . - -BINARY_PATH ?= ./bin/moby-ryuk - -GOARCH ?= amd64 - -ifdef GOOS -BINARY_PATH :=$(BINARY_PATH).$(GOOS)-$(GOARCH) -endif - -default: build - -build_all: vet fmt - for GOOS in darwin linux windows; do \ - $(MAKE) compile GOOS=$$GOOS GOARCH=amd64 ; \ - done - -compile: - CGO_ENABLED=0 go build -v -ldflags '-s' -o $(BINARY_PATH) $(SOURCE_FOLDER)/ - -run: - go run $(SOURCE_FOLDER)/main.go - -build: vet fmt compile - -fmt: - go fmt $(SOURCE_FOLDER)/... - -vet: - go vet $(SOURCE_FOLDER)/... - -lint: - go lint $(SOURCE_FOLDER)/... - -test: - go test $(SOURCE_FOLDER)/... diff --git a/linux/Dockerfile b/linux/Dockerfile new file mode 100644 index 0000000..a5793fe --- /dev/null +++ b/linux/Dockerfile @@ -0,0 +1,21 @@ +FROM golang:1.19 AS workspace +LABEL builder=true + +ENV CGO_ENABLED=0 + +WORKDIR /go/src/github.com/testcontainers/moby-ryuk +COPY go.mod go.sum ./ +RUN go mod download +COPY . ./ +RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ + && go vet ./... \ + && go test ./... \ + && go build \ + -v -a \ + -ldflags "-s -w -extldflags \"-static\"" \ + -o /bin/moby-ryuk main.go + +FROM alpine:3.16.1 +RUN apk --no-cache add ca-certificates +COPY --from=workspace /bin/moby-ryuk /moby-ryuk +CMD ["/moby-ryuk"] diff --git a/windows/Dockerfile b/windows/Dockerfile index f439755..3cf1854 100644 --- a/windows/Dockerfile +++ b/windows/Dockerfile @@ -2,18 +2,19 @@ FROM golang:1.19-nanoserver AS workspace LABEL builder=true ENV CGO_ENABLED=0 -#ENV GO111MODULE=on WORKDIR /go/src/github.com/testcontainers/moby-ryuk COPY go.mod go.sum ./ RUN go mod download COPY . ./ RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ + && go vet ./... \ + && go test ./... \ && go build \ -v -a \ -ldflags "-s -w -extldflags \"-static\"" \ - -o /bin/main main.go + -o /bin/moby-ryuk main.go FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 -COPY --from=workspace /bin/main /app -CMD ["/app"] +COPY --from=workspace /bin/moby-ryuk /moby-ryuk +CMD ["/moby-ryuk"] From cc4ce014cd30f35b4d9eb9e16060caf64b446015 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Wed, 17 Aug 2022 19:58:32 +0200 Subject: [PATCH 11/34] Try to create images based on :ltsc2019 instead of :ltsc2022 --- windows/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/Dockerfile b/windows/Dockerfile index 3cf1854..be20697 100644 --- a/windows/Dockerfile +++ b/windows/Dockerfile @@ -15,6 +15,6 @@ RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ -ldflags "-s -w -extldflags \"-static\"" \ -o /bin/moby-ryuk main.go -FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +FROM mcr.microsoft.com/windows/nanoserver:ltsc2019 COPY --from=workspace /bin/moby-ryuk /moby-ryuk CMD ["/moby-ryuk"] From 9d8ad215d0a50929418dc94ca186fa3fd96f30c6 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Thu, 18 Aug 2022 08:41:31 +0200 Subject: [PATCH 12/34] wip --- .github/workflows/build-docker-image.yml | 160 ++++++++++++++--------- Dockerfile | 31 +++++ Makefile | 38 ++++++ build-multiarch.sh | 54 ++++++++ 4 files changed, 223 insertions(+), 60 deletions(-) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100755 build-multiarch.sh diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index a3cc763..09dcdcb 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -2,77 +2,117 @@ name: Build multi-arch Docker Image on: release: - types: [published] + types: [ published ] push: - branches: [master] + branches: [ master ] pull_request: jobs: + build-linux-and-windows-multiarch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Login to Docker Hub + # Only if we need to push an image + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Setup for buildx + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Debugging information + - name: Docker info + run: docker info + - name: Buildx inspect + run: docker buildx inspect + + - name: Cross Build for Linux and Windows + run: | + ./build-multiarch.sh testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} + build-linux: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Login to Docker Hub - # Only if we need to push an image - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Setup for buildx - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - # Debugging information - - name: Docker info - run: docker info - - name: Buildx inspect - run: docker buildx inspect - - # Build and (optionally) push the image - - name: Build image - uses: docker/build-push-action@v2 - with: - context: . - file: ./linux/Dockerfile - # In case linux/s390x fails with tls issues: - # see https://github.com/testcontainers/moby-ryuk/pull/26 - # and https://github.com/testcontainers/moby-ryuk/pull/40 - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - # Only push if we are publishing a release - push: ${{ github.event_name == 'release' && github.event.action == 'published' }} - # Use a 'temp' tag, that won't be pushed, for non-release builds - tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} + - uses: actions/checkout@v2 + - name: Login to Docker Hub + # Only if we need to push an image + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Setup for buildx + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + # Debugging information + - name: Docker info + run: docker info + - name: Buildx inspect + run: docker buildx inspect + + # Build and (optionally) push the image + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: ./linux/Dockerfile + # In case linux/s390x fails with tls issues: + # see https://github.com/testcontainers/moby-ryuk/pull/26 + # and https://github.com/testcontainers/moby-ryuk/pull/40 + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + # Only push if we are publishing a release + push: ${{ github.event_name == 'release' && github.event.action == 'published' }} + # Use a 'temp' tag, that won't be pushed, for non-release builds + tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} + + # Build and (optionally) push the image + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: ./windows/Dockerfile + platforms: windows/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x + # Only push if we are publishing a release + push: ${{ github.event_name == 'release' && github.event.action == 'published' }} + # Use a 'temp' tag, that won't be pushed, for non-release builds + tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} build-windows: runs-on: windows-2022 steps: - - uses: actions/checkout@v3 - - name: Login to Docker Hub - # Only if we need to push an image - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Debugging information - - name: Docker info - run: docker info - - - name: Build image - # Use a 'temp' tag, that won't be pushed, for non-release builds - run: | - docker build -f windows/Dockerfile -t testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}-windows.amd64 . - - name: Push image - # Only push if we are publishing a release - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - run: | - docker push testcontainers/ryuk:${{ github.event.release.tag_name }}-windows.amd64 + - uses: actions/checkout@v3 + - name: Login to Docker Hub + # Only if we need to push an image + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Debugging information + - name: Docker info + run: docker info + + - name: Build image + # Use a 'temp' tag, that won't be pushed, for non-release builds + run: | + docker build -f windows/Dockerfile -t testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}-windows.amd64 . + - name: Push image + # Only push if we are publishing a release + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + run: | + docker push testcontainers/ryuk:${{ github.event.release.tag_name }}-windows.amd64 publish-multi-arch: # Only if we need to push an image diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ab01a19 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# dummy value for linux builds +ARG WINBASE=scratch + +FROM --platform=${BUILDPLATFORM} golang:1.19 AS workspace +LABEL builder=true + +ENV CGO_ENABLED=0 +ENV GOOS=${TARGETOS} +ENV GOARCH=${TARGETARCH} + +WORKDIR /go/src/github.com/testcontainers/moby-ryuk +COPY go.mod go.sum ./ +RUN go mod download +COPY . ./ +RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ + && go vet ./... \ + && go test ./... \ + && if [ "$TARGETARCH" = "arm" ]; then export GOARM="${TARGETVARIANT//v}"; fi; \ + go build -v -a \ + -ldflags "-s -w -extldflags \"-static\"" \ + -o /bin/moby-ryuk main.go; \ + chmod +x /bin/moby-ryuk + +FROM ${WINBASE} AS windows +CMD ["/moby-ryuk.exe"] +COPY --from=workspace /bin/moby-ryuk /moby-ryuk.exe + +FROM alpine:3.16.1 AS linux +RUN apk --no-cache add ca-certificates +CMD ["/moby-ryuk"] +COPY --from=workspace /bin/moby-ryuk /moby-ryuk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d983c55 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.PHONY: compile build build_all fmt lint test vet + +SOURCE_FOLDER := . + +BINARY_PATH ?= ./bin/moby-ryuk + +GOARCH ?= amd64 + +ifdef GOOS +BINARY_PATH :=$(BINARY_PATH).$(GOOS)-$(GOARCH) +endif + +default: build + +build_all: vet fmt + for GOOS in darwin linux windows; do \ + $(MAKE) compile GOOS=$$GOOS GOARCH=amd64 ; \ + done + +compile: + CGO_ENABLED=0 go build -v -ldflags '-s' -o $(BINARY_PATH) $(SOURCE_FOLDER)/ + +run: + go run $(SOURCE_FOLDER)/main.go + +build: vet fmt compile + +fmt: + go fmt $(SOURCE_FOLDER)/... + +vet: + go vet $(SOURCE_FOLDER)/... + +lint: + go lint $(SOURCE_FOLDER)/... + +test: + go test $(SOURCE_FOLDER)/... diff --git a/build-multiarch.sh b/build-multiarch.sh new file mode 100755 index 0000000..5040f10 --- /dev/null +++ b/build-multiarch.sh @@ -0,0 +1,54 @@ +TARGETIMAGE=${1:-testcontainers/ryuk:ci} +IS_RELEASE=${2:-no} +BASE="mcr.microsoft.com/windows/nanoserver" +OSVERSIONS=("1809" "1903" "1909" "ltsc2019" "2004" "20H2" "ltsc2022") +MANIFESTLIST="" +BUILDX_PUSH="" + +if [ "$IS_RELEASE" = "yes" ]; then + export BUILDX_PUSH="--push"; +fi; + +# build for Linux +docker buildx build \ + --platform linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 \ + ${BUILDX_PUSH} \ + --pull \ + --target linux \ + -t $TARGETIMAGE \ + . + +# build for Windows +for VERSION in ${OSVERSIONS[*]} +do + docker buildx build \ + --platform windows/amd64 \ + ${BUILDX_PUSH} \ + --pull \ + --build-arg WINBASE=${BASE}:${VERSION} \ + --target windows \ + -t "${TARGETIMAGE}-${VERSION}" \ + . + MANIFESTLIST+="${TARGETIMAGE}-${VERSION} " +done + +# Get images from Linux manifest list, append and annotate Windows images and overwrite in registry +docker manifest rm $TARGETIMAGE > /dev/null 2>&1 +lin_images=$(docker manifest inspect $TARGETIMAGE | jq -r '.manifests[].digest') + +docker manifest create $TARGETIMAGE $MANIFESTLIST ${lin_images//sha256:/${TARGETIMAGE%%:*}@sha256:} + +for VERSION in ${OSVERSIONS[*]} +do + docker manifest rm ${BASE}:${VERSION} > /dev/null 2>&1 + full_version=`docker manifest inspect ${BASE}:${VERSION} | grep "os.version" | head -n 1 | awk '{print $$2}' | sed 's@.*:@@' | sed 's/"//g'` || true; + docker manifest annotate \ + --os-version ${full_version} \ + --os windows \ + --arch amd64 \ + ${TARGETIMAGE} "${TARGETIMAGE}-${VERSION}" +done + +if [ "$IS_RELEASE" = "yes" ]; then + docker manifest push $TARGETIMAGE +fi From a13904e279848efe720629e0f28eb0876d986a4a Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Thu, 18 Aug 2022 08:50:12 +0200 Subject: [PATCH 13/34] wip --- .github/workflows/build-docker-image.yml | 4 ++++ build-multiarch.sh | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 09dcdcb..f8adf1e 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -32,7 +32,11 @@ jobs: - name: Buildx inspect run: docker buildx inspect + # In case linux/s390x fails with tls issues: + # see https://github.com/testcontainers/moby-ryuk/pull/26 + # and https://github.com/testcontainers/moby-ryuk/pull/40 - name: Cross Build for Linux and Windows + # Use a 'temp' tag, that won't be pushed, for non-release builds run: | ./build-multiarch.sh testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} diff --git a/build-multiarch.sh b/build-multiarch.sh index 5040f10..e92032d 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -1,4 +1,4 @@ -TARGETIMAGE=${1:-testcontainers/ryuk:ci} +TARGETIMAGE=${1:-target/image:ci} IS_RELEASE=${2:-no} BASE="mcr.microsoft.com/windows/nanoserver" OSVERSIONS=("1809" "1903" "1909" "ltsc2019" "2004" "20H2" "ltsc2022") @@ -11,7 +11,7 @@ fi; # build for Linux docker buildx build \ - --platform linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 \ + --platform linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 \ ${BUILDX_PUSH} \ --pull \ --target linux \ From 13bf1592ca5bdab553505b85b1d949ca47344ef3 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Thu, 18 Aug 2022 08:50:53 +0200 Subject: [PATCH 14/34] chore --- .github/workflows/build-docker-image.yml | 111 ----------------------- Makefile | 38 -------- linux/Dockerfile | 21 ----- windows/Dockerfile | 20 ---- 4 files changed, 190 deletions(-) delete mode 100644 Makefile delete mode 100644 linux/Dockerfile delete mode 100644 windows/Dockerfile diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index f8adf1e..a3abfe2 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -39,115 +39,4 @@ jobs: # Use a 'temp' tag, that won't be pushed, for non-release builds run: | ./build-multiarch.sh testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} - - build-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Login to Docker Hub - # Only if we need to push an image - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Setup for buildx - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - # Debugging information - - name: Docker info - run: docker info - - name: Buildx inspect - run: docker buildx inspect - - # Build and (optionally) push the image - - name: Build image - uses: docker/build-push-action@v2 - with: - context: . - file: ./linux/Dockerfile - # In case linux/s390x fails with tls issues: - # see https://github.com/testcontainers/moby-ryuk/pull/26 - # and https://github.com/testcontainers/moby-ryuk/pull/40 - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - # Only push if we are publishing a release - push: ${{ github.event_name == 'release' && github.event.action == 'published' }} - # Use a 'temp' tag, that won't be pushed, for non-release builds - tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} - - # Build and (optionally) push the image - - name: Build image - uses: docker/build-push-action@v2 - with: - context: . - file: ./windows/Dockerfile - platforms: windows/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - # Only push if we are publishing a release - push: ${{ github.event_name == 'release' && github.event.action == 'published' }} - # Use a 'temp' tag, that won't be pushed, for non-release builds - tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} - - build-windows: - runs-on: windows-2022 - steps: - - uses: actions/checkout@v3 - - name: Login to Docker Hub - # Only if we need to push an image - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Debugging information - - name: Docker info - run: docker info - - - name: Build image - # Use a 'temp' tag, that won't be pushed, for non-release builds - run: | - docker build -f windows/Dockerfile -t testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}-windows.amd64 . - - name: Push image - # Only push if we are publishing a release - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - run: | - docker push testcontainers/ryuk:${{ github.event.release.tag_name }}-windows.amd64 - - publish-multi-arch: - # Only if we need to push an image - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} - needs: - - build-linux - - build-windows - runs-on: ubuntu-latest - steps: - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Setup for buildx - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - with: - version: v0.6.1 - - # Debugging information - - name: Docker info - run: docker info - - name: Buildx inspect - run: docker buildx inspect - - - name: Docker Manifest - run: | - docker buildx imagetools create -t testcontainers/ryuk:${{ github.event.release.tag_name }} \ - testcontainers/ryuk:${{ github.event.release.tag_name }}-linux \ - testcontainers/ryuk:${{ github.event.release.tag_name }}-windows.amd64 ... diff --git a/Makefile b/Makefile deleted file mode 100644 index d983c55..0000000 --- a/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -.PHONY: compile build build_all fmt lint test vet - -SOURCE_FOLDER := . - -BINARY_PATH ?= ./bin/moby-ryuk - -GOARCH ?= amd64 - -ifdef GOOS -BINARY_PATH :=$(BINARY_PATH).$(GOOS)-$(GOARCH) -endif - -default: build - -build_all: vet fmt - for GOOS in darwin linux windows; do \ - $(MAKE) compile GOOS=$$GOOS GOARCH=amd64 ; \ - done - -compile: - CGO_ENABLED=0 go build -v -ldflags '-s' -o $(BINARY_PATH) $(SOURCE_FOLDER)/ - -run: - go run $(SOURCE_FOLDER)/main.go - -build: vet fmt compile - -fmt: - go fmt $(SOURCE_FOLDER)/... - -vet: - go vet $(SOURCE_FOLDER)/... - -lint: - go lint $(SOURCE_FOLDER)/... - -test: - go test $(SOURCE_FOLDER)/... diff --git a/linux/Dockerfile b/linux/Dockerfile deleted file mode 100644 index a5793fe..0000000 --- a/linux/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM golang:1.19 AS workspace -LABEL builder=true - -ENV CGO_ENABLED=0 - -WORKDIR /go/src/github.com/testcontainers/moby-ryuk -COPY go.mod go.sum ./ -RUN go mod download -COPY . ./ -RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ - && go vet ./... \ - && go test ./... \ - && go build \ - -v -a \ - -ldflags "-s -w -extldflags \"-static\"" \ - -o /bin/moby-ryuk main.go - -FROM alpine:3.16.1 -RUN apk --no-cache add ca-certificates -COPY --from=workspace /bin/moby-ryuk /moby-ryuk -CMD ["/moby-ryuk"] diff --git a/windows/Dockerfile b/windows/Dockerfile deleted file mode 100644 index be20697..0000000 --- a/windows/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM golang:1.19-nanoserver AS workspace -LABEL builder=true - -ENV CGO_ENABLED=0 - -WORKDIR /go/src/github.com/testcontainers/moby-ryuk -COPY go.mod go.sum ./ -RUN go mod download -COPY . ./ -RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ - && go vet ./... \ - && go test ./... \ - && go build \ - -v -a \ - -ldflags "-s -w -extldflags \"-static\"" \ - -o /bin/moby-ryuk main.go - -FROM mcr.microsoft.com/windows/nanoserver:ltsc2019 -COPY --from=workspace /bin/moby-ryuk /moby-ryuk -CMD ["/moby-ryuk"] From 68a489ac4b064e16ee050d4526cb36db21b5cd0c Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Fri, 19 Aug 2022 15:16:43 +0200 Subject: [PATCH 15/34] BASE -> WINBASE Co-authored-by: Kevin Wittek --- build-multiarch.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-multiarch.sh b/build-multiarch.sh index e92032d..bf1394c 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -1,6 +1,6 @@ TARGETIMAGE=${1:-target/image:ci} IS_RELEASE=${2:-no} -BASE="mcr.microsoft.com/windows/nanoserver" +WINBASE="mcr.microsoft.com/windows/nanoserver" OSVERSIONS=("1809" "1903" "1909" "ltsc2019" "2004" "20H2" "ltsc2022") MANIFESTLIST="" BUILDX_PUSH="" @@ -25,7 +25,7 @@ do --platform windows/amd64 \ ${BUILDX_PUSH} \ --pull \ - --build-arg WINBASE=${BASE}:${VERSION} \ + --build-arg WINBASE=${WINBASE}:${VERSION} \ --target windows \ -t "${TARGETIMAGE}-${VERSION}" \ . @@ -40,8 +40,8 @@ docker manifest create $TARGETIMAGE $MANIFESTLIST ${lin_images//sha256:/${TARGET for VERSION in ${OSVERSIONS[*]} do - docker manifest rm ${BASE}:${VERSION} > /dev/null 2>&1 - full_version=`docker manifest inspect ${BASE}:${VERSION} | grep "os.version" | head -n 1 | awk '{print $$2}' | sed 's@.*:@@' | sed 's/"//g'` || true; + docker manifest rm ${WINBASE}:${VERSION} > /dev/null 2>&1 + full_version=`docker manifest inspect ${WINBASE}:${VERSION} | grep "os.version" | head -n 1 | awk '{print $$2}' | sed 's@.*:@@' | sed 's/"//g'` || true; docker manifest annotate \ --os-version ${full_version} \ --os windows \ From 77a526ba127bd8a040f77af9df9b6d4115b72d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 1 Dec 2022 22:25:19 +0100 Subject: [PATCH 16/34] chore: simplify Co-authored-by: Ivan Fernandez Calvo --- build-multiarch.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build-multiarch.sh b/build-multiarch.sh index bf1394c..d239176 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -33,15 +33,21 @@ do done # Get images from Linux manifest list, append and annotate Windows images and overwrite in registry +# Not sure the remove of the manifest is needed docker manifest rm $TARGETIMAGE > /dev/null 2>&1 +# if you push the Docker images the manifest is not locally +docker pull $TARGETIMAGE lin_images=$(docker manifest inspect $TARGETIMAGE | jq -r '.manifests[].digest') docker manifest create $TARGETIMAGE $MANIFESTLIST ${lin_images//sha256:/${TARGETIMAGE%%:*}@sha256:} for VERSION in ${OSVERSIONS[*]} do + # Not sure the remove of the manifest is needed docker manifest rm ${WINBASE}:${VERSION} > /dev/null 2>&1 - full_version=`docker manifest inspect ${WINBASE}:${VERSION} | grep "os.version" | head -n 1 | awk '{print $$2}' | sed 's@.*:@@' | sed 's/"//g'` || true; + # if you push the Docker images the manifest is not locally + docker pull ${WINBASE}:${VERSION} + full_version=$(docker manifest inspect ${WINBASE}:${VERSION} |jq -r '.manifests[]|.platform|."os.version"'| sed 's@.*:@@') || true; docker manifest annotate \ --os-version ${full_version} \ --os windows \ From 01e5548baef2c4e6684b247d01968eddf681b4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 1 Dec 2022 22:56:36 +0100 Subject: [PATCH 17/34] chore: bring back go commands into the GH action --- .github/workflows/build-docker-image.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index cd29b76..71995b6 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -12,6 +12,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + with: + go-version: '1.18' + - run: go version + + - name: modVerify + run: go mod verify + + - name: modTidy + run: go mod tidy + + - name: ensure compilation + env: + GOOS: linux + run: go build + + - name: Test + run: go test -v ./... + - name: Login to Docker Hub # Only if we need to push an image if: ${{ github.event_name == 'release' && github.event.action == 'published' }} @@ -23,10 +43,11 @@ jobs: # Setup for buildx - name: Set up QEMU uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + id: buildx uses: docker/setup-buildx-action@v2 - # Debugging information - name: Docker info run: docker info - name: Buildx inspect From 3938fffe3b8bba2b111ca293f0b544f5656ec12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 1 Dec 2022 16:58:26 +0100 Subject: [PATCH 18/34] chore: add logs to each section of the script --- build-multiarch.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-multiarch.sh b/build-multiarch.sh index d239176..0555ce3 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -9,7 +9,7 @@ if [ "$IS_RELEASE" = "yes" ]; then export BUILDX_PUSH="--push"; fi; -# build for Linux +echo "Building for Linux" docker buildx build \ --platform linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 \ ${BUILDX_PUSH} \ @@ -18,9 +18,9 @@ docker buildx build \ -t $TARGETIMAGE \ . -# build for Windows for VERSION in ${OSVERSIONS[*]} do + echo "Building Windows ${VERSION}" docker buildx build \ --platform windows/amd64 \ ${BUILDX_PUSH} \ @@ -39,11 +39,13 @@ docker manifest rm $TARGETIMAGE > /dev/null 2>&1 docker pull $TARGETIMAGE lin_images=$(docker manifest inspect $TARGETIMAGE | jq -r '.manifests[].digest') +echo "Creating Linux manifest: ${lin_images}" docker manifest create $TARGETIMAGE $MANIFESTLIST ${lin_images//sha256:/${TARGETIMAGE%%:*}@sha256:} for VERSION in ${OSVERSIONS[*]} do # Not sure the remove of the manifest is needed + echo "Annotating Windows platforms to the manifest: ${WINBASE}:${VERSION}" docker manifest rm ${WINBASE}:${VERSION} > /dev/null 2>&1 # if you push the Docker images the manifest is not locally docker pull ${WINBASE}:${VERSION} @@ -56,5 +58,6 @@ do done if [ "$IS_RELEASE" = "yes" ]; then + echo "Pushing manifest to $TARGETIMAGE" docker manifest push $TARGETIMAGE fi From 4b6ff3b53d5f6d644c7bb32df8046e932105441b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 1 Dec 2022 19:56:54 +0100 Subject: [PATCH 19/34] chore: standardize shell variables --- build-multiarch.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/build-multiarch.sh b/build-multiarch.sh index 0555ce3..0737dc4 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -5,7 +5,7 @@ OSVERSIONS=("1809" "1903" "1909" "ltsc2019" "2004" "20H2" "ltsc2022") MANIFESTLIST="" BUILDX_PUSH="" -if [ "$IS_RELEASE" = "yes" ]; then +if [ "${IS_RELEASE}" = "yes" ]; then export BUILDX_PUSH="--push"; fi; @@ -15,7 +15,7 @@ docker buildx build \ ${BUILDX_PUSH} \ --pull \ --target linux \ - -t $TARGETIMAGE \ + -t ${TARGETIMAGE} \ . for VERSION in ${OSVERSIONS[*]} @@ -34,13 +34,13 @@ done # Get images from Linux manifest list, append and annotate Windows images and overwrite in registry # Not sure the remove of the manifest is needed -docker manifest rm $TARGETIMAGE > /dev/null 2>&1 +docker manifest rm ${TARGETIMAGE} > /dev/null 2>&1 # if you push the Docker images the manifest is not locally -docker pull $TARGETIMAGE -lin_images=$(docker manifest inspect $TARGETIMAGE | jq -r '.manifests[].digest') +docker pull ${TARGETIMAGE} +lin_images=$(docker manifest inspect ${TARGETIMAGE} | jq -r '.manifests[].digest') echo "Creating Linux manifest: ${lin_images}" -docker manifest create $TARGETIMAGE $MANIFESTLIST ${lin_images//sha256:/${TARGETIMAGE%%:*}@sha256:} +docker manifest create ${TARGETIMAGE} ${MANIFESTLIST} ${lin_images//sha256:/${TARGETIMAGE%%:*}@sha256:} for VERSION in ${OSVERSIONS[*]} do @@ -57,7 +57,7 @@ do ${TARGETIMAGE} "${TARGETIMAGE}-${VERSION}" done -if [ "$IS_RELEASE" = "yes" ]; then - echo "Pushing manifest to $TARGETIMAGE" - docker manifest push $TARGETIMAGE +if [ "${IS_RELEASE}" = "yes" ]; then + echo "Pushing manifest to ${TARGETIMAGE}" + docker manifest push ${TARGETIMAGE} fi From 5c3ef569cd7afd29f24988d7fe03a459dda15180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 11:28:55 +0100 Subject: [PATCH 20/34] chore: reduce windows OSs --- build-multiarch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-multiarch.sh b/build-multiarch.sh index 0737dc4..1bd2e64 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -1,7 +1,7 @@ TARGETIMAGE=${1:-target/image:ci} IS_RELEASE=${2:-no} WINBASE="mcr.microsoft.com/windows/nanoserver" -OSVERSIONS=("1809" "1903" "1909" "ltsc2019" "2004" "20H2" "ltsc2022") +OSVERSIONS=("ltsc2019" "ltsc2022") MANIFESTLIST="" BUILDX_PUSH="" From 057d0b29ab64c643674ac1f39760bd85c4870bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 11:58:35 +0100 Subject: [PATCH 21/34] chore: add a label with the base image name --- Dockerfile | 6 +++--- build-multiarch.sh | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48ecbf6..157e3a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # dummy value for linux builds -ARG WINBASE=scratch +ARG BASE_IMAGE=scratch FROM --platform=${BUILDPLATFORM} golang:1.18 AS workspace LABEL builder=true @@ -21,11 +21,11 @@ RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ -o /bin/moby-ryuk main.go; \ chmod +x /bin/moby-ryuk -FROM ${WINBASE} AS windows +FROM ${BASE_IMAGE} AS windows CMD ["/moby-ryuk.exe"] COPY --from=workspace /bin/moby-ryuk /moby-ryuk.exe -FROM alpine:3.16.1 AS linux +FROM ${BASE_IMAGE} AS linux RUN apk --no-cache add ca-certificates CMD ["/moby-ryuk"] COPY --from=workspace /bin/moby-ryuk /moby-ryuk diff --git a/build-multiarch.sh b/build-multiarch.sh index 1bd2e64..46c9fac 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -1,5 +1,6 @@ TARGETIMAGE=${1:-target/image:ci} IS_RELEASE=${2:-no} +LINUXBASE="alpine:3.16.1" WINBASE="mcr.microsoft.com/windows/nanoserver" OSVERSIONS=("ltsc2019" "ltsc2022") MANIFESTLIST="" @@ -14,6 +15,8 @@ docker buildx build \ --platform linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 \ ${BUILDX_PUSH} \ --pull \ + --build-arg BASE_IMAGE=${LINUXBASE} \ + --label "org.opencontainers.image.base.name=${LINUXBASE}" \ --target linux \ -t ${TARGETIMAGE} \ . @@ -25,7 +28,8 @@ do --platform windows/amd64 \ ${BUILDX_PUSH} \ --pull \ - --build-arg WINBASE=${WINBASE}:${VERSION} \ + --build-arg BASE_IMAGE=${WINBASE}:${VERSION} \ + --label "org.opencontainers.image.base.name=${WINBASE}:${VERSION}" \ --target windows \ -t "${TARGETIMAGE}-${VERSION}" \ . From d59c833eb765a4067cba6af12a46f93cf82e38a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 17:39:09 +0100 Subject: [PATCH 22/34] chore: separate Windows container Dockerfile --- Dockerfile | 6 +----- Dockerfile.windows | 25 +++++++++++++++++++++++++ build-multiarch.sh | 4 ++-- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 Dockerfile.windows diff --git a/Dockerfile b/Dockerfile index 157e3a1..3983eaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,11 +21,7 @@ RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ -o /bin/moby-ryuk main.go; \ chmod +x /bin/moby-ryuk -FROM ${BASE_IMAGE} AS windows -CMD ["/moby-ryuk.exe"] -COPY --from=workspace /bin/moby-ryuk /moby-ryuk.exe - -FROM ${BASE_IMAGE} AS linux +FROM ${BASE_IMAGE} RUN apk --no-cache add ca-certificates CMD ["/moby-ryuk"] COPY --from=workspace /bin/moby-ryuk /moby-ryuk diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..e67ee4b --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,25 @@ +ARG BASE_IMAGE=scracth + +# dummy value for linux builds +FROM --platform=${BUILDPLATFORM} golang:1.18 AS workspace +LABEL builder=true + +ENV CGO_ENABLED=0 +ENV GOOS=windows +ENV GOARCH=amd64 + +WORKDIR /go/src/github.com/testcontainers/moby-ryuk +COPY go.mod go.sum ./ +RUN go mod download +COPY . ./ +RUN echo $GOOS +RUN echo $GOARCH + +RUN go build -v -a \ + -ldflags "-s -w -extldflags \"-static\"" \ + -o /bin/moby-ryuk main.go; \ + chmod +x /bin/moby-ryuk + +FROM ${BASE_IMAGE} +CMD ["/moby-ryuk.exe"] +COPY --from=workspace /bin/moby-ryuk /moby-ryuk.exe diff --git a/build-multiarch.sh b/build-multiarch.sh index 46c9fac..2b7641f 100755 --- a/build-multiarch.sh +++ b/build-multiarch.sh @@ -17,8 +17,8 @@ docker buildx build \ --pull \ --build-arg BASE_IMAGE=${LINUXBASE} \ --label "org.opencontainers.image.base.name=${LINUXBASE}" \ - --target linux \ -t ${TARGETIMAGE} \ + -f Dockerfile \ . for VERSION in ${OSVERSIONS[*]} @@ -30,8 +30,8 @@ do --pull \ --build-arg BASE_IMAGE=${WINBASE}:${VERSION} \ --label "org.opencontainers.image.base.name=${WINBASE}:${VERSION}" \ - --target windows \ -t "${TARGETIMAGE}-${VERSION}" \ + -f Dockerfile.windows \ . MANIFESTLIST+="${TARGETIMAGE}-${VERSION} " done From 422bef6888d4cf617a93c86fcc65070854771c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 17:39:58 +0100 Subject: [PATCH 23/34] chore: do not run tests while packaging They are already run in the GH workflow --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3983eaf..3d3e6e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,6 @@ COPY go.mod go.sum ./ RUN go mod download COPY . ./ RUN cd /go/src/github.com/testcontainers/moby-ryuk && go get -d \ - && go vet ./... \ - && go test ./... \ && if [ "$TARGETARCH" = "arm" ]; then export GOARM="${TARGETVARIANT//v}"; fi; \ go build -v -a \ -ldflags "-s -w -extldflags \"-static\"" \ From 08458a23d327c31b4cc797fc67b95b2e2833d8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 17:46:24 +0100 Subject: [PATCH 24/34] chore: simplify logic extracting vars to env vars --- .github/workflows/build-docker-image.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 71995b6..f80b564 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -57,7 +57,9 @@ jobs: # see https://github.com/testcontainers/moby-ryuk/pull/26 # and https://github.com/testcontainers/moby-ryuk/pull/40 - name: Cross Build for Linux and Windows + env: + RYUK_VERSION: ${{ github.event.release.tag_name || github.sha }} + IS_RELEASE: ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} # Use a 'temp' tag, that won't be pushed, for non-release builds run: | - ./build-multiarch.sh testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }} ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} -... + ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} ${IS_RELEASE} From 95dfe017ba035eeb95408f9ebd7078dc6415e6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 17:46:39 +0100 Subject: [PATCH 25/34] chore: remove publish workflow, as it's already managed by the build one --- .github/workflows/publish-docker-image.yml | 47 ---------------------- 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/publish-docker-image.yml diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml deleted file mode 100644 index 17c6f0b..0000000 --- a/.github/workflows/publish-docker-image.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Release multi-arch Docker Image - -on: - release: - types: [published] - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-go@v3 - with: - go-version: '1.18' - - run: go version - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Verify project - run: make verify - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Docker info - run: docker info - - name: Buildx inspect - run: docker buildx inspect - - - name: Build and push image - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - # Only push if we are publishing a release - push: true - tags: testcontainers/ryuk:${{ github.event.release.tag_name }} From 3e70928ae14404917152893e5180f87848510e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 17:54:29 +0100 Subject: [PATCH 26/34] fic: keep GH check for the build --- .github/workflows/build-docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index f80b564..63c62ea 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -8,7 +8,7 @@ on: pull_request: jobs: - build-linux-and-windows-multiarch: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From cf94a38fbc504a38fca6e2e619b6078365b7e5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 20:36:02 +0100 Subject: [PATCH 27/34] chore: update windows example Co-authored-by: Tobias Gesellchen --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ada957e..ce188a1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ This project helps you to remove containers/networks/volumes/images by given fil $ ./bin/moby-ryuk -p 8080 $ # You can also run it with Docker $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 testcontainers/ryuk - $ docker run --rm -v "//./pipe/docker_engine://./pipe/docker_engine" -p 8080:8080 testcontainers/ryuk + $ # Example for Windows + $ docker run --rm -v //./pipe/docker_engine://./pipe/docker_engine -p 8080:8080 testcontainers/ryuk 1. Connect via TCP: From 4e9cfaac2d521ae60ca238a86669e055636e572d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 20:37:27 +0100 Subject: [PATCH 28/34] chore: remove useless comments Co-authored-by: Tobias Gesellchen --- Dockerfile | 1 - Dockerfile.windows | 1 - 2 files changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3d3e6e6..f2e52fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -# dummy value for linux builds ARG BASE_IMAGE=scratch FROM --platform=${BUILDPLATFORM} golang:1.18 AS workspace diff --git a/Dockerfile.windows b/Dockerfile.windows index e67ee4b..6500e13 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,6 +1,5 @@ ARG BASE_IMAGE=scracth -# dummy value for linux builds FROM --platform=${BUILDPLATFORM} golang:1.18 AS workspace LABEL builder=true From 0ec7863c5d7b10890a34f31775c5685abe26b0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 20:38:57 +0100 Subject: [PATCH 29/34] chore: remove default value for scratch --- Dockerfile | 2 +- Dockerfile.windows | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f2e52fd..32321e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=scratch +ARG BASE_IMAGE FROM --platform=${BUILDPLATFORM} golang:1.18 AS workspace LABEL builder=true diff --git a/Dockerfile.windows b/Dockerfile.windows index 6500e13..869b6af 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=scracth +ARG BASE_IMAGE FROM --platform=${BUILDPLATFORM} golang:1.18 AS workspace LABEL builder=true From 8e7e12ff7552aecf466575be1d884dbb4f9c0f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 2 Dec 2022 20:45:59 +0100 Subject: [PATCH 30/34] chore: remove comment Co-authored-by: Tobias Gesellchen --- .github/workflows/build-docker-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 63c62ea..90d0d4a 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -60,6 +60,5 @@ jobs: env: RYUK_VERSION: ${{ github.event.release.tag_name || github.sha }} IS_RELEASE: ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} - # Use a 'temp' tag, that won't be pushed, for non-release builds run: | ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} ${IS_RELEASE} From c42df8434a616772bc5f1b35a7945f39e736e56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 9 Dec 2022 11:47:40 +0100 Subject: [PATCH 31/34] chore: add a job that actually runs the created images --- .github/workflows/build-docker-image.yml | 29 +++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 90d0d4a..f47dc8a 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -7,6 +7,10 @@ on: branches: [ main ] pull_request: +env: + RYUK_VERSION: ${{ github.event.release.tag_name || github.sha }} + IS_RELEASE: ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} + jobs: build: runs-on: ubuntu-latest @@ -57,8 +61,27 @@ jobs: # see https://github.com/testcontainers/moby-ryuk/pull/26 # and https://github.com/testcontainers/moby-ryuk/pull/40 - name: Cross Build for Linux and Windows - env: - RYUK_VERSION: ${{ github.event.release.tag_name || github.sha }} - IS_RELEASE: ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} run: | ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} ${IS_RELEASE} + + run-images: + needs: build + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, windows-2022] + + runs-on: ${{ matrix.os }} + + steps: + - name: Pull Ryuk + run: docker pull testcontainers/ryuk:${RYUK_VERSION} + + - name: Run Ryuk on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} + run: docker run -v /var/run/docker.sock:/var/run/docker.sock testcontainers/ryuk:${RYUK_VERSION} + + - name: Run Ryuk on Windows + if: ${{ matrix.os == 'windows-2022' }} + run: docker run -v //./pipe/docker_engine://./pipe/docker_engine testcontainers/ryuk:${RYUK_VERSION} + continue-on-error: true From ef0c62890c3f507fef09bd0567350755d25ac1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 9 Dec 2022 12:00:02 +0100 Subject: [PATCH 32/34] chore: always push the docker images, as we want to test snapshots --- .github/workflows/build-docker-image.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index f47dc8a..2b74d11 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -9,7 +9,6 @@ on: env: RYUK_VERSION: ${{ github.event.release.tag_name || github.sha }} - IS_RELEASE: ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} jobs: build: @@ -62,7 +61,7 @@ jobs: # and https://github.com/testcontainers/moby-ryuk/pull/40 - name: Cross Build for Linux and Windows run: | - ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} ${IS_RELEASE} + ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} 'yes' run-images: needs: build From b1b4dfe021915ad3f1977076fbf1d1916391d70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 9 Dec 2022 12:15:39 +0100 Subject: [PATCH 33/34] fix: always login to Docker Hub --- .github/workflows/build-docker-image.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 2b74d11..825ee99 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -36,8 +36,6 @@ jobs: run: go test -v ./... - name: Login to Docker Hub - # Only if we need to push an image - if: ${{ github.event_name == 'release' && github.event.action == 'published' }} uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From d154bfc95e85c6de2ee4c9a45f836c0cba560419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 9 Dec 2022 13:38:31 +0100 Subject: [PATCH 34/34] chore: do not access Docker Hub on PRs --- .github/workflows/build-docker-image.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 825ee99..208ec7d 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -9,6 +9,7 @@ on: env: RYUK_VERSION: ${{ github.event.release.tag_name || github.sha }} + IS_RELEASE: ${{ (github.event_name == 'release' && github.event.action == 'published' && 'yes') || 'no' }} jobs: build: @@ -36,6 +37,7 @@ jobs: run: go test -v ./... - name: Login to Docker Hub + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -59,9 +61,10 @@ jobs: # and https://github.com/testcontainers/moby-ryuk/pull/40 - name: Cross Build for Linux and Windows run: | - ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} 'yes' + ./build-multiarch.sh testcontainers/ryuk:${RYUK_VERSION} ${IS_RELEASE} run-images: + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} needs: build strategy: fail-fast: false