-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (29 loc) · 880 Bytes
/
main.go
File metadata and controls
34 lines (29 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Deploy apps to Fly.io
//
// Basic Dagger module for deploying apps to Fly.io
package main
import (
"context"
)
type Flyio struct{}
// Deploy deploys an app from the src folder to Fly.io
func (m *Flyio) Deploy(ctx context.Context,
// +required
src *Directory,
// +required
token *Secret) (string, error) {
return m.FlyContainer(ctx, token).
WithMountedDirectory("/src", src).
WithWorkdir("/src").
WithExec([]string{"/root/.fly/bin/flyctl", "deploy"}).
Stdout(ctx)
}
// FlyContainer creates a container with the flyctl CLI installed
func (m *Flyio) FlyContainer(ctx context.Context, token *Secret) *Container {
return dag.Container().
From("alpine:3.20.0").
WithExec([]string{"apk", "add", "curl"}).
WithExec([]string{"curl", "-LO", "https://fly.io/install.sh"}).
WithExec([]string{"sh", "install.sh"}).
WithSecretVariable("FLY_API_TOKEN", token)
}