Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
00d3ee42
Commit
00d3ee42
authored
Jan 06, 2014
by
Matthew McKeen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docker-import: finish up Dockerfile provisioning, Add TODO for next section #774
parent
208b330b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
24 deletions
+63
-24
post-processor/docker-import/post-processor.go
post-processor/docker-import/post-processor.go
+63
-24
No files found.
post-processor/docker-import/post-processor.go
View file @
00d3ee42
...
@@ -67,6 +67,8 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -67,6 +67,8 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
id
:=
artifact
.
Id
()
id
:=
artifact
.
Id
()
ui
.
Say
(
"Importing image: "
+
id
)
ui
.
Say
(
"Importing image: "
+
id
)
// TODO Set artifact ID so that docker-push can use it
if
p
.
config
.
Tag
==
""
{
if
p
.
config
.
Tag
==
""
{
cmd
:=
exec
.
Command
(
"docker"
,
cmd
:=
exec
.
Command
(
"docker"
,
...
@@ -142,39 +144,76 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -142,39 +144,76 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
// Process Dockerfile if provided
// Process Dockerfile if provided
if
p
.
config
.
Dockerfile
!=
""
{
if
p
.
config
.
Dockerfile
!=
""
{
cmd
:=
exec
.
Command
(
"docker"
,
"build"
,
id
)
if
p
.
config
.
Tag
!=
""
{
stdin
,
err
:=
cmd
.
StdinPipe
(
)
cmd
:=
exec
.
Command
(
"docker"
,
"build"
,
"-t="
+
p
.
config
.
Repository
+
":"
+
p
.
config
.
Tag
,
"-"
)
if
err
!=
nil
{
stdin
,
err
:=
cmd
.
StdinPipe
()
return
nil
,
false
,
err
}
// open Dockerfile
if
err
!=
nil
{
file
,
err
:=
os
.
Open
(
p
.
config
.
Dockerfile
)
return
nil
,
false
,
err
}
if
err
!=
nil
{
// open Dockerfile
ui
.
Say
(
"Could not open Dockerfile: "
+
p
.
config
.
Dockerfile
)
file
,
err
:=
os
.
Open
(
p
.
config
.
Dockerfile
)
return
nil
,
false
,
err
}
defer
file
.
Close
()
if
err
!=
nil
{
ui
.
Say
(
"Could not open Dockerfile: "
+
p
.
config
.
Dockerfile
)
return
nil
,
false
,
err
}
if
err
:=
cmd
.
Start
();
err
!=
nil
{
ui
.
Say
(
id
)
ui
.
Say
(
"Failed to build image: "
+
id
)
return
nil
,
false
,
err
}
go
func
()
{
defer
file
.
Close
()
io
.
Copy
(
stdin
,
file
)
// close stdin so that program will exit
stdin
.
Close
()
}()
cmd
.
Wait
()
if
err
:=
cmd
.
Start
();
err
!=
nil
{
ui
.
Say
(
"Failed to build image: "
+
id
)
return
nil
,
false
,
err
}
go
func
()
{
io
.
Copy
(
stdin
,
file
)
// close stdin so that program will exit
stdin
.
Close
()
}()
cmd
.
Wait
()
}
else
{
cmd
:=
exec
.
Command
(
"docker"
,
"build"
,
"-t="
+
p
.
config
.
Repository
,
"-"
)
stdin
,
err
:=
cmd
.
StdinPipe
()
if
err
!=
nil
{
return
nil
,
false
,
err
}
// TODO make sure we re-tag instead of create new image
// open Dockerfile
// automatically use previous image as base of new image
file
,
err
:=
os
.
Open
(
p
.
config
.
Dockerfile
)
if
err
!=
nil
{
ui
.
Say
(
"Could not open Dockerfile: "
+
p
.
config
.
Dockerfile
)
return
nil
,
false
,
err
}
ui
.
Say
(
id
)
defer
file
.
Close
()
if
err
:=
cmd
.
Start
();
err
!=
nil
{
ui
.
Say
(
"Failed to build image: "
+
id
)
return
nil
,
false
,
err
}
go
func
()
{
io
.
Copy
(
stdin
,
file
)
// close stdin so that program will exit
stdin
.
Close
()
}()
cmd
.
Wait
()
}
}
}
return
nil
,
false
,
nil
return
nil
,
false
,
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment