aboutsummaryrefslogtreecommitdiff
path: root/docker.go
blob: d99f3f6c16bb300ecc330ca95bfb7f60eed4e28c (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
50
51
52
53
54
//+build ignore

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

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

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

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

func main() {
	flag.Parse()
	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)

	hTag := "docker.pkg.github.com/xe/x/h:" + gitTag

	yeet.DockerBuild(ctx, filepath.Join(yeet.WD, "cmd", "h"), hTag, "--build-arg", "X_VERSION="+gitTag)

	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)
		yeet.ShouldWork(ctx, nil, yeet.WD, "docker", "push", hTag)
	}

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