@@ -30,6 +30,7 @@ type RegistryType string
3030const (
3131 RegistryTypeLocalContainer RegistryType = "local-container"
3232 RegistryTypeArtifactRegistry RegistryType = "artifact-registry"
33+ RegistryTypeGitHub RegistryType = "github"
3334)
3435
3536type VMDef struct {
@@ -81,6 +82,8 @@ type CodesphereEnvironment struct {
8182 GatewayIP string `json:"gateway_ip"`
8283 PublicGatewayIP string `json:"public_gateway_ip"`
8384 RegistryType RegistryType `json:"registry_type"`
85+ GitHubPAT string `json:"-"`
86+ RegistryUser string `json:"-"`
8487
8588 // Config
8689 InstallConfigPath string `json:"-"`
@@ -215,6 +218,13 @@ func (b *GCPBootstrapper) Bootstrap() error {
215218 }
216219 }
217220
221+ if b .Env .RegistryType == RegistryTypeGitHub {
222+ err = b .stlog .Step ("Ensure GitHub access configured" , b .EnsureGitHubAccessConfigured )
223+ if err != nil {
224+ return fmt .Errorf ("failed to update install config: %w" , err )
225+ }
226+ }
227+
218228 if b .Env .WriteConfig {
219229 err = b .stlog .Step ("Update install config" , b .UpdateInstallConfig )
220230 if err != nil {
@@ -563,6 +573,10 @@ func (b *GCPBootstrapper) EnsureComputeInstances() error {
563573 wg := sync.WaitGroup {}
564574 errCh := make (chan error , len (vmDefs ))
565575 resultCh := make (chan vmResult , len (vmDefs ))
576+ rootDiskSize := int64 (200 )
577+ if b .Env .RegistryType == RegistryTypeGitHub {
578+ rootDiskSize = 50
579+ }
566580 for _ , vm := range vmDefs {
567581 wg .Add (1 )
568582 go func (vm VMDef ) {
@@ -574,7 +588,7 @@ func (b *GCPBootstrapper) EnsureComputeInstances() error {
574588 Type : protoString ("PERSISTENT" ),
575589 InitializeParams : & computepb.AttachedDiskInitializeParams {
576590 DiskType : & diskType ,
577- DiskSizeGb : protoInt64 (200 ),
591+ DiskSizeGb : protoInt64 (rootDiskSize ),
578592 SourceImage : protoString ("projects/ubuntu-os-cloud/global/images/family/ubuntu-2204-lts" ),
579593 },
580594 },
@@ -917,15 +931,28 @@ func (b *GCPBootstrapper) EnsureLocalContainerRegistry() error {
917931
918932 return nil
919933}
934+ func (b * GCPBootstrapper ) EnsureGitHubAccessConfigured () error {
935+ if b .Env .GitHubPAT == "" {
936+ return fmt .Errorf ("GitHub PAT is not set" )
937+ }
938+ b .Env .InstallConfig .Registry .Server = "ghcr.io"
939+ b .Env .InstallConfig .Registry .Username = b .Env .RegistryUser
940+ b .Env .InstallConfig .Registry .Password = b .Env .GitHubPAT
941+ b .Env .InstallConfig .Registry .ReplaceImagesInBom = false
942+ b .Env .InstallConfig .Registry .LoadContainerImages = false
943+ return nil
944+ }
920945
921946func (b * GCPBootstrapper ) UpdateInstallConfig () error {
922947 // Update install config with necessary values
923948 b .Env .InstallConfig .Datacenter .ID = b .Env .DatacenterID
924949 b .Env .InstallConfig .Datacenter .City = "Karlsruhe"
925950 b .Env .InstallConfig .Datacenter .CountryCode = "DE"
926951 b .Env .InstallConfig .Secrets .BaseDir = b .Env .SecretsDir
927- b .Env .InstallConfig .Registry .ReplaceImagesInBom = true
928- b .Env .InstallConfig .Registry .LoadContainerImages = true
952+ if b .Env .RegistryType != RegistryTypeGitHub {
953+ b .Env .InstallConfig .Registry .ReplaceImagesInBom = true
954+ b .Env .InstallConfig .Registry .LoadContainerImages = true
955+ }
929956
930957 if b .Env .InstallConfig .Postgres .Primary == nil {
931958 b .Env .InstallConfig .Postgres .Primary = & files.PostgresPrimaryConfig {
@@ -1245,12 +1272,23 @@ func (b *GCPBootstrapper) EnsureDNSRecords() error {
12451272}
12461273
12471274func (b * GCPBootstrapper ) InstallCodesphere () error {
1248- err := b .Env .Jumpbox .RunSSHCommand ("root" , "oms-cli download package " + b .Env .InstallCodesphereVersion )
1275+ packageFile := "installer.tar.gz"
1276+ skipSteps := ""
1277+ if b .Env .RegistryType == RegistryTypeGitHub {
1278+ skipSteps = " -s load-container-images"
1279+ packageFile = "installer-lite.tar.gz"
1280+ }
1281+
1282+ downloadCmd := "oms-cli download package -f " + packageFile + " " + b .Env .InstallCodesphereVersion
1283+ installCmd := fmt .Sprintf ("oms-cli install codesphere -c /etc/codesphere/config.yaml -k %s/age_key.txt -p %s-%s%s" ,
1284+ b .Env .SecretsDir , b .Env .InstallCodesphereVersion , packageFile , skipSteps )
1285+
1286+ err := b .Env .Jumpbox .RunSSHCommand ("root" , downloadCmd )
12491287 if err != nil {
12501288 return fmt .Errorf ("failed to download Codesphere package from jumpbox: %w" , err )
12511289 }
12521290
1253- err = b .Env .Jumpbox .RunSSHCommand ("root" , "oms-cli install codesphere -c /etc/codesphere/config.yaml -k " + b . Env . SecretsDir + "/age_key.txt -p " + b . Env . InstallCodesphereVersion + ".tar.gz" )
1291+ err = b .Env .Jumpbox .RunSSHCommand ("root" , installCmd )
12541292 if err != nil {
12551293 return fmt .Errorf ("failed to install Codesphere from jumpbox: %w" , err )
12561294 }
0 commit comments