status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | err = eg.Wait()
if err != nil {
return nil, fmt.Errorf("wait: %w", err)
}
ctr, err := bkcontainer.NewContainer(
context.Background(),
c.Worker,
c.SessionManager,
bksession.NewGroup(c.ID()),
ctrReq,
)
if err != nil {
return nil, err
}
c.containersMu.Lock()
defer c.containersMu.Unlock()
if c.containers == nil {
if err := ctr.Release(context.Background()); err != nil {
return nil, fmt.Errorf("release after close: %w", err)
}
return nil, errors.New("client closed")
}
c.containers[ctr] = struct{}{}
return ctr, nil
}
func (c *Client) WriteStatusesTo(ctx context.Context, ch chan *bkclient.SolveStatus) error {
return c.job.Status(ctx, ch)
}
func (c *Client) RegisterClient(clientID, clientHostname, secretToken string) error { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | c.clientMu.Lock()
defer c.clientMu.Unlock()
existingToken, ok := c.clientIDToSecretToken[clientID]
if ok {
if existingToken != secretToken {
return fmt.Errorf("client ID %q already registered with different secret token", clientID)
}
return nil
}
c.clientIDToSecretToken[clientID] = secretToken
return nil
}
func (c *Client) VerifyClient(clientID, secretToken string) error {
c.clientMu.RLock()
defer c.clientMu.RUnlock()
existingToken, ok := c.clientIDToSecretToken[clientID]
if !ok {
return fmt.Errorf("client ID %q not registered", clientID)
}
if existingToken != secretToken {
return fmt.Errorf("client ID %q registered with different secret token", clientID)
}
return nil
}
func (c *Client) CombinedResult(ctx context.Context) (*Result, error) {
c.refsMu.Lock() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | mergeInputs := make([]llb.State, 0, len(c.refs))
for r := range c.refs {
state, err := r.ToState()
if err != nil {
c.refsMu.Unlock()
return nil, err
}
mergeInputs = append(mergeInputs, state)
}
c.refsMu.Unlock()
llbdef, err := llb.Merge(mergeInputs, llb.WithCustomName("combined session result")).Marshal(ctx)
if err != nil {
return nil, err
}
return c.Solve(ctx, bkgw.SolveRequest{
Definition: llbdef.ToPB(),
})
}
func (c *Client) UpstreamCacheExport(ctx context.Context, cacheExportFuncs []ResolveCacheExporterFunc) error {
ctx, cancel, err := c.withClientCloseCancel(ctx)
if err != nil {
return err
}
defer cancel()
if len(cacheExportFuncs) == 0 {
return nil
}
bklog.G(ctx).Debugf("exporting %d caches", len(cacheExportFuncs))
combinedResult, err := c.CombinedResult(ctx)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | return err
}
cacheRes, err := ConvertToWorkerCacheResult(ctx, combinedResult)
if err != nil {
return fmt.Errorf("failed to convert result: %s", err)
}
bklog.G(ctx).Debugf("converting to solverRes")
solverRes, err := solverresult.ConvertResult(combinedResult, func(rf *ref) (bksolver.CachedResult, error) {
return rf.resultProxy.Result(ctx)
})
if err != nil {
return fmt.Errorf("failed to convert result: %s", err)
}
sessionGroup := bksession.NewGroup(c.ID())
eg, ctx := errgroup.WithContext(ctx)
for _, exporterFunc := range cacheExportFuncs {
exporterFunc := exporterFunc
eg.Go(func() error {
bklog.G(ctx).Debugf("getting exporter")
exporter, err := exporterFunc(ctx, sessionGroup)
if err != nil {
return err
}
bklog.G(ctx).Debugf("exporting cache with %T", exporter)
compressionCfg := exporter.Config().Compression
err = solverresult.EachRef(solverRes, cacheRes, func(res bksolver.CachedResult, ref bkcache.ImmutableRef) error {
bklog.G(ctx).Debugf("exporting cache for %s", ref.ID())
ctx := withDescHandlerCacheOpts(ctx, ref)
bklog.G(ctx).Debugf("calling exporter") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | _, err = res.CacheKeys()[0].Exporter.ExportTo(ctx, exporter, bksolver.CacheExportOpt{
ResolveRemotes: func(ctx context.Context, res bksolver.Result) ([]*bksolver.Remote, error) {
ref, ok := res.Sys().(*bkworker.WorkerRef)
if !ok {
return nil, fmt.Errorf("invalid result: %T", res.Sys())
}
bklog.G(ctx).Debugf("getting remotes for %s", ref.ID())
defer bklog.G(ctx).Debugf("got remotes for %s", ref.ID())
return ref.GetRemotes(ctx, true, bkcacheconfig.RefConfig{Compression: compressionCfg}, false, sessionGroup)
},
Mode: bksolver.CacheExportModeMax,
Session: sessionGroup,
CompressionOpt: &compressionCfg,
})
return err
})
if err != nil {
return err
}
bklog.G(ctx).Debugf("finalizing exporter")
defer bklog.G(ctx).Debugf("finalized exporter")
_, err = exporter.Finalize(ctx)
return err
})
}
bklog.G(ctx).Debugf("waiting for cache export")
defer bklog.G(ctx).Debugf("waited for cache export")
return eg.Wait()
}
func withDescHandlerCacheOpts(ctx context.Context, ref bkcache.ImmutableRef) context.Context { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | return bksolver.WithCacheOptGetter(ctx, func(_ bool, keys ...interface{}) map[interface{}]interface{} {
vals := make(map[interface{}]interface{})
for _, k := range keys {
if key, ok := k.(bkcache.DescHandlerKey); ok {
if handler := ref.DescHandler(digest.Digest(key)); handler != nil {
vals[k] = handler
}
}
}
return vals
})
}
func (c *Client) ListenHostToContainer(
ctx context.Context,
hostListenAddr, proto, upstream string,
) (*session.ListenResponse, func() error, error) {
ctx, cancel, err := c.withClientCloseCancel(ctx)
if err != nil {
return nil, nil, err
}
clientMetadata, err := engine.ClientMetadataFromContext(ctx)
if err != nil {
cancel()
return nil, nil, fmt.Errorf("failed to get requester session ID: %s", err)
}
clientCaller, err := c.SessionManager.Get(ctx, clientMetadata.ClientID, false)
if err != nil {
cancel()
return nil, nil, fmt.Errorf("failed to get requester session: %s", err)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | conn := clientCaller.Conn()
tunnelClient := session.NewTunnelListenerClient(conn)
listener, err := tunnelClient.Listen(ctx)
if err != nil {
cancel()
return nil, nil, fmt.Errorf("failed to listen: %s", err)
}
err = listener.Send(&session.ListenRequest{
Addr: hostListenAddr,
Protocol: proto,
})
if err != nil {
cancel()
return nil, nil, fmt.Errorf("failed to send listen request: %s", err)
}
listenRes, err := listener.Recv()
if err != nil {
cancel()
return nil, nil, fmt.Errorf("failed to receive listen response: %s", err)
}
conns := map[string]net.Conn{}
connsL := &sync.Mutex{}
sendL := &sync.Mutex{}
wg := new(sync.WaitGroup)
wg.Add(1)
go func() {
defer wg.Done()
for {
res, err := listener.Recv()
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | bklog.G(ctx).Warnf("listener recv err: %s", err)
return
}
connID := res.GetConnId()
if connID == "" {
continue
}
connsL.Lock()
conn, found := conns[connID]
connsL.Unlock()
if !found {
conn, err := c.dialer.Dial(proto, upstream)
if err != nil {
bklog.G(ctx).Warnf("failed to dial %s %s: %s", proto, upstream, err)
return
}
connsL.Lock()
conns[connID] = conn
connsL.Unlock()
wg.Add(1)
go func() {
defer wg.Done()
data := make([]byte, 32*1024)
for {
n, err := conn.Read(data)
if err != nil {
return
}
sendL.Lock()
err = listener.Send(&session.ListenRequest{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | ConnId: connID,
Data: data[:n],
})
sendL.Unlock()
if err != nil {
return
}
}
}()
}
if res.Data != nil {
_, err = conn.Write(res.Data)
if err != nil {
return
}
}
}
}()
return listenRes, func() error {
defer cancel()
sendL.Lock()
err := listener.CloseSend()
sendL.Unlock()
if err == nil {
wg.Wait()
}
return err
}, nil
}
func withOutgoingContext(ctx context.Context) context.Context { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,501 | 🐞 Logs are duplicated when a vertex is used multiple times | ### What is the issue?
This issue is only on `main`; the current release, v0.9.7, is not affected.
If you run a pipeline with a vertex that is used multiple times in the same session, the log output will be duplicated, possibly with each extra use (i.e. cache hit).
### Dagger version
main
### Steps to reproduce
Once #6456 is merged, run a function that calls another function twice; you should see duplicate logs in its `codegen` vertex.
### Log output
`main`:

`v0.9.7`:
 | https://github.com/dagger/dagger/issues/6501 | https://github.com/dagger/dagger/pull/6505 | 53179a064559cf376fa2ad7596e32bd4e4934c74 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 2024-01-26T02:30:45Z | go | 2024-01-29T11:51:30Z | engine/buildkit/client.go | md, ok := metadata.FromIncomingContext(ctx)
if ok {
ctx = metadata.NewOutgoingContext(ctx, md)
}
return ctx
}
type ContainerExecUncachedMetadata struct {
ParentClientIDs []string `json:"parentClientIDs,omitempty"`
ServerID string `json:"serverID,omitempty"`
}
func (md ContainerExecUncachedMetadata) ToPBFtpProxyVal() (string, error) {
b, err := json.Marshal(md)
if err != nil {
return "", err
}
return string(b), nil
}
func (md *ContainerExecUncachedMetadata) FromEnv(envKV string) (bool, error) {
_, val, ok := strings.Cut(envKV, "ftp_proxy=")
if !ok {
return false, nil
}
err := json.Unmarshal([]byte(val), md)
if err != nil {
return false, err
}
return true, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | package core
import (
"context"
"encoding/json"
"fmt"
"io/fs"
"os"
"path"
"path/filepath"
"sort" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | "strconv"
"strings"
"sync"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/pkg/transfer/archive"
"github.com/containerd/containerd/platforms"
"github.com/vektah/gqlparser/v2/ast"
"github.com/dagger/dagger/dagql"
"github.com/dagger/dagger/dagql/idproto"
"github.com/docker/distribution/reference"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/frontend/dockerui"
bkgw "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/leaseutil"
"github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/vito/progrock"
"github.com/dagger/dagger/core/pipeline"
"github.com/dagger/dagger/engine/buildkit"
)
var ErrContainerNoExec = errors.New("no command has been executed")
type Container struct {
Query *Query
FS *pb.Definition `json:"fs"` |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Config specs.ImageConfig `json:"cfg"`
EnabledGPUs []string `json:"enabledGPUs,omitempty"`
Mounts ContainerMounts `json:"mounts,omitempty"`
Meta *pb.Definition `json:"meta,omitempty"`
Platform Platform `json:"platform,omitempty"`
Secrets []ContainerSecret `json:"secret_env,omitempty"`
Sockets []ContainerSocket `json:"sockets,omitempty"`
ImageRef string `json:"image_ref,omitempty"`
Ports []Port `json:"ports,omitempty"`
Services ServiceBindings `json:"services,omitempty"`
Focused bool `json:"focused"`
DefaultShell []string `json:"defaultShell,omitempty"`
}
func (*Container) Type() *ast.Type {
return &ast.Type{
NamedType: "Container",
NonNull: true, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }
}
func (*Container) TypeDescription() string {
return "An OCI-compatible container, also known as a Docker container."
}
var _ HasPBDefinitions = (*Container)(nil)
func (container *Container) PBDefinitions(ctx context.Context) ([]*pb.Definition, error) {
var defs []*pb.Definition
if container.FS != nil {
defs = append(defs, container.FS)
}
for _, mnt := range container.Mounts {
if mnt.Source != nil {
defs = append(defs, mnt.Source)
}
}
for _, bnd := range container.Services {
ctr := bnd.Service.Container
if ctr == nil {
continue
}
ctrDefs, err := ctr.PBDefinitions(ctx)
if err != nil {
return nil, err
}
defs = append(defs, ctrDefs...)
}
return defs, nil
}
func NewContainer(root *Query, platform Platform) (*Container, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if root == nil {
panic("query must be non-nil")
}
return &Container{
Query: root,
Platform: platform,
}, nil
}
func (container *Container) Clone() *Container {
cp := *container
cp.Config.ExposedPorts = cloneMap(cp.Config.ExposedPorts)
cp.Config.Env = cloneSlice(cp.Config.Env)
cp.Config.Entrypoint = cloneSlice(cp.Config.Entrypoint)
cp.Config.Cmd = cloneSlice(cp.Config.Cmd)
cp.Config.Volumes = cloneMap(cp.Config.Volumes)
cp.Config.Labels = cloneMap(cp.Config.Labels)
cp.Mounts = cloneSlice(cp.Mounts)
cp.Secrets = cloneSlice(cp.Secrets)
cp.Sockets = cloneSlice(cp.Sockets)
cp.Ports = cloneSlice(cp.Ports)
cp.Services = cloneSlice(cp.Services)
return &cp
}
var _ pipeline.Pipelineable = (*Container)(nil)
func (container *Container) PipelinePath() pipeline.Path {
return container.Query.Pipeline
}
type Ownership struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | UID int `json:"uid"`
GID int `json:"gid"`
}
func (owner Ownership) Opt() llb.ChownOption {
return llb.WithUIDGID(owner.UID, owner.GID)
}
type ContainerSecret struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Secret *Secret `json:"secret"`
EnvName string `json:"env,omitempty"`
MountPath string `json:"path,omitempty"`
Owner *Ownership `json:"owner,omitempty"`
Mode fs.FileMode `json:"mode,omitempty"`
}
type ContainerSocket struct {
Source *Socket `json:"socket"`
ContainerPath string `json:"container_path,omitempty"`
Owner *Ownership `json:"owner,omitempty"`
}
func (container *Container) FSState() (llb.State, error) {
if container.FS == nil {
return llb.Scratch(), nil
}
return defToState(container.FS)
}
func (container *Container) MetaState() (*llb.State, error) {
if container.Meta == nil {
return nil, nil
}
metaSt, err := defToState(container.Meta)
if err != nil {
return nil, err
}
return &metaSt, nil
}
type ContainerMount struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Source *pb.Definition `json:"source,omitempty"`
SourcePath string `json:"source_path,omitempty"`
Target string `json:"target"`
CacheVolumeID string `json:"cache_volume_id,omitempty"`
CacheSharingMode CacheSharingMode `json:"cache_sharing,omitempty"`
Tmpfs bool `json:"tmpfs,omitempty"`
Readonly bool `json:"readonly,omitempty"`
}
func (mnt ContainerMount) SourceState() (llb.State, error) {
if mnt.Source == nil {
return llb.Scratch(), nil
}
return defToState(mnt.Source)
}
type ContainerMounts []ContainerMount |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | func (mnts ContainerMounts) With(newMnt ContainerMount) ContainerMounts {
mntsCp := make(ContainerMounts, 0, len(mnts))
parent := newMnt.Target + "/"
for _, mnt := range mnts {
if mnt.Target == newMnt.Target || strings.HasPrefix(mnt.Target, parent) {
continue
}
mntsCp = append(mntsCp, mnt)
}
mntsCp = append(mntsCp, newMnt)
return mntsCp
}
func (container *Container) From(ctx context.Context, addr string) (*Container, error) {
bk := container.Query.Buildkit
container = container.Clone()
platform := container.Platform
ctx, subRecorder := progrock.WithGroup(ctx, fmt.Sprintf("from %s", addr), progrock.Weak())
refName, err := reference.ParseNormalizedNamed(addr)
if err != nil {
return nil, err
}
ref := reference.TagNameOnly(refName).String()
_, digest, cfgBytes, err := bk.ResolveImageConfig(ctx, ref, llb.ResolveImageConfigOpt{
Platform: ptr(platform.Spec()),
ResolveMode: llb.ResolveModeDefault.String(),
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if err != nil {
return nil, err
}
digested, err := reference.WithDigest(refName, digest)
if err != nil {
return nil, err
}
var imgSpec specs.Image
if err := json.Unmarshal(cfgBytes, &imgSpec); err != nil {
return nil, err
}
fsSt := llb.Image(
digested.String(),
llb.WithCustomNamef("pull %s", ref),
)
def, err := fsSt.Marshal(ctx, llb.Platform(platform.Spec()))
if err != nil {
return nil, err
}
container.FS = def.ToPB()
buildkit.RecordVertexes(subRecorder, container.FS)
container.Config = mergeImageConfig(container.Config, imgSpec.Config)
container.ImageRef = digested.String()
return container, nil
}
const defaultDockerfileName = "Dockerfile"
func (container *Container) Build(
ctx context.Context,
contextDir *Directory, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | dockerfile string,
buildArgs []BuildArg,
target string,
secrets []*Secret,
) (*Container, error) {
container = container.Clone()
container.Services.Merge(contextDir.Services)
for _, secret := range secrets {
container.Secrets = append(container.Secrets, ContainerSecret{
Secret: secret,
MountPath: fmt.Sprintf("/run/secrets/%s", secret.Name),
})
}
container.ImageRef = ""
svcs := container.Query.Services
bk := container.Query.Buildkit
ctx, subRecorder := progrock.WithGroup(ctx, "docker build", progrock.Weak())
detach, _, err := svcs.StartBindings(ctx, container.Services)
if err != nil {
return nil, err
}
defer detach()
platform := container.Platform
opts := map[string]string{
"platform": platform.Format(),
"contextsubdir": contextDir.Dir,
}
if dockerfile != "" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | opts["filename"] = path.Join(contextDir.Dir, dockerfile)
} else {
opts["filename"] = path.Join(contextDir.Dir, defaultDockerfileName)
}
if target != "" {
opts["target"] = target
}
for _, buildArg := range buildArgs {
opts["build-arg:"+buildArg.Name] = buildArg.Value
}
inputs := map[string]*pb.Definition{
dockerui.DefaultLocalNameContext: contextDir.LLB,
dockerui.DefaultLocalNameDockerfile: contextDir.LLB,
}
res, err := bk.Solve(ctx, bkgw.SolveRequest{
Frontend: "dockerfile.v0",
FrontendOpt: opts,
FrontendInputs: inputs,
})
if err != nil {
return nil, err
}
bkref, err := res.SingleRef()
if err != nil {
return nil, err
}
var st llb.State
if bkref == nil {
st = llb.Scratch()
} else { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | st, err = bkref.ToState()
if err != nil {
return nil, err
}
}
def, err := st.Marshal(ctx, llb.Platform(platform.Spec()))
if err != nil {
return nil, err
}
buildkit.RecordVertexes(subRecorder, def.ToPB())
container.FS = def.ToPB()
container.FS.Source = nil
cfgBytes, found := res.Metadata[exptypes.ExporterImageConfigKey]
if found {
var imgSpec specs.Image
if err := json.Unmarshal(cfgBytes, &imgSpec); err != nil {
return nil, err
}
container.Config = mergeImageConfig(container.Config, imgSpec.Config)
}
return container, nil
}
func (container *Container) RootFS(ctx context.Context) (*Directory, error) {
return &Directory{
Query: container.Query,
LLB: container.FS,
Dir: "/",
Platform: container.Platform,
Services: container.Services, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }, nil
}
func (container *Container) WithRootFS(ctx context.Context, dir *Directory) (*Container, error) {
container = container.Clone()
dirSt, err := dir.StateWithSourcePath()
if err != nil {
return nil, err
}
def, err := dirSt.Marshal(ctx, llb.Platform(dir.Platform.Spec()))
if err != nil {
return nil, err
}
container.FS = def.ToPB()
container.Services.Merge(dir.Services)
container.ImageRef = ""
return container, nil
}
func (container *Container) WithDirectory(ctx context.Context, subdir string, src *Directory, filter CopyFilter, owner string) (*Container, error) {
container = container.Clone()
return container.writeToPath(ctx, subdir, func(dir *Directory) (*Directory, error) {
ownership, err := container.ownership(ctx, owner)
if err != nil {
return nil, err
}
return dir.WithDirectory(ctx, ".", src, filter, ownership)
})
}
func (container *Container) WithFile(ctx context.Context, destPath string, src *File, permissions *int, owner string) (*Container, error) {
container = container.Clone() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return container.writeToPath(ctx, path.Dir(destPath), func(dir *Directory) (*Directory, error) {
ownership, err := container.ownership(ctx, owner)
if err != nil {
return nil, err
}
return dir.WithFile(ctx, path.Base(destPath), src, permissions, ownership)
})
}
func (container *Container) WithNewFile(ctx context.Context, dest string, content []byte, permissions fs.FileMode, owner string) (*Container, error) {
container = container.Clone()
dir, file := filepath.Split(dest)
return container.writeToPath(ctx, dir, func(dir *Directory) (*Directory, error) {
ownership, err := container.ownership(ctx, owner)
if err != nil {
return nil, err
}
return dir.WithNewFile(ctx, file, content, permissions, ownership)
})
}
func (container *Container) WithMountedDirectory(ctx context.Context, target string, dir *Directory, owner string, readonly bool) (*Container, error) {
container = container.Clone()
return container.withMounted(ctx, target, dir.LLB, dir.Dir, dir.Services, owner, readonly)
}
func (container *Container) WithMountedFile(ctx context.Context, target string, file *File, owner string, readonly bool) (*Container, error) {
container = container.Clone()
return container.withMounted(ctx, target, file.LLB, file.File, file.Services, owner, readonly)
}
var SeenCacheKeys = new(sync.Map)
func (container *Container) WithMountedCache(ctx context.Context, target string, cache *CacheVolume, source *Directory, sharingMode CacheSharingMode, owner string) (*Container, error) {
container = container.Clone() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | target = absPath(container.Config.WorkingDir, target)
if sharingMode == "" {
sharingMode = CacheSharingModeShared
}
mount := ContainerMount{
Target: target,
CacheVolumeID: cache.Sum(),
CacheSharingMode: sharingMode,
}
if source != nil {
mount.Source = source.LLB
mount.SourcePath = source.Dir
}
if owner != "" {
var err error
mount.Source, mount.SourcePath, err = container.chown(
ctx,
mount.Source,
mount.SourcePath,
owner,
llb.Platform(container.Platform.Spec()),
)
if err != nil {
return nil, err
}
}
container.Mounts = container.Mounts.With(mount)
container.ImageRef = ""
SeenCacheKeys.Store(cache.Keys[0], struct{}{}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return container, nil
}
func (container *Container) WithMountedTemp(ctx context.Context, target string) (*Container, error) {
container = container.Clone()
target = absPath(container.Config.WorkingDir, target)
container.Mounts = container.Mounts.With(ContainerMount{
Target: target,
Tmpfs: true,
})
container.ImageRef = ""
return container, nil
}
func (container *Container) WithMountedSecret(ctx context.Context, target string, source *Secret, owner string, mode fs.FileMode) (*Container, error) {
container = container.Clone()
target = absPath(container.Config.WorkingDir, target)
ownership, err := container.ownership(ctx, owner)
if err != nil {
return nil, err
}
container.Secrets = append(container.Secrets, ContainerSecret{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Secret: source,
MountPath: target,
Owner: ownership,
Mode: mode,
})
container.ImageRef = ""
return container, nil
}
func (container *Container) WithoutMount(ctx context.Context, target string) (*Container, error) {
container = container.Clone()
target = absPath(container.Config.WorkingDir, target)
var found bool
var foundIdx int
for i := len(container.Mounts) - 1; i >= 0; i-- {
if container.Mounts[i].Target == target {
found = true
foundIdx = i
break
}
}
if found {
container.Mounts = append(container.Mounts[:foundIdx], container.Mounts[foundIdx+1:]...)
}
container.ImageRef = ""
return container, nil
}
func (container *Container) MountTargets(ctx context.Context) ([]string, error) {
mounts := []string{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | for _, mnt := range container.Mounts {
mounts = append(mounts, mnt.Target)
}
return mounts, nil
}
func (container *Container) WithUnixSocket(ctx context.Context, target string, source *Socket, owner string) (*Container, error) {
container = container.Clone()
target = absPath(container.Config.WorkingDir, target)
ownership, err := container.ownership(ctx, owner)
if err != nil {
return nil, err
}
newSocket := ContainerSocket{
Source: source,
ContainerPath: target,
Owner: ownership,
}
var replaced bool
for i, sock := range container.Sockets {
if sock.ContainerPath == target {
container.Sockets[i] = newSocket
replaced = true
break
}
}
if !replaced {
container.Sockets = append(container.Sockets, newSocket)
}
container.ImageRef = "" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return container, nil
}
func (container *Container) WithoutUnixSocket(ctx context.Context, target string) (*Container, error) {
container = container.Clone()
target = absPath(container.Config.WorkingDir, target)
for i, sock := range container.Sockets {
if sock.ContainerPath == target {
container.Sockets = append(container.Sockets[:i], container.Sockets[i+1:]...)
break
}
}
container.ImageRef = ""
return container, nil
}
func (container *Container) WithSecretVariable(ctx context.Context, name string, secret *Secret) (*Container, error) {
container = container.Clone()
container.Secrets = append(container.Secrets, ContainerSecret{
Secret: secret,
EnvName: name,
})
container.ImageRef = ""
return container, nil
}
func (container *Container) Directory(ctx context.Context, dirPath string) (*Directory, error) {
dir, _, err := locatePath(ctx, container, dirPath, NewDirectory)
if err != nil {
return nil, err
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | svcs := container.Query.Services
bk := container.Query.Buildkit
info, err := dir.Stat(ctx, bk, svcs, ".")
if err != nil {
return nil, err
}
if !info.IsDir() {
return nil, fmt.Errorf("path %s is a file, not a directory", dirPath)
}
return dir, nil
}
func (container *Container) File(ctx context.Context, filePath string) (*File, error) {
file, _, err := locatePath(ctx, container, filePath, NewFile)
if err != nil {
return nil, err
}
info, err := file.Stat(ctx)
if err != nil {
return nil, err
}
if info.IsDir() {
return nil, fmt.Errorf("path %s is a directory, not a file", filePath)
}
return file, nil
}
func locatePath[T *File | *Directory]( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | ctx context.Context,
container *Container,
containerPath string,
init func(*Query, *pb.Definition, string, Platform, ServiceBindings) T,
) (T, *ContainerMount, error) {
containerPath = absPath(container.Config.WorkingDir, containerPath)
for i := len(container.Mounts) - 1; i >= 0; i-- {
mnt := container.Mounts[i]
if containerPath == mnt.Target || strings.HasPrefix(containerPath, mnt.Target+"/") {
if mnt.Tmpfs {
return nil, nil, fmt.Errorf("%s: cannot retrieve path from tmpfs", containerPath)
}
if mnt.CacheVolumeID != "" {
return nil, nil, fmt.Errorf("%s: cannot retrieve path from cache", containerPath)
}
sub := mnt.SourcePath
if containerPath != mnt.Target { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | dirSub := strings.TrimPrefix(containerPath, mnt.Target+"/")
if dirSub != "" {
sub = path.Join(sub, dirSub)
}
}
return init(
container.Query,
mnt.Source,
sub,
container.Platform,
container.Services,
), &mnt, nil
}
}
return init(
container.Query,
container.FS,
containerPath,
container.Platform,
container.Services,
), nil, nil
}
func (container *Container) withMounted(
ctx context.Context,
target string,
srcDef *pb.Definition,
srcPath string,
svcs ServiceBindings, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | owner string,
readonly bool,
) (*Container, error) {
target = absPath(container.Config.WorkingDir, target)
var err error
if owner != "" {
srcDef, srcPath, err = container.chown(ctx, srcDef, srcPath, owner, llb.Platform(container.Platform.Spec()))
if err != nil {
return nil, err
}
}
container.Mounts = container.Mounts.With(ContainerMount{
Source: srcDef,
SourcePath: srcPath,
Target: target,
Readonly: readonly,
})
container.Services.Merge(svcs)
container.ImageRef = ""
return container, nil
}
func (container *Container) chown(
ctx context.Context,
srcDef *pb.Definition,
srcPath string,
owner string,
opts ...llb.ConstraintsOpt,
) (*pb.Definition, string, error) {
ownership, err := container.ownership(ctx, owner) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if err != nil {
return nil, "", err
}
if ownership == nil {
return srcDef, srcPath, nil
}
var srcSt llb.State
if srcDef == nil {
srcSt = llb.Scratch().File(
llb.Mkdir("/chown", 0o755, ownership.Opt()),
)
srcPath = "/chown"
} else {
srcSt, err = defToState(srcDef)
if err != nil {
return nil, "", err
}
def, err := srcSt.Marshal(ctx, opts...)
if err != nil {
return nil, "", err
}
ref, err := bkRef(ctx, container.Query.Buildkit, def.ToPB())
if err != nil {
return nil, "", err
}
stat, err := ref.StatFile(ctx, bkgw.StatRequest{
Path: srcPath,
})
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return nil, "", err
}
if stat.IsDir() {
chowned := "/chown"
srcSt = llb.Scratch().File(
llb.Mkdir(chowned, os.FileMode(stat.Mode), ownership.Opt()).
Copy(srcSt, srcPath, chowned, &llb.CopyInfo{
CopyDirContentsOnly: true,
}, ownership.Opt()),
)
srcPath = chowned
} else {
srcSt = llb.Scratch().File(
llb.Copy(srcSt, srcPath, ".", ownership.Opt()),
)
srcPath = filepath.Base(srcPath)
}
}
def, err := srcSt.Marshal(ctx, opts...)
if err != nil {
return nil, "", err
}
return def.ToPB(), srcPath, nil
}
func (container *Container) writeToPath(ctx context.Context, subdir string, fn func(dir *Directory) (*Directory, error)) (*Container, error) {
dir, mount, err := locatePath(ctx, container, subdir, NewDirectory)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return nil, err
}
dir, err = fn(dir)
if err != nil {
return nil, err
}
if mount == nil {
root, err := dir.Root()
if err != nil {
return nil, err
}
return container.WithRootFS(ctx, root)
}
return container.withMounted(ctx, mount.Target, dir.LLB, mount.SourcePath, nil, "", false)
}
func (container *Container) ImageConfig(ctx context.Context) (specs.ImageConfig, error) {
return container.Config, nil
}
func (container *Container) UpdateImageConfig(ctx context.Context, updateFn func(specs.ImageConfig) specs.ImageConfig) (*Container, error) {
container = container.Clone()
container.Config = updateFn(container.Config)
return container, nil
}
func (container *Container) WithPipeline(ctx context.Context, name, description string, labels []pipeline.Label) (*Container, error) {
container = container.Clone()
container.Query = container.Query.WithPipeline(name, description, labels)
return container, nil
}
type ContainerGPUOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Devices []string
}
func (container *Container) WithGPU(ctx context.Context, gpuOpts ContainerGPUOpts) (*Container, error) {
container = container.Clone()
container.EnabledGPUs = gpuOpts.Devices
return container, nil
}
func (container *Container) WithExec(ctx context.Context, opts ContainerExecOpts) (*Container, error) {
container = container.Clone()
cfg := container.Config
mounts := container.Mounts
platform := container.Platform
if platform.OS == "" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | platform = container.Query.Platform
}
args, err := container.command(opts)
if err != nil {
return nil, err
}
var namef string
if container.Focused {
namef = buildkit.FocusPrefix + "exec %s"
} else {
namef = "exec %s"
}
runOpts := []llb.RunOption{
llb.Args(args),
llb.WithCustomNamef(namef, strings.Join(args, " ")),
}
if opts.ExperimentalPrivilegedNesting {
runOpts = append(runOpts, llb.AddEnv("_DAGGER_ENABLE_NESTING", ""))
}
if opts.ModuleCallerDigest != "" {
runOpts = append(runOpts, llb.AddEnv("_DAGGER_MODULE_CALLER_DIGEST", opts.ModuleCallerDigest.String()))
}
if opts.NestedInSameSession {
runOpts = append(runOpts, llb.AddEnv("_DAGGER_ENABLE_NESTING_IN_SAME_SESSION", ""))
}
metaSt, metaSourcePath := metaMount(opts.Stdin)
runOpts = append(runOpts,
llb.AddMount(buildkit.MetaMountDestPath, metaSt, llb.SourcePath(metaSourcePath))) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if opts.RedirectStdout != "" {
runOpts = append(runOpts, llb.AddEnv("_DAGGER_REDIRECT_STDOUT", opts.RedirectStdout))
}
if opts.RedirectStderr != "" {
runOpts = append(runOpts, llb.AddEnv("_DAGGER_REDIRECT_STDERR", opts.RedirectStderr))
}
for _, bnd := range container.Services {
for _, alias := range bnd.Aliases {
runOpts = append(runOpts,
llb.AddEnv("_DAGGER_HOSTNAME_ALIAS_"+alias, bnd.Hostname))
}
}
if cfg.User != "" {
runOpts = append(runOpts, llb.User(cfg.User))
}
if cfg.WorkingDir != "" {
runOpts = append(runOpts, llb.Dir(cfg.WorkingDir))
}
for _, env := range cfg.Env {
name, val, ok := strings.Cut(env, "=")
if !ok {
_ = ok
}
if name == "_DAGGER_ENABLE_NESTING" && !opts.ExperimentalPrivilegedNesting {
continue
}
if name == "_DAGGER_MODULE_CALLER_DIGEST" && opts.ModuleCallerDigest == "" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | continue
}
if name == "_DAGGER_ENABLE_NESTING_IN_SAME_SESSION" && !opts.NestedInSameSession {
continue
}
runOpts = append(runOpts, llb.AddEnv(name, val))
}
if len(container.EnabledGPUs) > 0 {
if gpuSupportEnabled := os.Getenv("_EXPERIMENTAL_DAGGER_GPU_SUPPORT"); gpuSupportEnabled == "" {
return nil, fmt.Errorf("GPU support is not enabled, set _EXPERIMENTAL_DAGGER_GPU_SUPPORT")
}
runOpts = append(runOpts, llb.AddEnv("_EXPERIMENTAL_DAGGER_GPU_PARAMS", strings.Join(container.EnabledGPUs, ",")))
}
secretsToScrub := SecretToScrubInfo{}
for i, secret := range container.Secrets {
secretOpts := []llb.SecretOption{llb.SecretID(secret.Secret.Name)}
var secretDest string
switch {
case secret.EnvName != "":
secretDest = secret.EnvName
secretOpts = append(secretOpts, llb.SecretAsEnv(true))
secretsToScrub.Envs = append(secretsToScrub.Envs, secret.EnvName)
case secret.MountPath != "":
secretDest = secret.MountPath
secretsToScrub.Files = append(secretsToScrub.Files, secret.MountPath)
if secret.Owner != nil {
secretOpts = append(secretOpts, llb.SecretFileOpt(
secret.Owner.UID,
secret.Owner.GID, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | int(secret.Mode),
))
}
default:
return nil, fmt.Errorf("malformed secret config at index %d", i)
}
runOpts = append(runOpts, llb.AddSecret(secretDest, secretOpts...))
}
if len(secretsToScrub.Envs) != 0 || len(secretsToScrub.Files) != 0 {
sort.Strings(secretsToScrub.Envs)
sort.Strings(secretsToScrub.Files)
secretsToScrubJSON, err := json.Marshal(secretsToScrub)
if err != nil {
return nil, fmt.Errorf("scrub secrets json: %w", err)
}
runOpts = append(runOpts, llb.AddEnv("_DAGGER_SCRUB_SECRETS", string(secretsToScrubJSON)))
}
for _, ctrSocket := range container.Sockets {
if ctrSocket.ContainerPath == "" {
return nil, fmt.Errorf("unsupported socket: only unix paths are implemented")
}
socketOpts := []llb.SSHOption{
llb.SSHID(ctrSocket.Source.SSHID()),
llb.SSHSocketTarget(ctrSocket.ContainerPath),
}
if ctrSocket.Owner != nil {
socketOpts = append(socketOpts,
llb.SSHSocketOpt(
ctrSocket.ContainerPath, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | ctrSocket.Owner.UID,
ctrSocket.Owner.GID,
0o600,
))
}
runOpts = append(runOpts, llb.AddSSHSocket(socketOpts...))
}
for _, mnt := range mounts {
srcSt, err := mnt.SourceState()
if err != nil {
return nil, fmt.Errorf("mount %s: %w", mnt.Target, err)
}
mountOpts := []llb.MountOption{}
if mnt.SourcePath != "" {
mountOpts = append(mountOpts, llb.SourcePath(mnt.SourcePath))
}
if mnt.CacheVolumeID != "" {
var sharingMode llb.CacheMountSharingMode
switch mnt.CacheSharingMode {
case CacheSharingModeShared:
sharingMode = llb.CacheMountShared
case CacheSharingModePrivate:
sharingMode = llb.CacheMountPrivate
case CacheSharingModeLocked:
sharingMode = llb.CacheMountLocked
default:
return nil, errors.Errorf("invalid cache mount sharing mode %q", mnt.CacheSharingMode)
}
mountOpts = append(mountOpts, llb.AsPersistentCacheDir(mnt.CacheVolumeID, sharingMode))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if mnt.Tmpfs {
mountOpts = append(mountOpts, llb.Tmpfs())
}
if mnt.Readonly {
mountOpts = append(mountOpts, llb.Readonly)
}
runOpts = append(runOpts, llb.AddMount(mnt.Target, srcSt, mountOpts...))
}
if opts.InsecureRootCapabilities {
runOpts = append(runOpts, llb.Security(llb.SecurityModeInsecure))
}
fsSt, err := container.FSState()
if err != nil {
return nil, fmt.Errorf("fs state: %w", err)
}
execSt := fsSt.Run(runOpts...)
execDef, err := execSt.Root().Marshal(ctx, llb.Platform(platform.Spec()))
if err != nil {
return nil, fmt.Errorf("marshal root: %w", err)
}
container.FS = execDef.ToPB()
metaDef, err := execSt.GetMount(buildkit.MetaMountDestPath).Marshal(ctx, llb.Platform(platform.Spec()))
if err != nil {
return nil, fmt.Errorf("get meta mount: %w", err)
}
container.Meta = metaDef.ToPB()
for i, mnt := range mounts {
if mnt.Tmpfs || mnt.CacheVolumeID != "" {
continue
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | mountSt := execSt.GetMount(mnt.Target)
execMountDef, err := mountSt.Marshal(ctx, llb.Platform(platform.Spec()))
if err != nil {
return nil, fmt.Errorf("propagate %s: %w", mnt.Target, err)
}
mounts[i].Source = execMountDef.ToPB()
}
container.Mounts = mounts
container.ImageRef = ""
return container, nil
}
func (container Container) Evaluate(ctx context.Context) (*buildkit.Result, error) {
if container.FS == nil {
return nil, nil
}
root := container.Query
detach, _, err := root.Services.StartBindings(ctx, container.Services)
if err != nil {
return nil, err
}
defer detach()
st, err := container.FSState()
if err != nil {
return nil, err
}
def, err := st.Marshal(ctx, llb.Platform(container.Platform.Spec()))
if err != nil {
return nil, err |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }
return root.Buildkit.Solve(ctx, bkgw.SolveRequest{
Evaluate: true,
Definition: def.ToPB(),
})
}
func (container *Container) MetaFileContents(ctx context.Context, filePath string) (string, error) {
if container.Meta == nil {
ctr, err := container.WithExec(ctx, ContainerExecOpts{})
if err != nil {
return "", err
}
return ctr.MetaFileContents(ctx, filePath)
}
file := NewFile(
container.Query,
container.Meta,
path.Join(buildkit.MetaSourcePath, filePath),
container.Platform,
container.Services,
)
content, err := file.Contents(ctx)
if err != nil {
return "", err
}
return string(content), nil
}
func (container *Container) Publish(
ctx context.Context,
ref string, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | platformVariants []*Container,
forcedCompression ImageLayerCompression,
mediaTypes ImageMediaTypes,
) (string, error) {
if mediaTypes == "" {
mediaTypes = OCIMediaTypes
}
inputByPlatform := map[string]buildkit.ContainerExport{}
services := ServiceBindings{}
for _, variant := range append([]*Container{container}, platformVariants...) {
if variant.FS == nil {
continue
}
st, err := variant.FSState()
if err != nil {
return "", err
}
def, err := st.Marshal(ctx, llb.Platform(variant.Platform.Spec()))
if err != nil {
return "", err
}
platformString := variant.Platform.Format()
if _, ok := inputByPlatform[platformString]; ok {
return "", fmt.Errorf("duplicate platform %q", platformString)
}
inputByPlatform[platformString] = buildkit.ContainerExport{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Definition: def.ToPB(),
Config: variant.Config,
}
services.Merge(variant.Services)
}
if len(inputByPlatform) == 0 {
return "", errors.New("no containers to export")
}
opts := map[string]string{
string(exptypes.OptKeyName): ref,
string(exptypes.OptKeyPush): strconv.FormatBool(true),
string(exptypes.OptKeyOCITypes): strconv.FormatBool(mediaTypes == OCIMediaTypes),
}
if forcedCompression != "" {
opts[string(exptypes.OptKeyLayerCompression)] = strings.ToLower(string(forcedCompression))
opts[string(exptypes.OptKeyForceCompression)] = strconv.FormatBool(true)
}
svcs := container.Query.Services
bk := container.Query.Buildkit
detach, _, err := svcs.StartBindings(ctx, services)
if err != nil {
return "", err
}
defer detach()
resp, err := bk.PublishContainerImage(ctx, inputByPlatform, opts)
if err != nil {
return "", err
}
refName, err := reference.ParseNormalizedNamed(ref) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if err != nil {
return "", err
}
imageDigest, found := resp[exptypes.ExporterImageDigestKey]
if found {
dig, err := digest.Parse(imageDigest)
if err != nil {
return "", fmt.Errorf("parse digest: %w", err)
}
withDig, err := reference.WithDigest(refName, dig)
if err != nil {
return "", fmt.Errorf("with digest: %w", err)
}
return withDig.String(), nil
}
return ref, nil
}
func (container *Container) Export(
ctx context.Context,
dest string,
platformVariants []*Container,
forcedCompression ImageLayerCompression,
mediaTypes ImageMediaTypes,
) error {
svcs := container.Query.Services
bk := container.Query.Buildkit
if mediaTypes == "" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | mediaTypes = OCIMediaTypes
}
inputByPlatform := map[string]buildkit.ContainerExport{}
services := ServiceBindings{}
for _, variant := range append([]*Container{container}, platformVariants...) {
if variant.FS == nil {
continue
}
st, err := variant.FSState()
if err != nil {
return err
}
def, err := st.Marshal(ctx, llb.Platform(variant.Platform.Spec()))
if err != nil {
return err
}
platformString := variant.Platform.Format()
if _, ok := inputByPlatform[platformString]; ok {
return fmt.Errorf("duplicate platform %q", platformString)
}
inputByPlatform[platformString] = buildkit.ContainerExport{
Definition: def.ToPB(),
Config: variant.Config,
}
services.Merge(variant.Services)
}
if len(inputByPlatform) == 0 {
return errors.New("no containers to export") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }
opts := map[string]string{
"tar": strconv.FormatBool(true),
string(exptypes.OptKeyOCITypes): strconv.FormatBool(mediaTypes == OCIMediaTypes),
}
if forcedCompression != "" {
opts[string(exptypes.OptKeyLayerCompression)] = strings.ToLower(string(forcedCompression))
opts[string(exptypes.OptKeyForceCompression)] = strconv.FormatBool(true)
}
detach, _, err := svcs.StartBindings(ctx, services)
if err != nil {
return err
}
defer detach()
_, err = bk.ExportContainerImage(ctx, inputByPlatform, dest, opts)
return err
}
func (container *Container) AsTarball(
ctx context.Context,
platformVariants []*Container,
forcedCompression ImageLayerCompression,
mediaTypes ImageMediaTypes,
) (*File, error) {
bk := container.Query.Buildkit
svcs := container.Query.Services
engineHostPlatform := container.Query.Platform
if mediaTypes == "" {
mediaTypes = OCIMediaTypes
}
inputByPlatform := map[string]buildkit.ContainerExport{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | services := ServiceBindings{}
for _, variant := range append([]*Container{container}, platformVariants...) {
if variant.FS == nil {
continue
}
st, err := variant.FSState()
if err != nil {
return nil, err
}
def, err := st.Marshal(ctx, llb.Platform(variant.Platform.Spec()))
if err != nil {
return nil, err
}
platformString := platforms.Format(variant.Platform.Spec())
if _, ok := inputByPlatform[platformString]; ok {
return nil, fmt.Errorf("duplicate platform %q", platformString)
}
inputByPlatform[platformString] = buildkit.ContainerExport{
Definition: def.ToPB(),
Config: variant.Config,
}
services.Merge(variant.Services)
}
if len(inputByPlatform) == 0 {
return nil, errors.New("no containers to export")
}
opts := map[string]string{
"tar": strconv.FormatBool(true),
string(exptypes.OptKeyOCITypes): strconv.FormatBool(mediaTypes == OCIMediaTypes),
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if forcedCompression != "" {
opts[string(exptypes.OptKeyLayerCompression)] = strings.ToLower(string(forcedCompression))
opts[string(exptypes.OptKeyForceCompression)] = strconv.FormatBool(true)
}
detach, _, err := svcs.StartBindings(ctx, services)
if err != nil {
return nil, err
}
defer detach()
fileName := identity.NewID() + ".tar"
pbDef, err := bk.ContainerImageToTarball(ctx, engineHostPlatform.Spec(), fileName, inputByPlatform, opts)
if err != nil {
return nil, fmt.Errorf("container image to tarball file conversion failed: %w", err)
}
return NewFile(container.Query, pbDef, fileName, engineHostPlatform, nil), nil
}
func (container *Container) Import(
ctx context.Context,
source *File,
tag string,
) (*Container, error) {
bk := container.Query.Buildkit
store := container.Query.OCIStore
lm := container.Query.LeaseManager
container = container.Clone()
var release func(context.Context) error
loadManifest := func(ctx context.Context) (*specs.Descriptor, error) {
src, err := source.Open(ctx)
if err != nil {
return nil, err |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }
defer src.Close()
ctx, release, err = leaseutil.WithLease(ctx, lm, leaseutil.MakeTemporary)
if err != nil {
return nil, err
}
stream := archive.NewImageImportStream(src, "")
desc, err := stream.Import(ctx, store)
if err != nil {
return nil, fmt.Errorf("image archive import: %w", err)
}
return resolveIndex(ctx, store, desc, container.Platform.Spec(), tag)
}
manifestDesc, err := loadManifest(ctx)
if err != nil {
return nil, fmt.Errorf("recover: %w", err)
}
dummyRepo := "dagger/import"
st := llb.OCILayout(
fmt.Sprintf("%s@%s", dummyRepo, manifestDesc.Digest),
llb.OCIStore("", buildkit.OCIStoreName),
llb.Platform(container.Platform.Spec()),
)
execDef, err := st.Marshal(ctx, llb.Platform(container.Platform.Spec()))
if err != nil {
return nil, fmt.Errorf("marshal root: %w", err)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | container.FS = execDef.ToPB()
if release != nil {
_, err = bk.Solve(ctx, bkgw.SolveRequest{
Definition: container.FS,
Evaluate: true,
})
if err != nil {
return nil, fmt.Errorf("solve: %w", err)
}
if err := release(ctx); err != nil {
return nil, fmt.Errorf("release: %w", err)
}
}
manifestBlob, err := content.ReadBlob(ctx, store, *manifestDesc)
if err != nil {
return nil, fmt.Errorf("image archive read manifest blob: %w", err)
}
var man specs.Manifest
err = json.Unmarshal(manifestBlob, &man)
if err != nil {
return nil, fmt.Errorf("image archive unmarshal manifest: %w", err)
}
configBlob, err := content.ReadBlob(ctx, store, man.Config)
if err != nil {
return nil, fmt.Errorf("image archive read image config blob %s: %w", man.Config.Digest, err)
}
var imgSpec specs.Image
err = json.Unmarshal(configBlob, &imgSpec)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return nil, fmt.Errorf("load image config: %w", err)
}
container.Config = imgSpec.Config
return container, nil
}
func (container *Container) WithExposedPort(port Port) (*Container, error) {
container = container.Clone()
gotOne := false
for i, p := range container.Ports {
if p.Port == port.Port && p.Protocol == port.Protocol {
container.Ports[i] = port
gotOne = true
break
}
}
if !gotOne {
container.Ports = append(container.Ports, port)
}
if container.Config.ExposedPorts == nil {
container.Config.ExposedPorts = map[string]struct{}{}
}
ociPort := fmt.Sprintf("%d/%s", port.Port, port.Protocol.Network())
container.Config.ExposedPorts[ociPort] = struct{}{}
return container, nil
}
func (container *Container) WithoutExposedPort(port int, protocol NetworkProtocol) (*Container, error) {
container = container.Clone()
filtered := []Port{}
filteredOCI := map[string]struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | for _, p := range container.Ports {
if p.Port != port || p.Protocol != protocol {
filtered = append(filtered, p)
ociPort := fmt.Sprintf("%d/%s", p.Port, p.Protocol.Network())
filteredOCI[ociPort] = struct{}{}
}
}
container.Ports = filtered
container.Config.ExposedPorts = filteredOCI
return container, nil
}
func (container *Container) WithServiceBinding(ctx context.Context, id *idproto.ID, svc *Service, alias string) (*Container, error) {
container = container.Clone()
host, err := svc.Hostname(ctx, id)
if err != nil {
return nil, err
}
var aliases AliasSet
if alias != "" {
aliases = AliasSet{alias}
}
container.Services.Merge(ServiceBindings{
{
ID: id,
Service: svc,
Hostname: host,
Aliases: aliases,
},
})
return container, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }
func (container *Container) ImageRefOrErr(ctx context.Context) (string, error) {
imgRef := container.ImageRef
if imgRef != "" {
return imgRef, nil
}
return "", errors.Errorf("Image reference can only be retrieved immediately after the 'Container.From' call. Error in fetching imageRef as the container image is changed")
}
func (container *Container) Service(ctx context.Context) (*Service, error) {
if container.Meta == nil {
var err error
container, err = container.WithExec(ctx, ContainerExecOpts{})
if err != nil {
return nil, err
}
}
return container.Query.NewContainerService(container), nil
}
func (container *Container) ownership(ctx context.Context, owner string) (*Ownership, error) {
if owner == "" {
return nil, nil
}
fsSt, err := container.FSState()
if err != nil {
return nil, err
}
return resolveUIDGID(ctx, fsSt, container.Query.Buildkit, container.Platform, owner)
}
func (container *Container) command(opts ContainerExecOpts) ([]string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | cfg := container.Config
args := opts.Args
if len(args) == 0 {
args = cfg.Cmd
}
if len(cfg.Entrypoint) > 0 && !opts.SkipEntrypoint {
args = append(cfg.Entrypoint, args...)
}
if len(args) == 0 {
return nil, errors.New("no command has been set")
}
return args, nil
}
func metaMount(stdin string) (llb.State, string) {
meta := llb.Mkdir(buildkit.MetaSourcePath, 0o777)
if stdin != "" {
meta = meta.Mkfile(path.Join(buildkit.MetaSourcePath, "stdin"), 0o600, []byte(stdin))
}
return llb.Scratch().File(
meta,
llb.WithCustomName(buildkit.InternalPrefix+"creating dagger metadata"),
),
buildkit.MetaSourcePath
}
type ContainerExecOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Args []string
SkipEntrypoint bool `default:"false"`
Stdin string `default:""`
RedirectStdout string `default:""`
RedirectStderr string `default:""`
ExperimentalPrivilegedNesting bool `default:"false"`
InsecureRootCapabilities bool `default:"false"`
ModuleCallerDigest digest.Digest `name:"-"`
NestedInSameSession bool `name:"-"`
}
type BuildArg struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | Name string `field:"true" doc:"The build argument name."`
Value string `field:"true" doc:"The build argument value."`
}
func (BuildArg) TypeName() string {
return "BuildArg"
}
func (BuildArg) TypeDescription() string {
return "Key value object that represents a build argument."
}
const ociTagAnnotation = "org.opencontainers.image.ref.name"
func resolveIndex(ctx context.Context, store content.Store, desc specs.Descriptor, platform specs.Platform, tag string) (*specs.Descriptor, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | if desc.MediaType != specs.MediaTypeImageIndex {
return nil, fmt.Errorf("expected index, got %s", desc.MediaType)
}
indexBlob, err := content.ReadBlob(ctx, store, desc)
if err != nil {
return nil, fmt.Errorf("read index blob: %w", err)
}
var idx specs.Index
err = json.Unmarshal(indexBlob, &idx)
if err != nil {
return nil, fmt.Errorf("unmarshal index: %w", err)
}
matcher := platforms.Only(platform)
for _, m := range idx.Manifests {
if m.Platform != nil {
if !matcher.Match(*m.Platform) {
continue
}
}
if tag != "" {
if m.Annotations == nil {
continue
}
manifestTag, found := m.Annotations[ociTagAnnotation]
if !found || manifestTag != tag {
continue |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | }
}
switch m.MediaType {
case specs.MediaTypeImageManifest,
images.MediaTypeDockerSchema2Manifest:
return &m, nil
case specs.MediaTypeImageIndex,
images.MediaTypeDockerSchema2ManifestList:
return resolveIndex(ctx, store, m, platform, tag)
default:
return nil, fmt.Errorf("expected manifest or index, got %s", m.MediaType)
}
}
return nil, fmt.Errorf("no manifest for platform %s and tag %s", platforms.Format(platform), tag)
}
type ImageLayerCompression string
var ImageLayerCompressions = dagql.NewEnum[ImageLayerCompression]()
var (
CompressionGzip = ImageLayerCompressions.Register("Gzip")
CompressionZstd = ImageLayerCompressions.Register("Zstd")
CompressionEStarGZ = ImageLayerCompressions.Register("EStarGZ")
CompressionUncompressed = ImageLayerCompressions.Register("Uncompressed")
)
func (proto ImageLayerCompression) Type() *ast.Type {
return &ast.Type{
NamedType: "ImageLayerCompression",
NonNull: true,
}
}
func (proto ImageLayerCompression) TypeDescription() string { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/container.go | return "Compression algorithm to use for image layers."
}
func (proto ImageLayerCompression) Decoder() dagql.InputDecoder {
return ImageLayerCompressions
}
func (proto ImageLayerCompression) ToLiteral() *idproto.Literal {
return ImageLayerCompressions.Literal(proto)
}
type ImageMediaTypes string
var ImageMediaTypesEnum = dagql.NewEnum[ImageMediaTypes]()
var (
OCIMediaTypes = ImageMediaTypesEnum.Register("OCIMediaTypes")
DockerMediaTypes = ImageMediaTypesEnum.Register("DockerMediaTypes")
)
func (proto ImageMediaTypes) Type() *ast.Type {
return &ast.Type{
NamedType: "ImageMediaTypes",
NonNull: true,
}
}
func (proto ImageMediaTypes) TypeDescription() string {
return "Mediatypes to use in published or exported image metadata."
}
func (proto ImageMediaTypes) Decoder() dagql.InputDecoder {
return ImageMediaTypesEnum
}
func (proto ImageMediaTypes) ToLiteral() *idproto.Literal {
return ImageMediaTypesEnum.Literal(proto)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | package core
import (
"bytes"
_ "embed"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"testing"
"github.com/containerd/containerd/platforms"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/moby/buildkit/identity"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"dagger.io/dagger"
"github.com/dagger/dagger/core"
"github.com/dagger/dagger/core/schema"
"github.com/dagger/dagger/engine/buildkit"
"github.com/dagger/dagger/internal/testutil"
)
func TestContainerScratch(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
ID string
Rootfs struct {
Entries []string
}
}
}{}
err := testutil.Query(
`{
container {
id
rootfs {
entries
}
}
}`, &res, nil)
require.NoError(t, err)
require.Empty(t, res.Container.Rootfs.Entries)
}
func TestContainerFrom(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
File struct {
Contents string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
file(path: "/etc/alpine-release") {
contents
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.File.Contents, "3.18.2\n")
}
func TestContainerBuild(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | c, ctx := connect(t)
contextDir := c.Directory().
WithNewFile("main.go",
`package main
import "fmt"
import "os"
func main() {
for _, env := range os.Environ() {
fmt.Println(env)
}
}`)
t.Run("default Dockerfile location", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
env, err := c.Container().Build(src).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
})
t.Run("custom Dockerfile location", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | src := contextDir.
WithNewFile("subdir/Dockerfile.whee",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
env, err := c.Container().Build(src, dagger.ContainerBuildOpts{
Dockerfile: "subdir/Dockerfile.whee",
}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
})
t.Run("subdirectory with default Dockerfile location", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
sub := c.Directory().WithDirectory("subcontext", src).Directory("subcontext")
env, err := c.Container().Build(sub).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | require.Contains(t, env, "FOO=bar\n")
})
t.Run("subdirectory with custom Dockerfile location", func(t *testing.T) {
src := contextDir.
WithNewFile("subdir/Dockerfile.whee",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
sub := c.Directory().WithDirectory("subcontext", src).Directory("subcontext")
env, err := c.Container().Build(sub, dagger.ContainerBuildOpts{
Dockerfile: "subdir/Dockerfile.whee",
}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
})
t.Run("with build args", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
ARG FOOARG=bar
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=$FOOARG |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | CMD goenv
`)
env, err := c.Container().Build(src).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
env, err = c.Container().Build(src, dagger.ContainerBuildOpts{BuildArgs: []dagger.BuildArg{{Name: "FOOARG", Value: "barbar"}}}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=barbar\n")
})
t.Run("with target", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine AS base
CMD echo "base"
FROM base AS stage1
CMD echo "stage1"
FROM base AS stage2
CMD echo "stage2"
`)
output, err := c.Container().Build(src).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, output, "stage2\n")
output, err = c.Container().Build(src, dagger.ContainerBuildOpts{Target: "stage1"}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, output, "stage1\n")
require.NotContains(t, output, "stage2\n")
})
t.Run("with build secrets", func(t *testing.T) {
sec := c.SetSecret("my-secret", "barbar")
src := contextDir. |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
WORKDIR /src
RUN --mount=type=secret,id=my-secret test "$(cat /run/secrets/my-secret)" = "barbar"
RUN --mount=type=secret,id=my-secret cp /run/secrets/my-secret /secret
CMD cat /secret
`)
stdout, err := c.Container().Build(src, dagger.ContainerBuildOpts{
Secrets: []*dagger.Secret{sec},
}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, stdout, "***")
})
t.Run("just build, don't execute", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile", "FROM "+alpineImage+"\nCMD false")
_, err := c.Container().Build(src).Sync(ctx)
require.NoError(t, err)
_, err = c.Container().Build(src).WithExec(nil).Sync(ctx)
require.NotEmpty(t, err)
})
t.Run("just build, short-circuit", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile", "FROM "+alpineImage+"\nRUN false")
_, err := c.Container().Build(src).Sync(ctx)
require.NotEmpty(t, err)
})
}
func TestContainerWithRootFS(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
alpine316 := c.Container().From(alpineImage)
alpine316ReleaseStr, err := alpine316.File("/etc/alpine-release").Contents(ctx)
require.NoError(t, err)
alpine316ReleaseStr = strings.TrimSpace(alpine316ReleaseStr)
dir := alpine316.Rootfs()
_, err = c.Container().WithEnvVariable("ALPINE_RELEASE", alpine316ReleaseStr).WithRootfs(dir).WithExec([]string{
"/bin/sh",
"-c",
"test -f /etc/alpine-release && test \"$(head -n 1 /etc/alpine-release)\" = \"$ALPINE_RELEASE\"",
}).Sync(ctx)
require.NoError(t, err)
alpine315 := c.Container().From(alpineImage)
varVal := "testing123"
alpine315WithVar := alpine315.WithEnvVariable("DAGGER_TEST", varVal)
varValResp, err := alpine315WithVar.EnvVariable(ctx, "DAGGER_TEST")
require.NoError(t, err)
require.Equal(t, varVal, varValResp)
alpine315ReplacedFS := alpine315WithVar.WithRootfs(dir)
varValResp, err = alpine315ReplacedFS.EnvVariable(ctx, "DAGGER_TEST")
require.NoError(t, err)
require.Equal(t, varVal, varValResp)
releaseStr, err := alpine315ReplacedFS.File("/etc/alpine-release").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "3.18.2\n", releaseStr)
}
var helloSrc string
func TestContainerWithRootFSSubdir(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
hello := c.Directory().WithNewFile("main.go", helloSrc).File("main.go")
ctr := c.Container().
From(golangImage).
WithMountedFile("/src/main.go", hello).
WithEnvVariable("CGO_ENABLED", "0").
WithExec([]string{"go", "build", "-o", "/out/hello", "/src/main.go"})
out, err := c.Container().
WithRootfs(ctr.Directory("/out")).
WithExec([]string{"/hello"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "Hello, world!\n", out)
}
func TestContainerExecSync(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(args: ["false"]) {
sync
}
}
}
}`, nil, nil)
require.Contains(t, err.Error(), `process "false" did not complete successfully`)
}
func TestContainerExecStdoutStderr(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
WithExec struct {
Stdout string
Stderr string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"]) {
stdout
stderr
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithExec.Stdout, "hello\n")
require.Equal(t, res.Container.From.WithExec.Stderr, "goodbye\n")
}
func TestContainerExecStdin(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
WithExec struct {
Stdout string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(args: ["cat"], stdin: "hello") {
stdout
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithExec.Stdout, "hello")
}
func TestContainerExecRedirectStdoutStderr(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
WithExec struct {
Out, Err struct {
Contents string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(
args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"],
redirectStdout: "out",
redirectStderr: "err"
) {
out: file(path: "out") {
contents
}
err: file(path: "err") {
contents
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | }
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithExec.Out.Contents, "hello\n")
require.Equal(t, res.Container.From.WithExec.Err.Contents, "goodbye\n")
c, ctx := connect(t)
execWithMount := c.Container().From(alpineImage).
WithMountedDirectory("/mnt", c.Directory()).
WithExec([]string{"sh", "-c", "echo hello; echo goodbye >/dev/stderr"}, dagger.ContainerWithExecOpts{
RedirectStdout: "/mnt/out",
RedirectStderr: "/mnt/err",
})
stdout, err := execWithMount.File("/mnt/out").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "hello\n", stdout)
stderr, err := execWithMount.File("/mnt/err").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "goodbye\n", stderr)
_, err = execWithMount.Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hello\n", stdout)
_, err = execWithMount.Stderr(ctx)
require.NoError(t, err)
require.Equal(t, "goodbye\n", stderr)
}
func TestContainerExecWithWorkdir(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
WithWorkdir struct {
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withWorkdir(path: "/usr") {
withExec(args: ["pwd"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithWorkdir.WithExec.Stdout, "/usr\n")
}
func TestContainerExecWithoutWorkdir(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
res, err := c.Container().
From(alpineImage).
WithWorkdir("/usr").
WithoutWorkdir().
WithExec([]string{"pwd"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "/\n", res)
}
func TestContainerExecWithUser(t *testing.T) {
t.Parallel()
res := struct {
Container struct {
From struct {
User string
WithUser struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | User string
WithExec struct {
Stdout string
}
}
}
}
}{}
t.Run("user name", func(t *testing.T) {
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "daemon") {
user
withExec(args: ["whoami"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "daemon", res.Container.From.WithUser.User)
require.Equal(t, "daemon\n", res.Container.From.WithUser.WithExec.Stdout)
})
t.Run("user and group name", func(t *testing.T) {
err := testutil.Query( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | `{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "daemon:floppy") {
user
withExec(args: ["sh", "-c", "whoami; groups"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "daemon:floppy", res.Container.From.WithUser.User)
require.Equal(t, "daemon\nfloppy\n", res.Container.From.WithUser.WithExec.Stdout)
})
t.Run("user ID", func(t *testing.T) {
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "2") {
user
withExec(args: ["whoami"]) {
stdout
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | }
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "2", res.Container.From.WithUser.User)
require.Equal(t, "daemon\n", res.Container.From.WithUser.WithExec.Stdout)
})
t.Run("user and group ID", func(t *testing.T) {
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "2:11") {
user
withExec(args: ["sh", "-c", "whoami; groups"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "2:11", res.Container.From.WithUser.User)
require.Equal(t, "daemon\nfloppy\n", res.Container.From.WithUser.WithExec.Stdout)
})
}
func TestContainerExecWithoutUser(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
res, err := c.Container().
From(alpineImage).
WithUser("daemon").
WithoutUser().
WithExec([]string{"whoami"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "root\n", res)
}
func TestContainerExecWithEntrypoint(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := c.Container().From(alpineImage)
withEntry := base.WithEntrypoint([]string{"sh"})
t.Run("before", func(t *testing.T) {
t.Parallel()
before, err := base.Entrypoint(ctx)
require.NoError(t, err)
require.Empty(t, before)
})
t.Run("after", func(t *testing.T) {
t.Parallel()
after, err := withEntry.Entrypoint(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | require.Equal(t, []string{"sh"}, after)
})
t.Run("used", func(t *testing.T) {
t.Parallel()
used, err := withEntry.WithExec([]string{"-c", "echo $HOME"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "/root\n", used)
})
t.Run("prepended to exec", func(t *testing.T) {
t.Parallel()
_, err := withEntry.WithExec([]string{"sh", "-c", "echo $HOME"}).Sync(ctx)
require.Error(t, err)
require.ErrorContains(t, err, "can't open 'sh'")
})
t.Run("skipped", func(t *testing.T) {
t.Parallel()
skipped, err := withEntry.WithExec([]string{"sh", "-c", "echo $HOME"}, dagger.ContainerWithExecOpts{
SkipEntrypoint: true,
}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "/root\n", skipped)
})
t.Run("unset default args", func(t *testing.T) {
t.Parallel()
removed, err := base.
WithDefaultArgs([]string{"foobar"}).
WithEntrypoint([]string{"echo"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "\n", removed) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | })
t.Run("kept default args", func(t *testing.T) {
t.Parallel()
kept, err := base.
WithDefaultArgs([]string{"foobar"}).
WithEntrypoint([]string{"echo"}, dagger.ContainerWithEntrypointOpts{
KeepDefaultArgs: true,
}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foobar\n", kept)
})
t.Run("cleared", func(t *testing.T) {
t.Parallel()
withoutEntry := withEntry.WithEntrypoint(nil)
removed, err := withoutEntry.Entrypoint(ctx)
require.NoError(t, err)
require.Empty(t, removed)
})
}
func TestContainerExecWithoutEntrypoint(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
t.Run("cleared entrypoint", func(t *testing.T) {
res, err := c.Container().
From(alpineImage).
WithEntrypoint([]string{"foo"}).
WithoutEntrypoint().
WithExec([]string{"echo", "-n", "foobar"}). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foobar", res)
})
t.Run("cleared entrypoint with default args", func(t *testing.T) {
res, err := c.Container().
From(alpineImage).
WithEntrypoint([]string{"foo"}).
WithDefaultArgs([]string{"echo", "-n", "foobar"}).
WithoutEntrypoint().
Stdout(ctx)
require.ErrorContains(t, err, "no command has been set")
require.Empty(t, res)
})
t.Run("cleared entrypoint without default args", func(t *testing.T) {
res, err := c.Container().
From(alpineImage).
WithEntrypoint([]string{"foo"}).
WithDefaultArgs([]string{"echo", "-n", "foobar"}).
WithoutEntrypoint(dagger.ContainerWithoutEntrypointOpts{
KeepDefaultArgs: true,
}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foobar", res)
})
}
func TestContainerWithDefaultArgs(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
Entrypoint []string
DefaultArgs []string
WithExec struct {
Stdout string
}
WithDefaultArgs struct {
Entrypoint []string
DefaultArgs []string
}
WithEntrypoint struct {
Entrypoint []string
DefaultArgs []string
WithExec struct {
Stdout string
}
WithDefaultArgs struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Entrypoint []string
DefaultArgs []string
WithExec struct {
Stdout string
}
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
entrypoint
defaultArgs
withDefaultArgs(args: []) {
entrypoint
defaultArgs
}
withEntrypoint(args: ["sh", "-c"]) {
entrypoint
defaultArgs
withExec(args: ["echo $HOME"]) {
stdout
}
withDefaultArgs(args: ["id"]) {
entrypoint
defaultArgs
withExec(args: []) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | stdout
}
}
}
}
}
}`, &res, nil)
t.Run("default alpine (no entrypoint)", func(t *testing.T) {
require.NoError(t, err)
require.Empty(t, res.Container.From.Entrypoint)
require.Equal(t, []string{"/bin/sh"}, res.Container.From.DefaultArgs)
})
t.Run("with nil default args", func(t *testing.T) {
require.Empty(t, res.Container.From.WithDefaultArgs.Entrypoint)
require.Empty(t, res.Container.From.WithDefaultArgs.DefaultArgs)
})
t.Run("with entrypoint set", func(t *testing.T) {
require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.Entrypoint)
require.Empty(t, res.Container.From.WithEntrypoint.DefaultArgs)
})
t.Run("with exec args", func(t *testing.T) {
require.Equal(t, "/root\n", res.Container.From.WithEntrypoint.WithExec.Stdout)
})
t.Run("with default args set", func(t *testing.T) {
require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.WithDefaultArgs.Entrypoint)
require.Equal(t, []string{"id"}, res.Container.From.WithEntrypoint.WithDefaultArgs.DefaultArgs)
require.Equal(t, "uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)\n", res.Container.From.WithEntrypoint.WithDefaultArgs.WithExec.Stdout)
})
}
func TestContainerExecWithoutDefaultArgs(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
res, err := c.Container().
From(alpineImage).
WithEntrypoint([]string{"echo", "-n"}).
WithDefaultArgs([]string{"foo"}).
WithoutDefaultArgs().
WithExec([]string{}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "", res)
}
func TestContainerExecWithEnvVariable(t *testing.T) {
t.Parallel()
res := struct {
Container struct {
From struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | WithEnvVariable struct {
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withEnvVariable(name: "FOO", value: "bar") {
withExec(args: ["env"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Contains(t, res.Container.From.WithEnvVariable.WithExec.Stdout, "FOO=bar\n")
}
func TestContainerVariables(t *testing.T) {
t.Parallel()
res := struct {
Container struct {
From struct {
EnvVariables []schema.EnvVariable
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Stdout string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
envVariables {
name
value
}
withExec(args: ["env"]) {
stdout
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, []schema.EnvVariable{
{Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
{Name: "GOLANG_VERSION", Value: "1.18.2"},
{Name: "GOPATH", Value: "/go"},
}, res.Container.From.EnvVariables)
require.Contains(t, res.Container.From.WithExec.Stdout, "GOPATH=/go\n")
}
func TestContainerVariable(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Container struct {
From struct {
EnvVariable *string
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
envVariable(name: "GOLANG_VERSION")
}
}
}`, &res, nil)
require.NoError(t, err)
require.NotNil(t, res.Container.From.EnvVariable)
require.Equal(t, "1.18.2", *res.Container.From.EnvVariable)
err = testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
envVariable(name: "UNKNOWN")
}
}
}`, &res, nil)
require.NoError(t, err)
require.Nil(t, res.Container.From.EnvVariable)
}
func TestContainerWithoutVariable(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
res := struct {
Container struct {
From struct {
WithoutEnvVariable struct {
EnvVariables []schema.EnvVariable
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
withoutEnvVariable(name: "GOLANG_VERSION") {
envVariables {
name
value
}
withExec(args: ["env"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithoutEnvVariable.EnvVariables, []schema.EnvVariable{
{Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
{Name: "GOPATH", Value: "/go"},
})
require.NotContains(t, res.Container.From.WithoutEnvVariable.WithExec.Stdout, "GOLANG_VERSION")
}
func TestContainerEnvVariablesReplace(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | t.Parallel()
res := struct {
Container struct {
From struct {
WithEnvVariable struct {
EnvVariables []schema.EnvVariable
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
withEnvVariable(name: "GOPATH", value: "/gone") {
envVariables {
name |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | value
}
withExec(args: ["env"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithEnvVariable.EnvVariables, []schema.EnvVariable{
{Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
{Name: "GOLANG_VERSION", Value: "1.18.2"},
{Name: "GOPATH", Value: "/gone"},
})
require.Contains(t, res.Container.From.WithEnvVariable.WithExec.Stdout, "GOPATH=/gone\n")
}
func TestContainerWithEnvVariableExpand(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
t.Run("add env var without expansion", func(t *testing.T) {
out, err := c.Container().
From(alpineImage).
WithEnvVariable("FOO", "foo:$PATH").
WithExec([]string{"printenv", "FOO"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foo:$PATH\n", out)
})
t.Run("add env var with expansion", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,510 | 🐞 `with_user` breaks `with_exec`'s `stdin` | ### What is the issue?
`with_exec`'s `stdin` parameter enables writing content to the command's standard input before it closes. However, if you switch to another user, it breaks without any notification, preventing the command from executing.
### Dagger version
dagger v0.9.7 (registry.dagger.io/engine) darwin/arm64
### Steps to reproduce
This works:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
Hello World!
1
2
3
4
5
6
7
8
9
10
⠼ Disconnecting⏎
```
This fails:
```python
import anyio
import dagger
from dagger import dag
async def main():
async with dagger.connection():
out = (
await dag.container()
.from_("alpine:latest")
.with_exec(["adduser", "-D", "bob"])
.with_user("bob")
.with_exec(
["sh"],
stdin="""
echo "Hello World!"
for i in $(seq 1 10); do
echo "$i"
sleep 1
done
""",
)
.stdout()
)
print(out)
anyio.run(main)
```
Outputs:
```
⠇ Disconnecting⏎
```
### Log output
_No response_ | https://github.com/dagger/dagger/issues/6510 | https://github.com/dagger/dagger/pull/6511 | 30b22dd06e4366aed01f8f86d0a1729835b12aec | 6a31727f759d9137f5940458a06e196ab99b0717 | 2024-01-26T20:02:16Z | go | 2024-01-29T12:22:43Z | core/integration/container_test.go | out, err := c.Container().
From(alpineImage).
WithEnvVariable("USER_PATH", "/opt").
WithEnvVariable(
"PATH",
"${USER_PATH}/bin:$PATH",
dagger.ContainerWithEnvVariableOpts{
Expand: true,
},
).
WithExec([]string{"printenv", "PATH"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t,
"/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n",
out,
)
})
}
func TestContainerLabel(t *testing.T) {
c, ctx := connect(t)
t.Run("container with new label", func(t *testing.T) {
label, err := c.Container().From(alpineImage).WithLabel("FOO", "BAR").Label(ctx, "FOO")
require.NoError(t, err)
require.Contains(t, label, "BAR")
})
t.Run("container labels", func(t *testing.T) {
res := struct { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.