Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Docker Build
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
infra
Docker Build
Commits
b2ed622c
Commit
b2ed622c
authored
1 month ago
by
Jonas Leder
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
f3bbe8fa
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
switch to buildkit
Pipeline
#53863
passed
1 month ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
helper/helper.go
+0
-42
0 additions, 42 deletions
helper/helper.go
helper/main.go
+1
-7
1 addition, 7 deletions
helper/main.go
with
1 addition
and
49 deletions
helper/helper.go
+
0
−
42
View file @
b2ed622c
package
main
import
(
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
)
...
...
@@ -49,46 +47,6 @@ func getArchitectures() string {
return
strings
.
Join
(
prefixed
,
","
)
}
func
getSingleArchImageName
()
string
{
if
os
.
Getenv
(
"SINGLEARCH_IMAGE_NAME"
)
==
""
{
return
"single-arch"
}
return
os
.
Getenv
(
"SINGLEARCH_IMAGE_NAME"
)
}
func
getImageDigest
()
(
string
,
error
)
{
filePath
:=
"./image.txt"
content
,
err
:=
os
.
ReadFile
(
filePath
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to read file: %w"
,
err
)
}
err
=
os
.
Remove
(
filePath
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to delete file: %w"
,
err
)
}
return
strings
.
TrimSpace
(
string
(
content
)),
nil
}
func
getManifestDigest
()
(
string
,
error
)
{
filePath
:=
"./manifest-digest.txt"
content
,
err
:=
os
.
ReadFile
(
filePath
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to read file: %w"
,
err
)
}
err
=
os
.
Remove
(
filePath
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to delete file: %w"
,
err
)
}
re
:=
regexp
.
MustCompile
(
`sha256:[a-f0-9]{64}`
)
match
:=
re
.
FindString
(
string
(
content
))
return
match
,
nil
}
func
getAdditionalArgs
()
string
{
return
os
.
Getenv
(
"BUILDKIT_ADDITIONAL_ARGS"
)
}
This diff is collapsed.
Click to expand it.
helper/main.go
+
1
−
7
View file @
b2ed622c
...
...
@@ -15,7 +15,7 @@ func main() {
writeManifestDigest
()
}
func
buildImage
()
string
{
func
buildImage
()
{
buildCmd
:=
fmt
.
Sprintf
(
"buildctl --addr unix:///run/user/1000/buildkit/buildkitd.sock build --frontend=dockerfile.v0 --opt platform=%s --local context=
\"
$(pwd)
\"
--local dockerfile=%s --output type=image,name=%s:%s,push=true --metadata-file /tmp/build-metadata.json %s"
,
getArchitectures
(),
getDockerfilePath
(),
...
...
@@ -24,12 +24,6 @@ func buildImage() string {
getAdditionalArgs
())
fmt
.
Println
(
"Assembled build command: "
,
buildCmd
)
executeCmd
(
buildCmd
)
imageDigest
,
err
:=
getImageDigest
()
if
err
!=
nil
{
fmt
.
Println
(
"Failed to get image digest for AMD64 platform"
)
os
.
Exit
(
1
)
}
return
imageDigest
}
func
startupServices
()
{
...
...
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