Skip to content

Commit 7a7357d

Browse files
committed
LCOW: Implemented support for docker cp + build
This enables docker cp and ADD/COPY docker build support for LCOW. Originally, the graphdriver.Get() interface returned a local path to the container root filesystem. This does not work for LCOW, so the Get() method now returns an interface that LCOW implements to support copying to and from the container. Signed-off-by: Akash Gupta <[email protected]>
1 parent ba13c17 commit 7a7357d

85 files changed

Lines changed: 3304 additions & 954 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/server/httputils/form.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package httputils
22

33
import (
44
"net/http"
5-
"path/filepath"
65
"strconv"
76
"strings"
87
)
@@ -69,8 +68,7 @@ func ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions,
6968
if name == "" {
7069
return ArchiveOptions{}, badParameterError{"name"}
7170
}
72-
73-
path := filepath.FromSlash(r.Form.Get("path"))
71+
path := r.Form.Get("path")
7472
if path == "" {
7573
return ArchiveOptions{}, badParameterError{"path"}
7674
}

builder/builder.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/docker/docker/api/types/container"
1313
containerpkg "github.com/docker/docker/container"
1414
"github.com/docker/docker/layer"
15+
"github.com/docker/docker/pkg/containerfs"
1516
"golang.org/x/net/context"
1617
)
1718

@@ -24,7 +25,7 @@ const (
2425
// instructions in the builder.
2526
type Source interface {
2627
// Root returns root path for accessing source
27-
Root() string
28+
Root() containerfs.ContainerFS
2829
// Close allows to signal that the filesystem tree won't be used anymore.
2930
// For Context implementations using a temporary directory, it is recommended to
3031
// delete the temporary directory in Close().
@@ -99,7 +100,7 @@ type Image interface {
99100
// ReleaseableLayer is an image layer that can be mounted and released
100101
type ReleaseableLayer interface {
101102
Release() error
102-
Mount() (string, error)
103+
Mount() (containerfs.ContainerFS, error)
103104
Commit(platform string) (ReleaseableLayer, error)
104105
DiffID() layer.DiffID
105106
}

builder/dockerfile/builder.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import (
1717
"github.com/docker/docker/builder/dockerfile/parser"
1818
"github.com/docker/docker/builder/fscache"
1919
"github.com/docker/docker/builder/remotecontext"
20-
"github.com/docker/docker/pkg/archive"
21-
"github.com/docker/docker/pkg/chrootarchive"
2220
"github.com/docker/docker/pkg/idtools"
2321
"github.com/docker/docker/pkg/streamformatter"
2422
"github.com/docker/docker/pkg/stringid"
@@ -50,21 +48,21 @@ type SessionGetter interface {
5048

5149
// BuildManager is shared across all Builder objects
5250
type BuildManager struct {
53-
archiver *archive.Archiver
54-
backend builder.Backend
55-
pathCache pathCache // TODO: make this persistent
56-
sg SessionGetter
57-
fsCache *fscache.FSCache
51+
idMappings *idtools.IDMappings
52+
backend builder.Backend
53+
pathCache pathCache // TODO: make this persistent
54+
sg SessionGetter
55+
fsCache *fscache.FSCache
5856
}
5957

6058
// NewBuildManager creates a BuildManager
6159
func NewBuildManager(b builder.Backend, sg SessionGetter, fsCache *fscache.FSCache, idMappings *idtools.IDMappings) (*BuildManager, error) {
6260
bm := &BuildManager{
63-
backend: b,
64-
pathCache: &syncmap.Map{},
65-
sg: sg,
66-
archiver: chrootarchive.NewArchiver(idMappings),
67-
fsCache: fsCache,
61+
backend: b,
62+
pathCache: &syncmap.Map{},
63+
sg: sg,
64+
idMappings: idMappings,
65+
fsCache: fsCache,
6866
}
6967
if err := fsCache.RegisterTransport(remotecontext.ClientSessionRemote, NewClientSessionTransport()); err != nil {
7068
return nil, err
@@ -114,7 +112,7 @@ func (bm *BuildManager) Build(ctx context.Context, config backend.BuildConfig) (
114112
ProgressWriter: config.ProgressWriter,
115113
Backend: bm.backend,
116114
PathCache: bm.pathCache,
117-
Archiver: bm.archiver,
115+
IDMappings: bm.idMappings,
118116
Platform: dockerfile.Platform,
119117
}
120118

@@ -160,7 +158,7 @@ type builderOptions struct {
160158
Backend builder.Backend
161159
ProgressWriter backend.ProgressWriter
162160
PathCache pathCache
163-
Archiver *archive.Archiver
161+
IDMappings *idtools.IDMappings
164162
Platform string
165163
}
166164

@@ -177,7 +175,7 @@ type Builder struct {
177175
docker builder.Backend
178176
clientCtx context.Context
179177

180-
archiver *archive.Archiver
178+
idMappings *idtools.IDMappings
181179
buildStages *buildStages
182180
disableCommit bool
183181
buildArgs *buildArgs
@@ -219,7 +217,7 @@ func newBuilder(clientCtx context.Context, options builderOptions) *Builder {
219217
Aux: options.ProgressWriter.AuxFormatter,
220218
Output: options.ProgressWriter.Output,
221219
docker: options.Backend,
222-
archiver: options.Archiver,
220+
idMappings: options.IDMappings,
223221
buildArgs: newBuildArgs(config.BuildArgs),
224222
buildStages: newBuildStages(),
225223
imageSources: newImageSources(clientCtx, options),

0 commit comments

Comments
 (0)