Skip to content

Commit da65128

Browse files
authored
[Feature] Custom Extra Environment Variables in TEE instance (#35)
This PR resolves #26 ## Changes * Dockerfile is now dynamically constructed at the Job creation in memory. File system no longer used. (Resolves #3) * Dockerfile is stored in the DB * The Dockerfile has fields to specify dynamic environment variables * The Jupyterhub Spawner can set custom environment variables with prefix `MANATEE_EXTRA_ENV_`. ## Caveats * Currently, the dockerfile is specifically for Google Confidential Space backend. We need to make it support different backends (comment added) * I find it impossible to test the API with injecting DB dependency. So I could only do manual testing. ## Testing * Manual end-to-end testing * Added unit test for a new function `generateDockerfile`
1 parent bc3e696 commit da65128

File tree

13 files changed

+420
-86
lines changed

13 files changed

+420
-86
lines changed

app/dcr_api/BUILD.bazel

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,12 @@ pkg_tar(
3232
srcs = [":api"],
3333
)
3434

35-
# TODO: remove app_data and dockerfile when we stop using file system for building kaniko context
36-
# See https://github.com/manatee-project/manatee/issues/3
37-
pkg_tar(
38-
name = "app_data",
39-
empty_dirs = ["data"],
40-
package_dir = "/app",
41-
)
42-
43-
pkg_tar(
44-
name = "dockerfile",
45-
srcs = ["Dockerfile"],
46-
package_dir = "/usr/local/dcr_conf/",
47-
)
48-
4935
oci_image(
5036
name = "image",
5137
base = "@distroless_base_linux_amd64",
5238
entrypoint = ["/api"],
5339
tars = [
5440
":tar",
55-
":app_data",
56-
":dockerfile",
5741
],
5842
visibility = ["//visibility:public"],
5943
)

app/dcr_api/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/dcr_api/biz/dal/db/job.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ import (
2323

2424
type Job struct {
2525
gorm.Model
26-
ID uint64 `gorm:"id" json:"id""`
27-
UUID string `gorm:"uuid" json:"uuid"`
28-
Creator string `gorm:"creator" json:"creator"`
29-
JupyterFileName string `gorm:"jupyter_file_name" json:"jupyter_file_name"`
30-
BuildContextPath string `gorm:"build_context_path" json:"build_context_path"`
31-
DockerImage string `gorm:"docker_image" json:"docker_image"`
32-
DockerImageDigest string `gorm:"docker_image_digest" json:"docker_image_digest"`
33-
AttestationReport string `gorm:"attestation_report" json:"attestation_report"`
34-
JobStatus int `gorm:"job_status" json:"job_status"`
35-
InstanceName string `gorm:"instance_name" json:"instance_name"`
26+
ID uint64 `gorm:"id" json:"id""`
27+
UUID string `gorm:"uuid" json:"uuid"`
28+
Creator string `gorm:"creator" json:"creator"`
29+
JupyterFileName string `gorm:"jupyter_file_name" json:"jupyter_file_name"`
30+
BuildContextPath string `gorm:"build_context_path" json:"build_context_path"`
31+
Dockerfile string `gorm:"dockerfile" json:"dockerfile"`
32+
DockerImage string `gorm:"docker_image" json:"docker_image"`
33+
DockerImageDigest string `gorm:"docker_image_digest" json:"docker_image_digest"`
34+
AttestationReport string `gorm:"attestation_report" json:"attestation_report"`
35+
JobStatus int `gorm:"job_status" json:"job_status"`
36+
InstanceName string `gorm:"instance_name" json:"instance_name"`
37+
ExtraEnvs map[string]string `gorm:"serializer:json"`
3638
}
3739

3840
func (Job) TableName() string {
@@ -51,7 +53,16 @@ func CreateJob(job *Job) error {
5153
}
5254

5355
func UpdateJob(j *Job) error {
54-
result := DB.Model(j).Updates(Job{JobStatus: j.JobStatus, BuildContextPath: j.BuildContextPath, DockerImageDigest: j.DockerImageDigest, DockerImage: j.DockerImage, AttestationReport: j.AttestationReport, InstanceName: j.InstanceName})
56+
result := DB.Model(j).Updates(
57+
Job{
58+
JobStatus: j.JobStatus,
59+
BuildContextPath: j.BuildContextPath,
60+
DockerImageDigest: j.DockerImageDigest,
61+
DockerImage: j.DockerImage,
62+
AttestationReport: j.AttestationReport,
63+
InstanceName: j.InstanceName,
64+
ExtraEnvs: j.ExtraEnvs,
65+
})
5566
if result.Error != nil {
5667
return errors.Wrap(result.Error, "failed to update job %v")
5768
}

app/dcr_api/biz/handler/job/job_handler.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)