Skip to content

Commit b9f20a4

Browse files
authored
feat: separate starship installation by using fixed image (tensorchord#1424)
* feat: separate starship installation by using fixed image Signed-off-by: Kaiyang-Chen <[email protected]> * feat: add starship dockerfile Signed-off-by: Kaiyang-Chen <[email protected]> * feat: change starship dockerfile to multi-stage build to reduce size Signed-off-by: Kaiyang-Chen <[email protected]> * feat: change starship dockerfile base build image to scratch to reduce size Signed-off-by: Kaiyang-Chen <[email protected]> * feat: seperate starship installation in frontend v0 Signed-off-by: Kaiyang-Chen <[email protected]> * feat: add ci for starship image release Signed-off-by: Kaiyang-Chen <[email protected]> * fix: change ci action to docker/build-push Signed-off-by: Kaiyang-Chen <[email protected]> --------- Signed-off-by: Kaiyang-Chen <[email protected]>
1 parent 2ae200b commit b9f20a4

File tree

6 files changed

+65
-5
lines changed

6 files changed

+65
-5
lines changed

.github/workflows/envd-starship.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types: [created]
6+
# Allows you to run this workflow manually from the Actions tab
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.ref }}-${{ github.workflow }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
15+
docker:
16+
name: Push starship image to Docker Hub
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Docker Login
21+
uses: docker/login-action@v2
22+
with:
23+
username: ${{ secrets.DOCKERIO_USERNAME }}
24+
password: ${{ secrets.DOCKERIO_TOKEN }}
25+
- name: Docker Setup QEMU
26+
uses: docker/setup-qemu-action@v2
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
- name: Build and push
30+
uses: docker/build-push-action@v3
31+
with:
32+
push: true
33+
file: base-images/envd-starship/envd-starship.Dockerfile
34+
platforms: linux/amd64,linux/arm64
35+
tags: tensorchord/starship:v0.0.1
36+
cache-from: type=gha
37+
cache-to: type=gha,mode=max
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM curlimages/curl:7.87.0 as builder
2+
USER root
3+
RUN curl --proto '=https' --tlsv1.2 -sSf https://starship.rs/install.sh | sh -s -- -y
4+
5+
FROM scratch as prod
6+
COPY --from=builder /usr/local/bin/starship /usr/local/bin/starship

pkg/lang/ir/v0/system.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ func (g *generalGraph) preparePythonBase(root llb.State) llb.State {
157157
sb.WriteString(strings.Join(types.BaseAptPackage, " "))
158158
sb.WriteString("&& rm -rf /var/lib/apt/lists/* ")
159159
// shell prompt
160-
sb.WriteString("&& curl --proto '=https' --tlsv1.2 -sSf https://starship.rs/install.sh | sh -s -- -y")
161160
sb.WriteString("&& locale-gen en_US.UTF-8")
162161

163162
run := root.Run(llb.Shlexf(`bash -c "%s"`, sb.String()),
@@ -174,6 +173,14 @@ func (g generalGraph) compileSSHD(root llb.State) llb.State {
174173
return sshd
175174
}
176175

176+
func (g generalGraph) compileStarship(root llb.State) llb.State {
177+
starship := root.File(llb.Copy(
178+
llb.Image(types.EnvdStarshipImage), "/usr/local/bin/starship", "/usr/local/bin/starship",
179+
&llb.CopyInfo{CreateDestPath: true}),
180+
llb.WithCustomName(fmt.Sprintf("[internal] add envd-starship from %s", types.EnvdStarshipImage)))
181+
return starship
182+
}
183+
177184
func (g *generalGraph) compileBase() (llb.State, error) {
178185
logger := logrus.WithFields(logrus.Fields{
179186
"os": g.OS,
@@ -217,7 +224,8 @@ func (g *generalGraph) compileBase() (llb.State, error) {
217224
condaStage := g.installConda(base)
218225
supervisor := g.installHorust(condaStage)
219226
sshdStage := g.compileSSHD(supervisor)
220-
source, err := g.compileExtraSource(sshdStage)
227+
starshipStage := g.compileStarship(sshdStage)
228+
source, err := g.compileExtraSource(starshipStage)
221229
if err != nil {
222230
return llb.State{}, errors.Wrap(err, "failed to get extra sources")
223231
}

pkg/lang/ir/v1/compile.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ func (g *generalGraph) CompileLLB(uid, gid int) (llb.State, error) {
292292
dev := g.compileDevPackages(base)
293293
sshd := g.compileSSHD(dev)
294294
horust := g.installHorust(sshd)
295-
userGroup := g.compileUserGroup(horust)
295+
starship := g.compileStarship(horust)
296+
userGroup := g.compileUserGroup(starship)
296297
base = userGroup
297298
}
298299

pkg/lang/ir/v1/system.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ func (g *generalGraph) compileDevPackages(root llb.State) llb.State {
281281
sb.WriteString(strings.Join(types.BaseAptPackage, " "))
282282
sb.WriteString("&& rm -rf /var/lib/apt/lists/* ")
283283
// shell prompt
284-
sb.WriteString("&& curl --proto '=https' --tlsv1.2 -sSf https://starship.rs/install.sh | sh -s -- -y")
285284
sb.WriteString("&& locale-gen en_US.UTF-8")
286285

287286
run := root.Run(llb.Shlexf(`bash -c "%s"`, sb.String()),
@@ -290,6 +289,14 @@ func (g *generalGraph) compileDevPackages(root llb.State) llb.State {
290289
return run.Root()
291290
}
292291

292+
func (g generalGraph) compileStarship(root llb.State) llb.State {
293+
starship := root.File(llb.Copy(
294+
llb.Image(types.EnvdStarshipImage), "/usr/local/bin/starship", "/usr/local/bin/starship",
295+
&llb.CopyInfo{CreateDestPath: true}),
296+
llb.WithCustomName(fmt.Sprintf("[internal] add envd-starship from %s", types.EnvdStarshipImage)))
297+
return starship
298+
}
299+
293300
func (g generalGraph) compileSSHD(root llb.State) llb.State {
294301
sshd := root.File(llb.Copy(
295302
llb.Image(types.EnvdSshdImage), "/usr/bin/envd-sshd", "/var/envd/bin/envd-sshd",

pkg/types/envd.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const (
3333
DefaultCondaPath = "/opt/conda/envs/envd/bin:/opt/conda/bin:/home/envd/.local/bin"
3434
DefaultJuliaPath = "/usr/local/julia/bin"
3535
// image
36-
PythonBaseImage = "ubuntu:20.04"
36+
PythonBaseImage = "ubuntu:20.04"
37+
EnvdStarshipImage = "tensorchord/starship:v0.0.1"
3738
// supervisor
3839
HorustImage = "tensorchord/horust:v0.2.1"
3940
HorustServiceDir = "/etc/horust/services"

0 commit comments

Comments
 (0)