Commit Graph

42 Commits

Author SHA1 Message Date
Ian Campbell
9f44acf8e3 Generate intermediate image into a temp file
All of the `output*` functions took a `[]byte` and immediately wrapped it in a
`bytes.Buffer` to produce an `io.Reader`. Make them take an `io.Reader` instead
and satisfy this further up the call chain by directing `moby.Build` to output
to a temp file instead of another `bytes.Buffer`.

In my test case (building kube master image) this reduces Maximum RSS (as
measured by time(1)) from 6.7G to 2.8G and overall allocations from 9.7G to
5.3G. When building a tar (output to /dev/null) the Maximum RSS fell slightly
from 2.2G to 2.1G. Overall allocations remained stable at around 5.3G.

Signed-off-by: Ian Campbell <ijc@docker.com>
2017-12-06 16:07:46 +00:00
Justin Cormack
e3a7739f42 Make easier to embed in LinuxKit
Split out util file in same way.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-11-20 12:04:08 +00:00
Justin Cormack
45333d2480 Update dependencies to use sirupsen not Sirupsen
That entailed a few other fixes, eg small Notary API changes.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-11-01 15:14:58 +00:00
Daniel Nephin
a224547540 Fix lint errors
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-10-17 17:30:47 -04:00
Justin Cormack
aca26f00c2 Remove the hyperkit option
We are going to phase out the LinuxKit build option, in favour of keeping Docker
or a native Linux build option for CI use cases, as it is faster. So the
hyperkit option that only worked in one very limited use case is not needed.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-10-03 15:55:02 +01:00
Justin Cormack
11b573c6fb Rename "output" to "format"
This was confusing as there is an option to output to a file as well.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-09-01 23:45:25 +01:00
Justin Cormack
3ee4fdc43a Error if there are duplicate service names
Continue to allow onboot to have duplicates as we do not run simultaneously
so that is ok (and we number them anyway), but services are run together
so we will get a runtime error if duplicated as this is the containerd/runc
id.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-07-10 14:50:04 +01:00
Justin Cormack
e7ebabdb05 Split out into a small stub command line and a library
- this is pretty much the smallest change to split this out and it
  exposes a few things that can be improved later
- no change to logging yet

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-21 16:19:31 -07:00
Justin Cormack
c5cccad62e Return errors from build internal function
This makes it easier to convert to a library.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-20 17:25:16 -07:00
Justin Cormack
618dc424de Allow creation of empty files
- change to a pointer type so we can distinguish empty from unset.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-20 13:25:36 -07:00
Justin Cormack
13da5e08ea Use hyperkit to make raw disks
- enable the hyperkit option by default on MacOS
- use it for creating raw disk images

fix #68

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-15 15:10:55 -07:00
Justin Cormack
4d64a46ae9 Allow some files specified with source to be optional
See discussion in https://github.com/linuxkit/linuxkit/pull/2027

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-15 11:07:58 -07:00
Justin Cormack
d7ca674ea6 Add support to fetch yaml file with http
For example you can do
```
moby build https://raw.githubusercontent.com/linuxkit/linuxkit/master/linuxkit.yml
```

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-12 18:11:21 +02:00
Justin Cormack
1988b312d2 Allow ~ for home directory when specifying source of file
Useful when adding ssh keys

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-12 16:37:00 +02:00
Justin Cormack
796d943054 Remove absolute paths from files
tarballs should only have relative paths in.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-09 11:39:52 +01:00
Justin Cormack
83c166d3f2 Allow setting of mode in files section
Also keep track of directory creation there, so you can explicitly
set directory permissions if required, and to avoid duplicates.

We should really keep track of files created elsewhere in the build
as well as we still might create some extras, but at least you can
set the write permisisons.

We can add uid, gid support too if required...

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-08 14:44:02 +01:00
Justin Cormack
8abeffde59 Add Docker output format
This will add a Dockerfile which will build the contents into an
image and then call `tinit` to start it.

This is fairly experimental, but is a prototype for other non
LinuxKit outputs. The container will need to run as `privileged`
as `runc` needs quite a few capabilities and `containerd` needs to
mount.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-07 15:32:02 +01:00
Justin Cormack
c2806000e0 Use streaming APIs rather than buffers for building
This should lower memory usage a lot and should be faster.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-07 12:13:12 +01:00
Justin Cormack
b086231008 Allow streaming output for tar
This is a little ugly in terms of the validation now, but it is a move towards
splitting "build" and "package".

The "tar" output (and soon others) can output direct to a file or to stdout.
Obviously you can only build a single output format like this.

The LinuxKit output formats that build disk images cannot stream as they
have to build whole images. These allow multiple outputs.

