Skip to content

Commit

Permalink
feat(dockerfile): container image
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikbin committed Feb 9, 2022
1 parent f70cd95 commit 40446d1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ RUN --mount=type=bind,source=.,target=/src,rw \
--snapshot="no" \
--post-hooks="sh -c 'upx -v --ultra-brute --best -o /usr/local/bin/{{ .ProjectName }}{{ .Ext }} || true'"

## standard
FROM scratch AS standard
COPY --from=bin /usr/local/bin/zipper /usr/local/bin/zipper
ENTRYPOINT [ "/usr/local/bin/zipper" ]

## Slim
FROM scratch AS slim
COPY --from=bin-slim /usr/local/bin/zipper-slim /usr/local/bin/zipper
ENTRYPOINT [ "/usr/local/bin/zipper" ]

## get binary out
### non slim binary
FROM scratch AS artifact
Expand Down
50 changes: 25 additions & 25 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ target "_slim" {
tags = TAGS_SLIM
}

target "_fat" {
target = "fat"
target "_standard" {
target = "standard"
tags = TAGS
}

Expand Down Expand Up @@ -104,7 +104,7 @@ target "bin-platform" {
}

group "default" {
targets = ["artifact"]
targets = ["image"]
}

# test
Expand All @@ -113,31 +113,31 @@ target "test" {
target = "test"
}

# # Creating fat container image for local docker
# target "image" {
# inherits = ["_common", "_fat", "_labels"]
# output = ["type=docker"]
# }
# Creating standard container image for local docker
target "image" {
inherits = ["_common", "_standard", "_labels"]
output = ["type=docker"]
}

# # Creating slim container image for local docker
# target "image-slim" {
# inherits = ["_common", "_slim", "_labels"]
# output = ["type=docker"]
# }
# Creating slim container image for local docker
target "image-slim" {
inherits = ["_common", "_slim", "_labels"]
output = ["type=docker"]
}

# # Creating fat container image for all platforms
# target "image-all" {
# inherits = ["_common", "image-platform", "_fat", "_labels"]
# target = "fat"
# }
# Creating standard container image for all platforms
target "image-all" {
inherits = ["_common", "image-platform", "_standard", "_labels"]
target = "standard"
}

# # Creating slim container image for all platforms
# target "image-all-slim" {
# inherits = ["_common", "image-platform", "_slim", "_labels"]
# target = "slim"
# }
# Creating slim container image for all platforms
target "image-all-slim" {
inherits = ["_common", "image-platform", "_slim", "_labels"]
target = "slim"
}

# Creating all fat artifact for all platforms
# Creating all standard artifact for all platforms
target "artifact" {
inherits = ["_common", "artifacs"]
target = "artifact"
Expand All @@ -151,6 +151,6 @@ target "artifact-slim" {

# Creating all full, slim artifact for all platforms
target "artifact-all" {
inherits = ["artifact-all", "artifacs", "bin-platform", ]
inherits = ["artifact-all", "artifacs", "bin-platform"]
target = "artifact-all"
}

0 comments on commit 40446d1

Please sign in to comment.