Skip to content

Commit

Permalink
Merge pull request #203 from ironstar-io/feature/pinned-image-versions
Browse files Browse the repository at this point in the history
set Tokaido to use pinned image tags, rather than 'edge' or 'stable'
  • Loading branch information
ironmike-au committed Oct 13, 2019
2 parents 28cdea8 + 35d4ad4 commit 999a0b3
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/rebuild.go
Expand Up @@ -24,7 +24,7 @@ var RebuildCmd = &cobra.Command{
docker.Stop()
unison.UnloadSyncService(conf.GetConfig().Tokaido.Project.Name)

tok.Init(true, false, false)
tok.Init(true, false)

tok.InitMessage()

Expand Down
1 change: 0 additions & 1 deletion cmd/root.go
Expand Up @@ -70,7 +70,6 @@ func RootCmd() *cobra.Command {
rootCmd.PersistentFlags().BoolP("debug", "d", false, "Enable debug mode, command output is printed to the console")

OpenCmd.PersistentFlags().BoolVarP(&adminFlag, "admin", "", false, "Create a one-time admin login URL and open")
UpCmd.PersistentFlags().BoolVarP(&noPullImagesFlag, "no-pull-images", "", false, "Stop Tokaido from downloaded the latest Docker images")
TestCmd.PersistentFlags().BoolVarP(&useExistingDBFlag, "use-existing-db", "", false, "Run the test suite without recreating the database or temporary users. Note: this may cause test flakiness due to database having prior state.")
SnapshotNewCmd.PersistentFlags().StringVarP(&nameFlag, "name", "n", "", "Specify a name to be added to the snapshot name. If not specified, Tokaido will only use the current UTC date and time")

Expand Down
2 changes: 1 addition & 1 deletion cmd/up.go
Expand Up @@ -21,7 +21,7 @@ var UpCmd = &cobra.Command{
telemetry.SendCommand("up")
utils.CheckCmdHard("docker-compose")

tok.Init(conf.GetConfig().Tokaido.Yes, true, noPullImagesFlag)
tok.Init(conf.GetConfig().Tokaido.Yes, true)
tok.InitMessage()
},
}
7 changes: 5 additions & 2 deletions constants/images.go
@@ -1,6 +1,9 @@
package constants

const (
// ProxyStableVersion ...
ProxyStableVersion string = "1.11.0"
// StableVersion is the tag for all Tokaido images that are running in Ironstar Production environments at the time of this Tokaido release
StableVersion string = "stable"

// EdgeVersion is the tag for all Tokaido images that are running in Ironstar Non-Production environments at the time of this Tokaido release
EdgeVersion string = "1.11.0"
)
2 changes: 1 addition & 1 deletion initialize/main.go
Expand Up @@ -72,7 +72,7 @@ func readProjectConfig(command string) {
viper.SetDefault("Tokaido.Debug", viper.GetBool("debug"))
viper.SetDefault("Tokaido.Force", viper.GetBool("force"))
viper.SetDefault("Tokaido.Yes", viper.GetBool("yes"))
viper.SetDefault("Tokaido.Stability", "edge")
viper.SetDefault("Tokaido.Stability", constants.EdgeVersion)
viper.SetDefault("Tokaido.Dependencychecks", true)
viper.SetDefault("Tokaido.Enableemoji", emojiDefaults())
viper.SetDefault("Tokaido.Phpversion", "7.2")
Expand Down
2 changes: 1 addition & 1 deletion services/docker/generate.go
Expand Up @@ -260,7 +260,7 @@ func UnmarshalledDefaults() conf.ComposeDotTok {
}

// Set our stability version
err = yaml.Unmarshal(dockertmpl.StabilityLevel(phpVersion, conf.GetConfig().Tokaido.Stability), &tokStruct)
err = yaml.Unmarshal(dockertmpl.ImageVersion(phpVersion, conf.GetConfig().Tokaido.Stability), &tokStruct)
if err != nil {
log.Fatalf("Error updating stability version for containers in Compose file: %v", err)
}
Expand Down
36 changes: 21 additions & 15 deletions services/docker/templates/compose.go
Expand Up @@ -4,6 +4,7 @@ import (
"log"

"github.com/ironstar-io/tokaido/conf"
"github.com/ironstar-io/tokaido/constants"
"github.com/ironstar-io/tokaido/system/fs"
homedir "github.com/mitchellh/go-homedir"
)
Expand Down Expand Up @@ -56,41 +57,46 @@ func DrupalSettings(drupalRoot string, projectName string) []byte {
PROJECT_NAME: ` + projectName)
}

// StabilityLevel ...
func StabilityLevel(phpVersion, stability string) []byte {
// ImageVersion ...
func ImageVersion(phpVersion, stability string) []byte {
v := calcPhpVersionString(phpVersion)

imageVersion := constants.EdgeVersion
if stability == "stable" {
imageVersion = constants.StableVersion
}

if conf.GetConfig().Global.Syncservice == "fusion" {
return []byte(`services:
sync:
image: tokaido/sync:` + stability + `
image: tokaido/sync:` + imageVersion + `
syslog:
image: tokaido/syslog:` + stability + `
image: tokaido/syslog:` + imageVersion + `
haproxy:
image: tokaido/haproxy:` + stability + `
image: tokaido/haproxy:` + imageVersion + `
varnish:
image: tokaido/varnish:` + stability + `
image: tokaido/varnish:` + imageVersion + `
nginx:
image: tokaido/nginx:` + stability + `
image: tokaido/nginx:` + imageVersion + `
fpm:
image: tokaido/php` + v + `-fpm:` + stability + `
image: tokaido/php` + v + `-fpm:` + imageVersion + `
drush:
image: tokaido/admin` + v + `-heavy:` + stability + ``)
image: tokaido/admin` + v + `-heavy:` + imageVersion + ``)
}

return []byte(`services:
syslog:
image: tokaido/syslog:` + stability + `
image: tokaido/syslog:` + imageVersion + `
haproxy:
image: tokaido/haproxy:` + stability + `
image: tokaido/haproxy:` + imageVersion + `
varnish:
image: tokaido/varnish:` + stability + `
image: tokaido/varnish:` + imageVersion + `
nginx:
image: tokaido/nginx:` + stability + `
image: tokaido/nginx:` + imageVersion + `
fpm:
image: tokaido/php` + v + `-fpm:` + stability + `
image: tokaido/php` + v + `-fpm:` + imageVersion + `
drush:
image: tokaido/admin` + v + `-heavy:` + stability + ``)
image: tokaido/admin` + v + `-heavy:` + imageVersion + ``)
}

// EnableSolr ...
Expand Down
5 changes: 3 additions & 2 deletions services/proxy/struct.go
@@ -1,6 +1,7 @@
package proxy

import (
"github.com/ironstar-io/tokaido/conf"
"github.com/ironstar-io/tokaido/constants"
)

Expand Down Expand Up @@ -42,7 +43,7 @@ func ComposeDefaults() []byte {
return []byte(`version: "2"
services:
proxy:
image: tokaido/proxy:` + constants.ProxyStableVersion + `
image: tokaido/proxy:` + conf.GetConfig().Tokaido.Stability + `
ports:
- "` + constants.ProxyPort + `:` + constants.ProxyPort + `"
volumes:
Expand Down Expand Up @@ -72,7 +73,7 @@ services:
- default
- tokaido_proxy
proxy:
image: tokaido/proxy:` + constants.ProxyStableVersion + `
image: tokaido/proxy:` + conf.GetConfig().Tokaido.Stability + `
ports:
- "` + constants.ProxyPort + `:` + constants.ProxyPort + `"
volumes_from:
Expand Down
9 changes: 1 addition & 8 deletions services/tok/init.go
Expand Up @@ -30,7 +30,7 @@ import (
)

// Init - The core run sheet of `tok up`
func Init(yes, statuscheck, noPullImagesFlag bool) {
func Init(yes, statuscheck bool) {
c := conf.GetConfig()
cs := "ASK"
if yes {
Expand Down Expand Up @@ -97,13 +97,6 @@ func Init(yes, statuscheck, noPullImagesFlag bool) {
console.SpinPersist(wo, "🚛", "Initial sync completed")
}

if noPullImagesFlag {
fmt.Println(" Not downloading the latest Docker images")
} else {
fmt.Println("🤖 Downloading the latest Docker images")
docker.PullImages()
}

// Configure TLS
fmt.Println("🔐 Configuring TLS Certificates")
tls.ConfigureTLS()
Expand Down
2 changes: 1 addition & 1 deletion services/tok/new.go
Expand Up @@ -208,7 +208,7 @@ func New(args []string, requestTemplate string) {

// Start the environment
initialize.TokConfig("up")
Init(true, false, false)
Init(true, false)

// Run the post-up custom installation commands
l := len(template.PostUpCommands)
Expand Down

0 comments on commit 999a0b3

Please sign in to comment.