Skip to content

Commit 90d2c61

Browse files
authored
Merge pull request #2 from rapidfort/v1.0.10
Add context sub path support
2 parents 9a80cb4 + 481a105 commit 90d2c61

File tree

5 files changed

+38
-32
lines changed

5 files changed

+38
-32
lines changed

README.md

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,12 @@ A: Smithy uses user namespaces for true rootless operation, while Kaniko runs as
22502250

22512251
A: Yes! Smithy can run as a standard container:
22522252
```bash
2253-
docker run --security-opt seccomp=unconfined --user 1000:1000 \
2253+
docker run \
2254+
--cap-drop ALL \
2255+
--cap-add SETUID \
2256+
--cap-add SETGID \
2257+
--security-opt seccomp=unconfined \
2258+
--security-opt apparmor=unconfined \
22542259
-v $(pwd):/workspace \
22552260
ghcr.io/rapidfort/smithy:latest \
22562261
--context=/workspace --destination=registry/image:tag
@@ -2321,37 +2326,6 @@ initContainers:
23212326
securityContext:
23222327
runAsUser: 0
23232328
```
2324-
2325-
---
2326-
2327-
## License
2328-
2329-
Smithy is licensed under the [MIT License](LICENSE).
2330-
2331-
```
2332-
MIT License
2333-
2334-
Copyright (c) 2025 RapidFort Inc.
2335-
2336-
Permission is hereby granted, free of charge, to any person obtaining a copy
2337-
of this software and associated documentation files (the "Software"), to deal
2338-
in the Software without restriction, including without limitation the rights
2339-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2340-
copies of the Software, and to permit persons to whom the Software is
2341-
furnished to do so, subject to the following conditions:
2342-
2343-
The above copyright notice and this permission notice shall be included in all
2344-
copies or substantial portions of the Software.
2345-
2346-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2347-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2348-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2349-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2350-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2351-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2352-
SOFTWARE.
2353-
```
2354-
23552329
---
23562330
23572331
## Acknowledgments

src/cmd/smithy/args.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ func parseArgs(args []string) *Config {
6161
config.Context = args[i]
6262
}
6363

64+
case "--context-sub-path":
65+
if value != "" {
66+
config.SubContext = value
67+
} else if i+1 < len(args) {
68+
i++
69+
config.SubContext = args[i]
70+
}
6471
case "-d", "--destination":
6572
dest := value
6673
if dest == "" && i+1 < len(args) {

src/cmd/smithy/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type Config struct {
55
// Core build arguments
66
Dockerfile string
77
Context string
8+
SubContext string
89
Destination []string
910

1011
// Cache configuration

src/cmd/smithy/help.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func printHelp() {
1313
fmt.Println()
1414
fmt.Println("CORE OPTIONS:")
1515
fmt.Println(" -c, --context PATH Build context directory or Git URL")
16+
fmt.Println(" --context-sub-path PATH Sub-directory within build context")
1617
fmt.Println(" -f, --dockerfile PATH Path to Dockerfile (default: Dockerfile)")
1718
fmt.Println(" -d, --destination IMAGE Destination image with tag (repeatable)")
1819
fmt.Println(" -t, --target STAGE Target stage in multi-stage Dockerfile")
@@ -61,6 +62,12 @@ func printHelp() {
6162
fmt.Println(" --git-branch=main \\")
6263
fmt.Println(" --destination=registry.io/myapp:v1.0.0")
6364
fmt.Println()
65+
fmt.Println(" # Build from sub-directory in Git repository")
66+
fmt.Println(" smithy --context=https://github.com/org/repo.git \\")
67+
fmt.Println(" --context-sub-path=docker/app \\")
68+
fmt.Println(" --dockerfile=Dockerfile \\")
69+
fmt.Println(" --destination=registry.io/myapp:latest")
70+
fmt.Println()
6471
fmt.Println(" # Build with custom arguments and labels")
6572
fmt.Println(" smithy --context=. \\")
6673
fmt.Println(" --destination=registry.io/myapp:latest \\")

src/cmd/smithy/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,25 @@ func main() {
102102
if err != nil {
103103
logger.Fatal("Failed to prepare build context: %v", err)
104104
}
105+
105106
defer ctx.Cleanup()
106107

108+
if config.SubContext != "" {
109+
logger.Debug("Applying sub-context path: %s", config.SubContext)
110+
111+
// Join the sub-path to the prepared context
112+
newContextPath := filepath.Join(ctx.Path, config.SubContext)
113+
114+
// Verify the sub-context exists
115+
if _, err := os.Stat(newContextPath); os.IsNotExist(err) {
116+
logger.Fatal("Sub-context path does not exist: %s (full path: %s)", config.SubContext, newContextPath)
117+
}
118+
119+
// Update the context path
120+
ctx.Path = newContextPath
121+
logger.Info("Using sub-context: %s", ctx.Path)
122+
}
123+
107124
// Execute build
108125
buildConfig := build.Config{
109126
Dockerfile: config.Dockerfile,

0 commit comments

Comments
 (0)