In future we will probably change to
```
moby build | moby package
```

or similar, but that is a bit ugly, so currently have a compromise where
there are essentially two output types.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-06 14:50:28 +01:00
Justin Cormack
181c66d42c Merge pull request #70 from justincormack/multiple-yaml
Allow specification of multiple yaml files for a single build
2017-06-05 16:39:31 +01:00
Justin Cormack
54e58f2808 Allow specification of multiple yaml files for a single build
Each section will be appended in order of the CLI, other then
kernel where last specified one wins.

This is useful if you eg want to have a base version for (say)
AWS and GCP and then add your own image on top.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-04 17:50:13 +01:00
Riyaz Faizullabhoy
6c6190172c trust: include trust configuration in docker inspect for OCI config
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2017-06-02 15:18:55 -07:00
Riyaz Faizullabhoy
6221552204 trust: check local image cache to not pull every time
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2017-06-02 13:03:47 -07:00
Justin Cormack
249bbc56ed Use linuxkit to build qcow2 and raw image disks, rather than docker containers with libguestfs
- does not require docker if user has qemu natively, will still fall back to docker
- allow specifying size for fixed size disk images
- add a raw disk output format
- more dogfooding
- marginally slower, but can be improved later

The images used to do the build are cached to make the process quicker.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-06-02 16:33:06 +01:00
Justin Cormack
cde8329d2f Merge pull request #61 from FrenchBen/validate-output
Validate output before doing the work
2017-06-01 22:39:56 +01:00
Justin Cormack
edcf4d0362 Merge pull request #59 from riyazdf/trust-parse-fixes-and-tests
trust: parsing fixes and tests
2017-06-01 22:35:59 +01:00
French Ben
23856c1e46 Validate output before doing the work
Signed-off-by: French Ben <frenchben@docker.com>
2017-06-01 14:30:41 -07:00
Riyaz Faizullabhoy
99eeb981a7 trust: improve org checks to enable library official repo checks
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2017-06-01 11:20:36 -07:00
Riyaz Faizullabhoy
32f167bd9e trust: fix splitting on tags and digests and add tests
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2017-05-31 16:42:42 -07:00
Riyaz Faizullabhoy
1ecfc11160 add disable-content-trust flag for one-off build
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2017-05-31 14:51:59 -07:00
Justin Cormack
b8cdb985fd Fix build in directory
Remove unnecessary argument to buildInternal function, does not need to know the name.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-26 15:22:12 +01:00
Justin Cormack
f73558a98a Add a -dir option for location of output files
Fix #17

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-26 14:53:17 +01:00
Justin Cormack
cbbedbfc57 Remove output formats from the Yaml file, put in CLI
This removes outputs from yaml, instead you can do
```
moby build -output tar -output qcow2 file.yaml
```
or alternative syntax
```
moby build -output tar,qcow2 file.yaml
```

In future we may change this to be available in a `moby package`
step, but lets try this for now.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-26 13:00:45 +01:00
Justin Cormack
c734b47e9c Add support for override of parameters using a label
Using the label `org.mobyproject.config` will use that JSON
(or yaml, but it is very hard to get yaml into a label as newlines are
not respected) for parameters that are not explicitly set in the yaml file.

Had to change parameter definitions so override behaves as expected.

fix #16

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-18 17:48:15 +01:00
Justin Cormack
96ae98d2d5 Do not log information about empty sections
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-09 13:12:51 +01:00
Justin Cormack
e25033f70d Allow no kernel to be specified
This is needed for non LinuxKit use cases.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-09 13:03:58 +01:00
Justin Cormack
dd08b2b70a Add tar output format
Add a canonical single tarball output format. This
adds kernel and cmdline to `/boot` where LinuxKit output
formats will find them.

Make the other output formats use that as a base.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-05-08 17:19:08 +01:00
Justin Cormack
d0f867e9b2 Make sure we always pull images if create fails
`docker create` will not pull an image so we need an additional fallback.

Rework the pull and trust code so it is in one place to facilitate this.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-04-28 16:14:15 +01:00
Justin Cormack
ef017ac223 Support both kernel and bzImage for now
Also do not require `tar` to be in container, use the standard
image export code that we already have and find the files we
want.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-04-28 12:48:04 +01:00
Justin Cormack
2cd9bead88 Switch from bzImage to kernel for kernel image
This was too architecture specific previously.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-04-28 12:38:04 +01:00
Akihiro Suda
d98f23c2ba build: support reading yaml from stdin
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-04-25 10:26:34 +00:00
Justin Cormack
fa88ca8ede Move src/cmd to cmd
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-04-24 22:58:37 +01:00