Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
moby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
emulab
moby
Commits
ae0d5550
Commit
ae0d5550
authored
11 years ago
by
Guillaume J. Charmes
Browse files
Options
Downloads
Patches
Plain Diff
Fix autorun issue within docker build
parent
92939569
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildfile.go
+20
-8
20 additions, 8 deletions
buildfile.go
with
20 additions
and
8 deletions
buildfile.go
+
20
−
8
View file @
ae0d5550
...
...
@@ -95,10 +95,12 @@ func (b *buildFile) CmdRun(args string) error {
return
err
}
cmd
,
env
:=
b
.
config
.
Cmd
,
b
.
config
.
Env
cmd
:=
b
.
config
.
Cmd
b
.
config
.
Cmd
=
nil
MergeConfig
(
b
.
config
,
config
)
utils
.
Debugf
(
"Commang to be executed: %v"
,
b
.
config
.
Cmd
)
if
cache
,
err
:=
b
.
srv
.
ImageGetCached
(
b
.
image
,
config
);
err
!=
nil
{
return
err
}
else
if
cache
!=
nil
{
...
...
@@ -111,8 +113,11 @@ func (b *buildFile) CmdRun(args string) error {
if
err
!=
nil
{
return
err
}
b
.
config
.
Cmd
,
b
.
config
.
Env
=
cmd
,
env
return
b
.
commit
(
cid
)
if
err
:=
b
.
commit
(
cid
,
cmd
);
err
!=
nil
{
return
err
}
b
.
config
.
Cmd
=
cmd
return
nil
}
func
(
b
*
buildFile
)
CmdEnv
(
args
string
)
error
{
...
...
@@ -153,6 +158,7 @@ func (b *buildFile) CmdExpose(args string) error {
}
func
(
b
*
buildFile
)
CmdInsert
(
args
string
)
error
{
if
b
.
image
==
""
{
return
fmt
.
Errorf
(
"Please provide a source image with `from` prior to insert"
)
}
...
...
@@ -169,6 +175,7 @@ func (b *buildFile) CmdInsert(args string) error {
}
defer
file
.
Body
.
Close
()
cmd
:=
b
.
config
.
Cmd
b
.
config
.
Cmd
=
[]
string
{
"echo"
,
"INSERT"
,
sourceUrl
,
"in"
,
destPath
}
cid
,
err
:=
b
.
run
()
if
err
!=
nil
{
...
...
@@ -184,7 +191,7 @@ func (b *buildFile) CmdInsert(args string) error {
return
err
}
return
b
.
commit
(
cid
)
return
b
.
commit
(
cid
,
cmd
)
}
func
(
b
*
buildFile
)
CmdAdd
(
args
string
)
error
{
...
...
@@ -198,6 +205,7 @@ func (b *buildFile) CmdAdd(args string) error {
orig
:=
strings
.
Trim
(
tmp
[
0
],
" "
)
dest
:=
strings
.
Trim
(
tmp
[
1
],
" "
)
cmd
:=
b
.
config
.
Cmd
b
.
config
.
Cmd
=
[]
string
{
"echo"
,
"PUSH"
,
orig
,
"in"
,
dest
}
cid
,
err
:=
b
.
run
()
if
err
!=
nil
{
...
...
@@ -236,7 +244,7 @@ func (b *buildFile) CmdAdd(args string) error {
}
}
return
b
.
commit
(
cid
)
return
b
.
commit
(
cid
,
cmd
)
}
func
(
b
*
buildFile
)
run
()
(
string
,
error
)
{
...
...
@@ -265,7 +273,8 @@ func (b *buildFile) run() (string, error) {
return
c
.
Id
,
nil
}
func
(
b
*
buildFile
)
commit
(
id
string
)
error
{
// Commit the container <id> with the autorun command <autoCmd>
func
(
b
*
buildFile
)
commit
(
id
string
,
autoCmd
[]
string
)
error
{
if
b
.
image
==
""
{
return
fmt
.
Errorf
(
"Please provide a source image with `from` prior to commit"
)
}
...
...
@@ -286,8 +295,11 @@ func (b *buildFile) commit(id string) error {
return
fmt
.
Errorf
(
"An error occured while creating the container"
)
}
// Note: Actually copy the struct
autoConfig
:=
*
b
.
config
autoConfig
.
Cmd
=
autoCmd
// Commit the container
image
,
err
:=
b
.
builder
.
Commit
(
container
,
""
,
""
,
""
,
b
.
maintainer
,
nil
)
image
,
err
:=
b
.
builder
.
Commit
(
container
,
""
,
""
,
""
,
b
.
maintainer
,
&
autoConfig
)
if
err
!=
nil
{
return
err
}
...
...
@@ -347,7 +359,7 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
fmt
.
Fprintf
(
b
.
out
,
"===> %v
\n
"
,
b
.
image
)
}
if
b
.
needCommit
{
if
err
:=
b
.
commit
(
""
);
err
!=
nil
{
if
err
:=
b
.
commit
(
""
,
nil
);
err
!=
nil
{
return
""
,
err
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment