Skip to content

Commit

Permalink
Docker build logs (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno authored Oct 19, 2023
1 parent 28d66e1 commit 00628cc
Show file tree
Hide file tree
Showing 22 changed files with 561 additions and 109 deletions.
5 changes: 5 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ lint:
paths:
- "**/go.work.sum"
- "**/go.sum"
- linters: [gitleaks,trufflehog]
paths:
- "**/go.work.sum"
- "**/go.sum"

enabled:
- [email protected]
- [email protected]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.10
0.0.11
47 changes: 47 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN go mod download
COPY internal internal
COPY main.go main.go

RUN make build
RUN --mount=type=cache,target=/root/.cache/go-build make build

FROM alpine:3.17

Expand Down
6 changes: 6 additions & 0 deletions packages/api/api.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ variable "bucket_name" {
default = ""
}

variable "api_secret" {
type = string
default = ""
}

job "orchestration-api" {
datacenters = [var.gcp_zone]

Expand Down Expand Up @@ -108,6 +113,7 @@ job "orchestration-api" {
API_ADMIN_KEY = var.api_admin_key
ENVIRONMENT = var.environment
GOOGLE_CLOUD_STORAGE_BUCKET = var.bucket_name
API_SECRET = var.api_secret
}

config {
Expand Down
66 changes: 56 additions & 10 deletions packages/api/internal/api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 24 additions & 23 deletions packages/api/internal/api/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions packages/api/internal/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions packages/api/internal/db/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (

"github.com/volatiletech/sqlboiler/v4/queries/qm"

"github.com/volatiletech/sqlboiler/v4/boil"

"github.com/e2b-dev/infra/packages/api/internal/api"
"github.com/e2b-dev/infra/packages/api/internal/db/models"
"github.com/volatiletech/sqlboiler/v4/boil"
)

func (db *DB) DeleteEnv(envID string) error {
Expand All @@ -30,9 +31,11 @@ func (db *DB) GetEnvs(teamID string) (result []*api.Environment, err error) {

for _, env := range envs {
result = append(result, &api.Environment{
EnvID: env.ID,
Status: api.EnvironmentStatus(env.Status),
Public: env.Public,
EnvID: env.ID,
BuildID: "",
Status: api.EnvironmentStatus(env.Status),
Public: env.Public,
Logs: nil,
})
}

Expand All @@ -58,9 +61,11 @@ func (db *DB) GetEnv(envID string, teamID string) (env *api.Environment, err err
dbEnv := dbEnvs[0]

return &api.Environment{
EnvID: dbEnv.ID,
Status: api.EnvironmentStatus(dbEnv.Status),
Public: dbEnv.Public,
EnvID: dbEnv.ID,
BuildID: "",
Status: api.EnvironmentStatus(dbEnv.Status),
Logs: nil,
Public: dbEnv.Public,
}, nil
}

Expand All @@ -81,7 +86,7 @@ func (db *DB) CreateEnv(envID string, teamID string, dockerfile string) (*api.En
return nil, errMsg
}

return &api.Environment{EnvID: envID, Status: api.EnvironmentStatusBuilding, Public: false}, nil
return &api.Environment{EnvID: envID, BuildID: "", Logs: nil, Status: api.EnvironmentStatusBuilding, Public: false}, nil
}

func (db *DB) UpdateDockerfileEnv(envID string, dockerfile string) (*api.Environment, error) {
Expand All @@ -105,7 +110,7 @@ func (db *DB) UpdateDockerfileEnv(envID string, dockerfile string) (*api.Environ
return nil, fmt.Errorf("didn't find env to update, env with id '%s'", envID)
}

return &api.Environment{EnvID: envID, Status: api.EnvironmentStatusBuilding, Public: false}, nil
return &api.Environment{EnvID: envID, BuildID: "", Logs: nil, Status: api.EnvironmentStatusBuilding, Public: false}, nil
}

func (db *DB) UpdateStatusEnv(envID string, status models.EnvStatusEnum) (*api.Environment, error) {
Expand All @@ -127,7 +132,7 @@ func (db *DB) UpdateStatusEnv(envID string, status models.EnvStatusEnum) (*api.E
return nil, fmt.Errorf("didn't find env to update to, env with id '%s'", envID)
}

return &api.Environment{EnvID: envID, Status: api.EnvironmentStatus(status), Public: false}, nil
return &api.Environment{EnvID: envID, BuildID: "", Logs: nil, Status: api.EnvironmentStatus(status), Public: false}, nil
}

func (db *DB) HasEnvAccess(envID string, teamID string, public bool) (bool, error) {
Expand Down
Loading

0 comments on commit 00628cc

Please sign in to comment.