aboutsummaryrefslogtreecommitdiff
path: root/docker.go
blob: 1157e39900591b0e7beb62c8d66b5b9c9191f5f3 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//+build ignore

// Makes the docker image xena/xperimental.
package main

import (
	"context"
	"flag"
	"log"
	"path/filepath"

	"within.website/x/internal"
	"within.website/x/internal/yeet"
)

var (
	dontPush = flag.Bool("dont-push", false, "if set, don't push docker images")
)

func main() {
	internal.HandleStartup()
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	tag := "xena/xperimental"
	yeet.DockerBuild(ctx, yeet.WD, tag)

	resTag := yeet.DockerTag(ctx, "xena", "xperimental", tag)
	otherResTag := yeet.DockerTag(ctx, "docker.pkg.github.com/xe/x", "xperimental", tag)

	gitTag, err := yeet.GitTag(ctx)
	if err != nil {
		log.Fatal(err)
	}

	dnsdTag := "xena/dnsd:" + gitTag

	yeet.DockerBuild(ctx, filepath.Join(yeet.WD, "cmd", "dnsd"), dnsdTag, "--build-arg", "X_VERSION="+gitTag)
	dnsdGithubTag := yeet.DockerTag(ctx, "docker.pkg.github.com/xe/x", "dnsd", dnsdTag)

	if !*dontPush {
		yeet.ShouldWork(ctx, nil, yeet.WD, "docker", "push", resTag)
		yeet.ShouldWork(ctx, nil, yeet.WD, "docker", "push", otherResTag)
		yeet.ShouldWork(ctx, nil, yeet.WD, "docker", "push", dnsdGithubTag)
	}

	log.Printf("xperimental:\t%s", otherResTag)
	log.Printf("dnsd:\t%s", dnsdGithubTag)
}