services/magefiles/mage.go
Dan Anglin 042f3e2364
fix: build GTS docker image from base Alpine image
Changes:

- Update the Dockerfile template to build the GTS image from alpine:3.17.
- Add logic to download and verify GTS packages.
- Allow the Download target to be more forgiving for a service that does not need to download any files.
- The Download target is now a dependency to the Render target for all services that aren't named 'compose'.
- Update the path to the web files in the GTS config file.
- Update the entrypoint to use the correct path of the GTS executable file.

Chores:

- Remove unused DockerImageDigest setting from GTS config.
2023-02-26 17:14:39 +00:00

62 lines
1.2 KiB
Go

//go:build mage
package main
import (
"fmt"
"os"
"github.com/magefile/mage/sh"
)
const (
configFile string = "./config/services.json"
rootBuildDir string = "./build"
templateExtension string = ".gotmpl"
rootTemplatesDir string = "./templates"
)
// Clean cleans the workspace.
func Clean() error {
buildDir := "./build"
objects, err := os.ReadDir(buildDir)
if err != nil {
return err
}
for i := range objects {
name := objects[i].Name()
if name != ".gitkeep" {
if err := sh.Rm(buildDir + "/" + name); err != nil {
return err
}
}
}
return nil
}
// Download downloads the binaries for a given service.
func Download(name string) error {
cfg, err := newConfig(configFile)
if err != nil {
return fmt.Errorf("unable to load the configuration; %v", err)
}
switch name {
case "forgejo":
if err := downloadForgejo(cfg.Forgejo.Version); err != nil {
return fmt.Errorf("an error occurred whilst getting the forgejo binary; %w", err)
}
case "gotosocial":
if err := downloadGoToSocial(cfg.GoToSocial.Version); err != nil {
return fmt.Errorf("an error occurred whilst getting the packages for GoToSocial; %w", err)
}
default:
fmt.Printf("'%s' has no files to download.\n", name)
}
return nil
}