Skip to content

Commit 28f3160

Browse files
committed
dockerfile changes
1 parent 4ef5be3 commit 28f3160

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

pkg/agentfs/examples/node.Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ COPY . .
3838
# Build the project
3939
RUN pnpm exec tsc
4040

41-
# Remove development-only dependencies to reduce the runtime image size
42-
RUN pnpm prune --prod
43-
44-
# Pre-download any ML models or files the agent needs
45-
# This ensures the container is ready to run immediately without downloading
46-
# dependencies at runtime, which improves startup time and reliability
47-
RUN pnpm exec node dist/agent.js download-files
48-
4941
# Create a non-privileged user that the app will run under
5042
# See https://docs.docker.com/develop/develop-images/dockerfile_best_practices/#user
5143
ARG UID=10001
@@ -61,6 +53,16 @@ RUN adduser \
6153
RUN chown -R appuser:appuser /app
6254
USER appuser
6355

56+
# Pre-download any ML models or files the agent needs
57+
# This ensures the container is ready to run immediately without downloading
58+
# dependencies at runtime, which improves startup time and reliability
59+
RUN pnpm exec node dist/agent.js download-files
60+
61+
# Remove development-only dependencies to reduce the runtime image size
62+
USER root
63+
RUN pnpm prune --prod && chown -R appuser:appuser /app
64+
USER appuser
65+
6466
# Set Node.js to production mode
6567
ENV NODE_ENV=production
6668

pkg/agentfs/tar.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"net/http"
2424
"os"
25+
pathpkg "path"
2526
"path/filepath"
2627
"strings"
2728

@@ -42,7 +43,6 @@ var (
4243
}
4344

4445
ignoreFilePatterns = []string{
45-
".gitignore",
4646
".dockerignore",
4747
}
4848
)
@@ -61,8 +61,17 @@ func UploadTarball(directory string, presignedUrl string, excludeFiles []string)
6161
}
6262
}
6363

64-
for i, exclude := range excludeFiles {
65-
excludeFiles[i] = strings.TrimSpace(exclude)
64+
// Normalize and filter ignore patterns
65+
{
66+
filtered := make([]string, 0, len(excludeFiles))
67+
for _, exclude := range excludeFiles {
68+
exclude = strings.TrimSpace(exclude)
69+
if exclude == "" || strings.HasPrefix(exclude, "#") {
70+
continue
71+
}
72+
filtered = append(filtered, filepath.ToSlash(exclude))
73+
}
74+
excludeFiles = filtered
6675
}
6776

6877
var totalSize int64
@@ -75,17 +84,19 @@ func UploadTarball(directory string, presignedUrl string, excludeFiles []string)
7584
if err != nil {
7685
return nil
7786
}
87+
// Use forward slashes inside tar archives regardless of OS
88+
relPath = filepath.ToSlash(relPath)
7889

7990
for _, exclude := range excludeFiles {
8091
if exclude == "" || strings.Contains(exclude, "Dockerfile") {
8192
continue
8293
}
8394
if info.IsDir() {
84-
if strings.HasPrefix(relPath, exclude+"/") || strings.HasPrefix(relPath, exclude) {
95+
if strings.HasPrefix(relPath, exclude+"/") || relPath == exclude {
8596
return filepath.SkipDir
8697
}
8798
}
88-
matched, err := filepath.Match(exclude, relPath)
99+
matched, err := pathpkg.Match(exclude, relPath)
89100
if err != nil {
90101
return nil
91102
}
@@ -132,20 +143,22 @@ func UploadTarball(directory string, presignedUrl string, excludeFiles []string)
132143
if err != nil {
133144
return fmt.Errorf("failed to calculate relative path for %s: %w", path, err)
134145
}
146+
// Normalize to forward slashes for tar header names and matching
147+
relPath = filepath.ToSlash(relPath)
135148

136149
for _, exclude := range excludeFiles {
137150
if exclude == "" || strings.Contains(exclude, "Dockerfile") {
138151
continue
139152
}
140153

141154
if info.IsDir() {
142-
if strings.HasPrefix(relPath, exclude+"/") || strings.HasPrefix(relPath, exclude) {
155+
if strings.HasPrefix(relPath, exclude+"/") || relPath == exclude {
143156
logger.Debugw("excluding directory from tarball", "path", path)
144157
return filepath.SkipDir
145158
}
146159
}
147160

148-
matched, err := filepath.Match(exclude, relPath)
161+
matched, err := pathpkg.Match(exclude, relPath)
149162
if err != nil {
150163
return nil
151164
}

0 commit comments

Comments
 (0)