├── .Dockerignore ├── .gitignore ├── Dockerfile ├── Gockerfile.yaml ├── LICENSE ├── Makefile ├── README.md ├── build.go ├── cmd └── gocker │ └── main.go ├── config └── config.go ├── example ├── gin │ └── main.go └── server │ └── main.go ├── go.mod ├── go.sum ├── gocker2llb.go ├── goreleaser.yml └── image.go /.Dockerignore: -------------------------------------------------------------------------------- 1 | README.md 2 | LICENSE 3 | out.png 4 | gocker 5 | example/ 6 | .gitignore 7 | Makefile 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.png 3 | gocker 4 | .vscode -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.12 AS builder 2 | 3 | ENV GO111MODULE on 4 | WORKDIR /go/src/github.com/po3rin/gockerfile 5 | COPY . ./ 6 | RUN CGO_ENABLED=0 go build -o /gocker -tags "v0.0.1" --ldflags "-s -w" ./cmd/gocker 7 | 8 | FROM scratch 9 | COPY --from=builder /gocker /bin/gocker 10 | ENTRYPOINT ["/bin/gocker"] 11 | -------------------------------------------------------------------------------- /Gockerfile.yaml: -------------------------------------------------------------------------------- 1 | #syntax=po3rin/gocker 2 | repo: github.com/po3rin/gockerfile 3 | path: ./example/gin 4 | version: v0.0.1 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GATEWAY_IMAGE := po3rin/gocker 2 | IMAGE := po3rin/gockersample 3 | 4 | GATEWAY_IMAGE_TEST := po3rin/gocker-t 5 | 6 | .PHONY: debug-llb 7 | debug-raw: 8 | go run cmd/gocker/main.go -graph | buildctl debug dump-llb | jq . 9 | 10 | .PHONY: debug-img 11 | debug-img: 12 | go run cmd/gocker/main.go -graph | buildctl debug dump-llb --dot | dot -T png -o out.png 13 | 14 | # TODO debug. 15 | # error: failed to solve: rpc error: code = Unknown desc = runtime execution on platform darwin/amd64 not supported 16 | .PHONY: build-gocker 17 | build-gocker: 18 | go run cmd/gocker/main.go -graph | buildctl build --output type=docker,name=gockersample | docker load 19 | 20 | .PHONY: docker-build 21 | docker-build: 22 | DOCKER_BUILDKIT=1 docker build -f Gockerfile.yaml -t po3rin/gockersample . 23 | 24 | .PHONY: build-buildctl 25 | build-buildctl: 26 | buildctl build \ 27 | --frontend=gateway.v0 \ 28 | --opt source=$(GATEWAY_IMAGE) \ 29 | --local gockerfile=. \ 30 | --output type=docker,name=$(IMAGE) | docker load 31 | 32 | .PHONY: build-buildctl-test 33 | build-buildctl-test: 34 | buildctl --debug build \ 35 | --frontend=gateway.v0 \ 36 | --opt source=$(GATEWAY_IMAGE_TEST) \ 37 | --local gockerfile=. \ 38 | --output type=docker,name=$(IMAGE) | docker load 39 | 40 | .PHONY: image 41 | image: 42 | docker build . -t $(GATEWAY_IMAGE) && docker push $(GATEWAY_IMAGE) 43 | 44 | .PHONY: run 45 | run: 46 | docker run -it -p 8080:8080 po3rin/gockersample:latest /bin/server 47 | 48 | .PHONY: image-test 49 | image-test: 50 | docker build . -t $(GATEWAY_IMAGE_TEST) && docker push $(GATEWAY_IMAGE_TEST) 51 | 52 | .PHONY: run-test 53 | run-test: 54 | docker run -it -p 8080:8080 po3rin/gockersample:latest /bin/server 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gockerfile 2 | 3 | [![GolangCI](https://golangci.com/badges/github.com/po3rin/gockerfile.svg)](https://golangci.com) 4 | 5 | :whale: 6 | gockerfile is a YAML Docker-compatible alternative to the Dockerfile Specializing in simple go server. 7 | 8 | ## Instalation as cmd 9 | 10 | ```bash 11 | $ go get -u github.com/po3rin/gockerfile/cmd/gocker 12 | ``` 13 | 14 | ## Usage 15 | 16 | ### po3rin/gocker config file 17 | 18 | create Gockerfile.yaml (Gockerfile supports only 3 fields) 19 | 20 | ```yaml 21 | #syntax=po3rin/gocker 22 | 23 | repo: github.com/po3rin/gockerfile 24 | path: ./example/server 25 | version: v0.0.1 # default master 26 | ``` 27 | 28 | repo is git repository. path is path to main.go. 29 | 30 | ### Build Gockerfile using docker build 31 | 32 | you can build Gockerfile.yaml with docker build 33 | 34 | ``` 35 | $ DOCKER_BUILDKIT=1 docker build -f Gockerfile.yaml -t po3rin/gockersample . 36 | ``` 37 | 38 | ### Build Gockerfile with builtctl 39 | 40 | using as buildkit frontend. 41 | 42 | ```bash 43 | buildctl build \ 44 | --frontend=gateway.v0 \ 45 | --opt source=po3rin/gocker \ 46 | --local gockerfile=. \ 47 | --output type=docker,name=gockersample | docker load 48 | ``` 49 | 50 | ## Run container 51 | 52 | You can run go API container as it is. 53 | 54 | ```bash 55 | $ docker run -it -p 8080:8080 po3rin/gockersample:latest /bin/server 56 | $ curl localhost:8080/ 57 | Hello World 58 | ``` 59 | -------------------------------------------------------------------------------- /build.go: -------------------------------------------------------------------------------- 1 | package gockerfile 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/containerd/containerd/platforms" 9 | "github.com/moby/buildkit/client/llb" 10 | "github.com/moby/buildkit/exporter/containerimage/exptypes" 11 | "github.com/moby/buildkit/frontend/gateway/client" 12 | "github.com/pkg/errors" 13 | "github.com/po3rin/gockerfile/config" 14 | ) 15 | 16 | const ( 17 | LocalNameContext = "context" 18 | LocalNameDockerfile = "dockerfile" 19 | LocalNameGockerfile = "gockerfile" 20 | keyTarget = "target" 21 | keyFilename = "filename" 22 | keyCacheFrom = "cache-from" 23 | defaultGockerfileName = "Gockerfile.yaml" 24 | dockerignoreFilename = ".dockerignore" 25 | buildArgPrefix = "build-arg:" 26 | labelPrefix = "label:" 27 | keyNoCache = "no-cache" 28 | keyTargetPlatform = "platform" 29 | keyMultiPlatform = "multi-platform" 30 | keyImageResolveMode = "image-resolve-mode" 31 | keyGlobalAddHosts = "add-hosts" 32 | keyForceNetwork = "force-network-mode" 33 | keyOverrideCopyImage = "override-copy-image" // remove after CopyOp implemented 34 | ) 35 | 36 | // Build builds Docker Image. Internaly, get config from Gockerfile.yml & convert LLB & solve. 37 | func Build(ctx context.Context, c client.Client) (*client.Result, error) { 38 | cfg, err := GetGockerfileConfig(ctx, c) 39 | if err != nil { 40 | return nil, errors.Wrap(err, "got error getting gockerfile") 41 | } 42 | st, img, err := Gocker2LLB(cfg) 43 | if err != nil { 44 | return nil, errors.Wrapf(err, "failed to convert gocker to llb") 45 | } 46 | 47 | def, err := st.Marshal() 48 | if err != nil { 49 | return nil, errors.Wrapf(err, "failed to marshal local source") 50 | } 51 | res, err := c.Solve(ctx, client.SolveRequest{ 52 | Definition: def.ToPB(), 53 | }) 54 | if err != nil { 55 | return nil, errors.Wrapf(err, "failed to resolve dockerfile") 56 | } 57 | ref, err := res.SingleRef() 58 | if err != nil { 59 | return nil, err 60 | } 61 | 62 | config, err := json.Marshal(img) 63 | if err != nil { 64 | return nil, errors.Wrapf(err, "failed to marshal image config") 65 | } 66 | k := platforms.Format(platforms.DefaultSpec()) 67 | 68 | res.AddMeta(fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, k), config) 69 | res.SetRef(ref) 70 | 71 | return res, nil 72 | } 73 | 74 | func GetGockerfileConfig(ctx context.Context, c client.Client) (*config.Config, error) { 75 | opts := c.BuildOpts().Opts 76 | 77 | var localName string 78 | filename := opts[keyFilename] 79 | if filename == "" { 80 | filename = defaultGockerfileName 81 | localName = LocalNameGockerfile 82 | } else { 83 | localName = LocalNameDockerfile 84 | } 85 | 86 | name := "load Gockerfile" 87 | if filename != "Gockerfile" { 88 | name += " from " + filename 89 | } 90 | 91 | src := llb.Local(localName, 92 | llb.IncludePatterns([]string{filename}), 93 | llb.SessionID(c.BuildOpts().SessionID), 94 | llb.SharedKeyHint(defaultGockerfileName), 95 | llb.WithCustomName("[internal] "+name), 96 | ) 97 | 98 | def, err := src.Marshal() 99 | if err != nil { 100 | return nil, errors.Wrapf(err, "failed to marshal local source") 101 | } 102 | 103 | var dtGockerfile []byte 104 | res, err := c.Solve(ctx, client.SolveRequest{ 105 | Definition: def.ToPB(), 106 | }) 107 | if err != nil { 108 | return nil, errors.Wrapf(err, "failed to resolve Gockerfile") 109 | } 110 | 111 | ref, err := res.SingleRef() 112 | if err != nil { 113 | return nil, err 114 | } 115 | 116 | dtGockerfile, err = ref.ReadFile(ctx, client.ReadRequest{ 117 | Filename: filename, 118 | }) 119 | if err != nil { 120 | return nil, errors.Wrapf(err, "failed to read Gockerfile") 121 | } 122 | 123 | cfg, err := config.NewConfigFromBytes(dtGockerfile) 124 | if err != nil { 125 | return nil, errors.Wrap(err, "getting config") 126 | } 127 | 128 | return cfg, nil 129 | } 130 | -------------------------------------------------------------------------------- /cmd/gocker/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "log" 6 | "os" 7 | 8 | "github.com/moby/buildkit/client/llb" 9 | "github.com/moby/buildkit/frontend/gateway/grpcclient" 10 | "github.com/moby/buildkit/util/appcontext" 11 | "github.com/po3rin/gockerfile" 12 | "github.com/po3rin/gockerfile/config" 13 | ) 14 | 15 | var ( 16 | filename string 17 | graph bool 18 | ) 19 | 20 | func main() { 21 | flag.BoolVar(&graph, "graph", false, "output a graph and exit") 22 | flag.StringVar(&filename, "f", "Gockerfile.yaml", "the file to read from") 23 | flag.Parse() 24 | 25 | if graph { 26 | c, err := config.NewConfigFromFilename(filename) 27 | if err != nil { 28 | log.Fatal(err) 29 | } 30 | 31 | st, _, err := gockerfile.Gocker2LLB(c) 32 | if err != nil { 33 | log.Fatal(err) 34 | } 35 | dt, err := st.Marshal() 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | llb.WriteTo(dt, os.Stdout) 40 | os.Exit(0) 41 | } 42 | 43 | if err := grpcclient.RunFromEnvironment(appcontext.Context(), gockerfile.Build); err != nil { 44 | log.Fatal(err) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | 7 | "github.com/pkg/errors" 8 | yaml "gopkg.in/yaml.v2" 9 | ) 10 | 11 | // Config is yml top level config. 12 | type Config struct { 13 | Repo string `yaml:"repo"` 14 | Ver string `yaml:"version"` 15 | Path string `yaml:"path"` 16 | } 17 | 18 | func validateRequiredConfig(c *Config) error { 19 | if c.Repo == "" { 20 | return errors.New("repo field is required") 21 | } 22 | return nil 23 | } 24 | 25 | func setDefaultConfig(c *Config) *Config { 26 | if c.Ver == "" { 27 | c.Ver = "master" 28 | } 29 | if c.Path == "" { 30 | c.Path = "./" 31 | } 32 | return c 33 | } 34 | 35 | // NewConfigFromBytes returns a new config from a bytes 36 | func NewConfigFromBytes(b []byte) (*Config, error) { 37 | c := &Config{} 38 | if err := yaml.Unmarshal(b, c); err != nil { 39 | return nil, errors.Wrap(err, "unmarshal config") 40 | } 41 | if err := validateRequiredConfig(c); err != nil { 42 | return nil, errors.Wrap(err, "failed to validate gockerfile") 43 | } 44 | c = setDefaultConfig(c) 45 | return c, nil 46 | } 47 | 48 | // NewConfigFromFilename shorthand to NewConfigFromBytes. 49 | func NewConfigFromFilename(filename string) (*Config, error) { 50 | f, err := os.Open(filename) 51 | if err != nil { 52 | return nil, errors.Wrap(err, "got error opening file") 53 | } 54 | defer f.Close() 55 | contents, err := ioutil.ReadAll(f) 56 | if err != nil { 57 | return nil, errors.Wrap(err, "got error reading config file") 58 | } 59 | return NewConfigFromBytes(contents) 60 | } 61 | -------------------------------------------------------------------------------- /example/gin/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | func main() { 6 | r := gin.Default() 7 | r.GET("/ping", func(c *gin.Context) { 8 | c.JSON(200, gin.H{ 9 | "message": "ping", 10 | }) 11 | }) 12 | r.Run() 13 | } 14 | -------------------------------------------------------------------------------- /example/server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | ) 8 | 9 | func hello(w http.ResponseWriter, r *http.Request) { 10 | fmt.Fprintf(w, "Hello World") 11 | } 12 | 13 | func main() { 14 | http.HandleFunc("/", hello) 15 | if err := http.ListenAndServe(":8080", nil); err != nil { 16 | log.Fatal("ListenAndServe: ", err) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/po3rin/gockerfile 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/containerd/containerd v1.3.0-0.20190212172151-f5b0fa220df8 7 | github.com/docker/docker v0.7.3-0.20180531152204-71cd53e4a197 8 | github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 // indirect 9 | github.com/gin-gonic/gin v1.3.0 10 | github.com/mattn/go-isatty v0.0.7 // indirect 11 | github.com/moby/buildkit v0.4.0 12 | github.com/opencontainers/image-spec v1.0.1 13 | github.com/pkg/errors v0.8.1 14 | github.com/r2d4/mockerfile v0.0.0-20190109124726-140c6a912bbf 15 | github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 // indirect 16 | gopkg.in/go-playground/validator.v8 v8.18.2 // indirect 17 | gopkg.in/yaml.v2 v2.2.1 18 | ) 19 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 2 | github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= 3 | github.com/Microsoft/hcsshim v0.8.5/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= 4 | github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 5 | github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= 6 | github.com/containerd/cgroups v0.0.0-20181219155423-39b18af02c41/go.mod h1:X9rLEHIqSf/wfK8NsPqxJmeZgW4pcfzdXITDrUSJ6uI= 7 | github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= 8 | github.com/containerd/containerd v1.2.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= 9 | github.com/containerd/containerd v1.3.0-0.20190212172151-f5b0fa220df8 h1:SAFmxzP/R0bE7iYWaYWlnxAO0a4Rol5KwXuS/iD4Mu4= 10 | github.com/containerd/containerd v1.3.0-0.20190212172151-f5b0fa220df8/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= 11 | github.com/containerd/continuity v0.0.0-20181001140422-bd77b46c8352/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= 12 | github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= 13 | github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= 14 | github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= 15 | github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 16 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 17 | github.com/docker/cli v0.0.0-20190131223713-234462756460/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= 18 | github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible h1:dvc1KSkIYTVjZgHf/CTC2diTYC8PzhaA5sFISRfNVrE= 19 | github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= 20 | github.com/docker/docker v0.7.3-0.20180531152204-71cd53e4a197 h1:xjQaPxUee5t0z4hTzMWDAJLQ5InCoNS5eMfRdyvG9/o= 21 | github.com/docker/docker v0.7.3-0.20180531152204-71cd53e4a197/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 22 | github.com/docker/docker-credential-helpers v0.6.0/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= 23 | github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o= 24 | github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= 25 | github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= 26 | github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= 27 | github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= 28 | github.com/docker/libnetwork v0.0.0-20180913200009-36d3bed0e9f4/go.mod h1:93m0aTqz6z+g32wla4l4WxTrdtvBRmVzYRkYvasA5Z8= 29 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 30 | github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g= 31 | github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= 32 | github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs= 33 | github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= 34 | github.com/godbus/dbus v4.1.0+incompatible/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= 35 | github.com/gofrs/flock v0.7.0/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= 36 | github.com/gogo/googleapis v0.0.0-20180501115203-b23578765ee5 h1:/IG8HCSoBr+VsVJYoJ+gf91i8ZX2JuLOqd4t9Wt9zN4= 37 | github.com/gogo/googleapis v0.0.0-20180501115203-b23578765ee5/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= 38 | github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= 39 | github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 40 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 41 | github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= 42 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 43 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 44 | github.com/google/shlex v0.0.0-20150127133951-6f45313302b9 h1:JM174NTeGNJ2m/oLH3UOWOvWQQKd+BoL3hcSCUWFLt0= 45 | github.com/google/shlex v0.0.0-20150127133951-6f45313302b9/go.mod h1:RpwtwJQFrIEPstU94h88MWPXP2ektJZ8cZ0YntAmXiE= 46 | github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= 47 | github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= 48 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 49 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 50 | github.com/hashicorp/golang-lru v0.0.0-20160207214719-a0d98a5f2880/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 51 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 52 | github.com/hashicorp/uuid v0.0.0-20160311170451-ebb0a03e909c/go.mod h1:fHzc09UnyJyqyW+bFuq864eh+wC7dj65aXmXLRe5to0= 53 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 54 | github.com/ishidawataru/sctp v0.0.0-20180213033435-07191f837fed/go.mod h1:DM4VvS+hD/kDi1U1QsX2fnZowwBhqD0Dk3bRPKF/Oc8= 55 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 56 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 57 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 58 | github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc= 59 | github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 60 | github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= 61 | github.com/moby/buildkit v0.4.0 h1:G+Tmjcf641ydgaxznDR3NBukvUWHF/ywyepWjiEDsPg= 62 | github.com/moby/buildkit v0.4.0/go.mod h1:MF4hMPvE6YC67Nwj70Soh0QX3igIeDct3HOOcpr0qgw= 63 | github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= 64 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 65 | github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 66 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 67 | github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= 68 | github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= 69 | github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= 70 | github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= 71 | github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= 72 | github.com/opencontainers/runtime-spec v0.0.0-20180909173843-eba862dc2470/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= 73 | github.com/opentracing-contrib/go-stdlib v0.0.0-20171029140428-b1a47cfbdd75/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w= 74 | github.com/opentracing/opentracing-go v0.0.0-20171003133519-1361b9cd60be/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 75 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 76 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 77 | github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= 78 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 79 | github.com/r2d4/mockerfile v0.0.0-20190109124726-140c6a912bbf h1:NaqgGVdwXPfbV7pU0BNjT4Jg/uTD8sqbBGjBTZkVSA0= 80 | github.com/r2d4/mockerfile v0.0.0-20190109124726-140c6a912bbf/go.mod h1:itUPU9XujSPy3xladHSb/OQdrm57aI+idtamaEUfCA4= 81 | github.com/sirupsen/logrus v1.0.3 h1:B5C/igNWoiULof20pKfY4VntcIPqKuwEmoLZrabbUrc= 82 | github.com/sirupsen/logrus v1.0.3/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= 83 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 84 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 85 | github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= 86 | github.com/tonistiigi/fsutil v0.0.0-20190130224639-b4281fa67095 h1:b9hxvP2uTwPNrzo4q77+g25UgefFB3+f7i5IpRvlzDs= 87 | github.com/tonistiigi/fsutil v0.0.0-20190130224639-b4281fa67095/go.mod h1:UYukpgbLYvlEDwyQ/SqtLJ9QlgYORCPEwDln/Noj7xc= 88 | github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea/go.mod h1:WPnis/6cRcDZSUvVmezrxJPkiO87ThFYsoUiMwWNDJk= 89 | github.com/uber/jaeger-client-go v0.0.0-20180103221425-e02c85f9069e/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= 90 | github.com/uber/jaeger-lib v1.2.1/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= 91 | github.com/ugorji/go v1.1.2 h1:JON3E2/GPW2iDNGoSAusl1KDf5TRQ8k8q7Tp097pZGs= 92 | github.com/ugorji/go v1.1.2/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= 93 | github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 h1:vG/gY/PxA3v3l04qxe3tDjXyu3bozii8ulSlIPOYKhI= 94 | github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA= 95 | github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= 96 | github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= 97 | github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= 98 | go.etcd.io/bbolt v1.3.1-etcd.8/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 99 | golang.org/x/crypto v0.0.0-20190129210102-ccddf3741a0c h1:MWY7h75sb9ioBR+s5Zgq1JYXxhbZvrSP2okwLi3ItmI= 100 | golang.org/x/crypto v0.0.0-20190129210102-ccddf3741a0c/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 101 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= 102 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 103 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= 104 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 105 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= 106 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 107 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= 108 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 109 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 110 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 111 | golang.org/x/time v0.0.0-20161028155119-f51c12702a4d/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 112 | google.golang.org/genproto v0.0.0-20170523043604-d80a6e20e776 h1:wVJP1pATLVPNxCz4R2mTO6HUJgfGE0PmIu2E10RuhCw= 113 | google.golang.org/genproto v0.0.0-20170523043604-d80a6e20e776/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 114 | google.golang.org/grpc v1.12.0 h1:Mm8atZtkT+P6R43n/dqNDWkPPu5BwRVu/1rJnJCeZH8= 115 | google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 116 | gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= 117 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 118 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 119 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 120 | gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= 121 | gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= 122 | gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= 123 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 124 | gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= 125 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 126 | gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 127 | -------------------------------------------------------------------------------- /gocker2llb.go: -------------------------------------------------------------------------------- 1 | package gockerfile 2 | 3 | import ( 4 | "github.com/moby/buildkit/client/llb" 5 | "github.com/moby/buildkit/util/system" 6 | "github.com/po3rin/gockerfile/config" 7 | ) 8 | 9 | // Gocker2LLB converts gockerfile yml to LLB. 10 | func Gocker2LLB(c *config.Config) (llb.State, *Image, error) { 11 | state := buildkit(c) 12 | imgCfg := NewImageConfig() 13 | return state, imgCfg, nil 14 | } 15 | 16 | func goBuildBase() llb.State { 17 | goAlpine := llb.Image("docker.io/library/golang:1.12-alpine") 18 | return goAlpine. 19 | AddEnv("PATH", "/usr/local/go/bin:"+system.DefaultPathEnv). 20 | AddEnv("GO111MODULE", "on"). 21 | Run(llb.Shlex("apk add --no-cache git")). 22 | Root() 23 | } 24 | 25 | func goRepo(s llb.State, repo, ref string, g ...llb.GitOption) func(ro ...llb.RunOption) llb.State { 26 | dir := "/go/src/" + repo 27 | return func(ro ...llb.RunOption) llb.State { 28 | es := s.Dir(dir).Run(ro...) 29 | es.AddMount(dir, llb.Git(repo, ref, g...)) 30 | return es.AddMount(dir+"/bin", llb.Scratch()) 31 | } 32 | } 33 | 34 | func buildkit(c *config.Config) llb.State { 35 | builder := goRepo(goBuildBase(), c.Repo, c.Ver) 36 | built := builder(llb.Shlex("go build -o ./bin/server " + c.Path)) 37 | r := llb.Image("docker.io/library/alpine:latest").With( 38 | copyAll(built, "/bin"), 39 | ) 40 | return r 41 | } 42 | 43 | func copyAll(src llb.State, destPath string) llb.StateOption { 44 | return copyFrom(src, "/.", destPath) 45 | } 46 | 47 | // copyFrom has similar semantics as `COPY --from` 48 | func copyFrom(src llb.State, srcPath, destPath string) llb.StateOption { 49 | return func(s llb.State) llb.State { 50 | return copy(src, srcPath, s, destPath) 51 | } 52 | } 53 | 54 | func copy(src llb.State, srcPath string, dest llb.State, destPath string) llb.State { 55 | cpImage := llb.Image("docker.io/library/alpine:latest") 56 | cp := cpImage.Run(llb.Shlexf("cp -a /src%s /dest%s", srcPath, destPath)) 57 | cp.AddMount("/src", src) 58 | return cp.AddMount("/dest", dest) 59 | } 60 | -------------------------------------------------------------------------------- /goreleaser.yml: -------------------------------------------------------------------------------- 1 | builds: 2 | - main: cmd/gocker/main.go 3 | binary: gocker 4 | goos: 5 | - windows 6 | - darwin 7 | - linux 8 | goarch: 9 | - amd64 10 | release: 11 | github: 12 | owner: po3rin 13 | name: gocker 14 | -------------------------------------------------------------------------------- /image.go: -------------------------------------------------------------------------------- 1 | package gockerfile 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/docker/docker/api/types/strslice" 7 | "github.com/moby/buildkit/util/system" 8 | 9 | specs "github.com/opencontainers/image-spec/specs-go/v1" 10 | ) 11 | 12 | type Image struct { 13 | specs.Image 14 | 15 | // Config defines the execution parameters which should be used as a base when running a container using the image. 16 | Config ImageConfig `json:"config,omitempty"` 17 | } 18 | 19 | // ImageConfig is a docker compatible config for an image 20 | type ImageConfig struct { 21 | specs.ImageConfig 22 | 23 | Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy 24 | ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) 25 | 26 | // NetworkDisabled bool `json:",omitempty"` // Is network disabled 27 | // MacAddress string `json:",omitempty"` // Mac Address of the container 28 | OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile 29 | StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container 30 | Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT 31 | } 32 | 33 | // HealthConfig holds configuration settings for the HEALTHCHECK feature. 34 | type HealthConfig struct { 35 | // Test is the test to perform to check that the container is healthy. 36 | // An empty slice means to inherit the default. 37 | // The options are: 38 | // {} : inherit healthcheck 39 | // {"NONE"} : disable healthcheck 40 | // {"CMD", args...} : exec arguments directly 41 | // {"CMD-SHELL", command} : run command with system's default shell 42 | Test []string `json:",omitempty"` 43 | 44 | // Zero means to inherit. Durations are expressed as integer nanoseconds. 45 | Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. 46 | Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. 47 | StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down. 48 | 49 | // Retries is the number of consecutive failures needed to consider a container as unhealthy. 50 | // Zero means inherit. 51 | Retries int `json:",omitempty"` 52 | } 53 | 54 | // NewImageConfig init image config. 55 | func NewImageConfig() *Image { 56 | img := emptyImage() 57 | img.Config.Cmd = []string{"/bin/server"} 58 | return img 59 | } 60 | 61 | func emptyImage() *Image { 62 | img := &Image{ 63 | Image: specs.Image{ 64 | Architecture: "amd64", 65 | OS: "linux", 66 | }, 67 | } 68 | img.RootFS.Type = "layers" 69 | img.Config.WorkingDir = "/" 70 | img.Config.Env = []string{"PATH=" + system.DefaultPathEnv} 71 | return img 72 | } 73 | --------------------------------------------------------------------------------