Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MariaDB from 10.11 to 11.4 (LTS) #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions assets/local-beach/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ services:
environment:
- DEFAULT_HOST=hello.localbeach.net
database:
image: mariadb:10.11
image: mariadb:11.4
container_name: local_beach_database
networks:
- local_beach
volumes:
- {{databasePath}}:/var/lib/mysql
healthcheck:
test: "/usr/bin/mysql --user=root --password=password --execute \"SHOW DATABASES;\""
test: "/usr/bin/mariadb --user=root --password=password --execute \"SHOW DATABASES;\""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of MariaDB 11.0 the image no longer contains mysql-named binaries.

interval: 3s
timeout: 1s
retries: 10
environment:
- MYSQL_ROOT_PASSWORD=password
ports:
- 3307:3306
command: 'mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci'
- "3307:3306"
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
8 changes: 7 additions & 1 deletion cmd/beach/cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func startLocalBeach() error {

databaseStatusOutput, err := exec.RunCommand("docker", []string{"ps", "--filter", "name=local_beach_database", "--filter", "status=running", "-q"})
if err != nil {
return errors.New("failed checking status of container local_beach_database container")
return errors.New("failed checking status of container local_beach_database container, maybe the Docker daemon is not running")
}

if len(nginxStatusOutput) == 0 || len(databaseStatusOutput) == 0 {
Expand Down Expand Up @@ -187,6 +187,12 @@ func startLocalBeach() error {
return errors.New("failed to check for database server container health")
}
if strings.TrimSpace(output) == "healthy" {
commandArgs := []string{"exec", "local_beach_database", "mariadb-upgrade", "-u", "root", "--password=password"}
Copy link
Member Author

@kdambekalns kdambekalns Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs the upgrade – on every start. But since it does no harm to run it when not needed, I chose this way.

An alternative would be to check if the upgrade is needed (using mariadb-upgrade --check-if-upgrade-is-needed), but that seemed superfluous.

output, err = exec.RunCommand("docker", commandArgs)
if err != nil {
log.Error(output)
return errors.New("mariadb-upgrade failed")
}
break
}
if tries == 10 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/beach/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func handleStartRun(cmd *cobra.Command, args []string) {
}

log.Debug("Creating project database (if needed) ...")
commandArgs = []string{"exec", "local_beach_database", "/bin/bash", "-c", "echo 'CREATE DATABASE IF NOT EXISTS `" + sandbox.ProjectName + "`' | mysql -u root --password=password"}
commandArgs = []string{"exec", "local_beach_database", "/bin/bash", "-c", "echo 'CREATE DATABASE IF NOT EXISTS `" + sandbox.ProjectName + "`' | mariadb -u root --password=password"}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of MariaDB 11.0 the image no longer contains mysql-named binaries.

output, err = exec.RunCommand("docker", commandArgs)
if err != nil {
log.Fatal(output)
Expand Down