Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into nicktobey/proximity-map2
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktobey committed Jan 16, 2025
2 parents c237c1c + e37ea46 commit f19df88
Show file tree
Hide file tree
Showing 82 changed files with 2,208 additions and 1,084 deletions.
15 changes: 15 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,27 @@ _main() {
set -- "$@" --config=$CONFIG_PROVIDED
fi

# If DOLT_ROOT_HOST has been specified – create a root user for that host with the specified password
if [ -n "$DOLT_ROOT_HOST" ] && [ "$DOLT_ROOT_HOST" != 'localhost' ]; then
echo "Ensuring root@${DOLT_ROOT_HOST} superuser exists (DOLT_ROOT_HOST was specified)"
dolt sql -q "CREATE USER IF NOT EXISTS 'root'@'${DOLT_ROOT_HOST}' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
ALTER USER 'root'@'${DOLT_ROOT_HOST}' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
GRANT ALL ON *.* TO 'root'@'${DOLT_ROOT_HOST}' WITH GRANT OPTION;"
fi

# Ensure the root@localhost user exists, with the requested password
echo "Ensuring root@localhost user exists"
dolt sql -q "CREATE USER IF NOT EXISTS 'root'@'localhost' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
ALTER USER 'root'@'localhost' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION;"

if [[ ! -f $INIT_COMPLETED ]]; then
# run any file provided in /docker-entrypoint-initdb.d directory before the server starts
docker_process_init_files /docker-entrypoint-initdb.d/*
touch $INIT_COMPLETED
fi

# switch this process over to executing dolt sql-server
exec dolt sql-server --host=0.0.0.0 --port=3306 "$@"
}

Expand Down
37 changes: 18 additions & 19 deletions docker/serverREADME.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,45 +76,44 @@ Learn more about Dolt use cases, configuration and guides to use dolt on our [do

# How to use this image

This image is for Dolt SQL Server, which is similar to MySQL Docker Image. Running this image without any arguments
is equivalent to running `dolt sql-server --host 0.0.0.0 --port 3306` command locally. The reason for persisted host
and port is that it allows user to connect to the server inside the container from the local host system through
port-mapping.
This image is for Dolt SQL Server, which is similar to the MySQL Docker image. Running this image without any arguments
is equivalent to running `dolt sql-server --host 0.0.0.0 --port 3306` command inside a Docker container.

To check out supported options for `dolt sql-server`, you can run the image with `--help` flag.
To see all supported options for `dolt sql-server`, you can run the image with `--help` flag.

```shell
$ docker run dolthub/dolt-sql-server:latest --help
```

### Connect to the server in the container from the host system

To be able to connect to the server running in the container, we need to set up a port to connect to locally that
maps to the port in the container. The host is set to `0.0.0.0` for accepting connections to any available network
interface.
From the host system, to connect to a server running in a container, we need to map a port on the host system to the port our sql-server is running on in the container.

```shell
$ docker run -p 3307:3306 dolthub/dolt-sql-server:latest
We also need a user account that has permission to connect to the server
from the host system's address. By default, as of Dolt version 1.46.0, the `root` superuser is configured to only allow connections from localhost. This is a security feature to prevent unauthorized access to the server. If you don't want to log in to the container and then connect to your sql-server, you can use the `DOLT_ROOT_HOST` and `DOLT_ROOT_PASSWORD` environment variables to control how the `root` superuser is initialized. When the Docker container is started, it will ensure the `root` superuser is configured according to those environment variables.

In our example below, we're using `DOLT_ROOT_HOST` to override the host of the `root` superuser account to `%` in order to allow any host to connect to our server and log in as `root`. We're also using `DOLT_ROOT_PASSWORD` to override the default, empty password and specify a password for the `root` account. Setting a password is strongly advised for security when allowing the `root` account to connect from any host.

```bash
> docker run -e DOLT_ROOT_PASSWORD=secret2 -e DOLT_ROOT_HOST=% -p 3307:3306 dolthub/dolt-sql-server:latest
```

Now, you have a running server in the container, and we can connect to it by specifying our host, 3307 for the port, and root for the user,
since that's the default user and we didn't provide any configuration when running the server.
If we run the command above with -d or switch to a separate window we can connect with MySQL:

For example, you can run mysql client to connect to the server like this:
```shell
$ mysql --host 0.0.0.0 -P 3307 -u root
```bash
> mysql --host 0.0.0.0 -P 3307 -u root -p secret2
```

### Define configuration for the server

You can either define server configuration as commandline arguments, or you can use yaml configuration file.
For the commandline argument definition you can simply define arguments after whole docker command.
You can specify server configuration with commandline arguments, or you can use a YAML configuration file.
For commandline arguments, you can simply add arguments at the end of the docker command, as shown below.

```shell
$ docker run -p 3307:3306 dolthub/dolt-sql-server:latest -l debug --no-auto-commit
```

Or, we can mount a local directory to specific directories in the container.
To use a configuration file, you can map a local directory to location in the container.
The special directory for server configuration is `/etc/dolt/servercfg.d/`. You can only have one `.yaml` configuration
file in this directory. If there are multiple, the default configuration will be used. If the location of
configuration file was `/Users/jennifer/docker/server/config.yaml`, this is how to use `-v` flag which mounts
Expand All @@ -127,7 +126,7 @@ $ docker run -p 3307:3306 -v /Users/jennifer/docker/server/:/etc/dolt/servercfg.
The Dolt configuration and data directories can be configured similarly:

- The dolt configuration directory is `/etc/dolt/doltcfg.d/`
There should be one `.json` dolt configuration file. It will replace the global dolt configuration file in the
There should be one `.json` Dolt configuration file. It will replace the global Dolt configuration file in the
container.

- We set the location of where data to be stored to default location at `/var/lib/dolt/` in the container.
Expand Down
1 change: 1 addition & 0 deletions go/cmd/dolt/cli/arg_parser_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func CreatePullArgParser() *argparser.ArgParser {
ap.SupportsFlag(NoCommitFlag, "", "Perform the merge and stop just before creating a merge commit. Note this will not prevent a fast-forward merge; use the --no-ff arg together with the --no-commit arg to prevent both fast-forwards and merge commits.")
ap.SupportsFlag(NoEditFlag, "", "Use an auto-generated commit message when creating a merge commit. The default for interactive CLI sessions is to open an editor.")
ap.SupportsString(UserFlag, "", "user", "User name to use when authenticating with the remote. Gets password from the environment variable {{.EmphasisLeft}}DOLT_REMOTE_PASSWORD{{.EmphasisRight}}.")
ap.SupportsFlag(PruneFlag, "p", "After fetching, remove any remote-tracking references that don't exist on the remote.")
ap.SupportsFlag(SilentFlag, "", "Suppress progress information.")
return ap
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/ci/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/dolthub/dolt/go/cmd/dolt/cli"
)

var Commands = cli.NewHiddenSubCommandHandler("ci", "Commands for working with Dolt continuous integration configuration.", []cli.Command{
var Commands = cli.NewSubCommandHandler("ci", "Commands for working with Dolt continuous integration configuration.", []cli.Command{
InitCmd{},
DestroyCmd{},
ImportCmd{},
Expand Down
11 changes: 6 additions & 5 deletions go/cmd/dolt/commands/ci/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
)

var destroyDocs = cli.CommandDocumentationContent{
ShortDesc: "Drops database tables used to store continuous integration configuration",
LongDesc: "Drops database tables used to store continuous integration configuration",
ShortDesc: "Drops all database tables used to store continuous integration configuration",
LongDesc: "Drops all database tables used to store continuous integration configuration and creates a Dolt commit",
Synopsis: []string{
"{{.LessThan}}destroy{{.GreaterThan}}",
"",
},
}

Expand Down Expand Up @@ -59,7 +59,7 @@ func (cmd DestroyCmd) Docs() *cli.CommandDocumentation {

// Hidden should return true if this command should be hidden from the help text
func (cmd DestroyCmd) Hidden() bool {
return true
return false
}

// ArgParser implements cli.Command.
Expand All @@ -71,7 +71,8 @@ func (cmd DestroyCmd) ArgParser() *argparser.ArgParser {
// Exec implements cli.Command.
func (cmd DestroyCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
_, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, destroyDocs, ap))
cli.ParseArgsOrDie(ap, args, help)

if !cli.CheckEnvIsValid(dEnv) {
return 1
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/dolt/commands/ci/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
)

var exportDocs = cli.CommandDocumentationContent{
ShortDesc: "Export a Dolt continuous integration workflow file by name",
LongDesc: "Export a Dolt continuous integration workflow file by name",
ShortDesc: "Export a Dolt continuous integration workflow by name",
LongDesc: "Export a Dolt continuous integration workflow by name",
Synopsis: []string{
"{{.LessThan}}workflow name{{.GreaterThan}}",
},
Expand Down Expand Up @@ -65,7 +65,7 @@ func (cmd ExportCmd) Docs() *cli.CommandDocumentation {

// Hidden should return true if this command should be hidden from the help text
func (cmd ExportCmd) Hidden() bool {
return true
return false
}

// ArgParser implements cli.Command.
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/dolt/commands/ci/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

var importDocs = cli.CommandDocumentationContent{
ShortDesc: "Import a Dolt continuous integration workflow file into the database",
LongDesc: "Import a Dolt continuous integration workflow file into the database",
LongDesc: "Import a Dolt continuous integration workflow file into the database and create a Dolt commit",
Synopsis: []string{
"{{.LessThan}}file{{.GreaterThan}}",
},
Expand Down Expand Up @@ -64,7 +64,7 @@ func (cmd ImportCmd) Docs() *cli.CommandDocumentation {

// Hidden should return true if this command should be hidden from the help text
func (cmd ImportCmd) Hidden() bool {
return true
return false
}

// ArgParser implements cli.Command.
Expand Down
11 changes: 5 additions & 6 deletions go/cmd/dolt/commands/ci/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ import (

var initDocs = cli.CommandDocumentationContent{
ShortDesc: "Creates database tables used to store continuous integration configuration",
LongDesc: "Creates database tables used to store continuous integration configuration",
Synopsis: []string{
"{{.LessThan}}init{{.GreaterThan}}",
},
LongDesc: "Creates database tables used to store continuous integration configuration and creates a Dolt commit",
Synopsis: []string{""},
}

type InitCmd struct{}
Expand Down Expand Up @@ -61,7 +59,7 @@ func (cmd InitCmd) Docs() *cli.CommandDocumentation {

// Hidden should return true if this command should be hidden from the help text
func (cmd InitCmd) Hidden() bool {
return true
return false
}

// ArgParser implements cli.Command.
Expand All @@ -73,7 +71,8 @@ func (cmd InitCmd) ArgParser() *argparser.ArgParser {
// Exec implements cli.Command.
func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
_, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
cli.ParseArgsOrDie(ap, args, help)

if !cli.CheckEnvIsValid(dEnv) {
return 1
Expand Down
11 changes: 6 additions & 5 deletions go/cmd/dolt/commands/ci/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
)

var listDocs = cli.CommandDocumentationContent{
ShortDesc: "List Dolt CI workflows",
LongDesc: "List Dolt CI workflows",
ShortDesc: "List Dolt continuous integration workflows",
LongDesc: "List Dolt continuous integration workflows",
Synopsis: []string{
"{{.LessThan}}ls{{.GreaterThan}}",
"",
},
}

Expand Down Expand Up @@ -61,7 +61,7 @@ func (cmd ListCmd) Docs() *cli.CommandDocumentation {

// Hidden should return true if this command should be hidden from the help text
func (cmd ListCmd) Hidden() bool {
return true
return false
}

// ArgParser implements cli.Command.
Expand All @@ -73,7 +73,8 @@ func (cmd ListCmd) ArgParser() *argparser.ArgParser {
// Exec implements cli.Command.
func (cmd ListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
_, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, listDocs, ap))
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, listDocs, ap))
cli.ParseArgsOrDie(ap, args, help)

if !cli.CheckEnvIsValid(dEnv) {
return 1
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/dolt/commands/ci/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
)

var removeDocs = cli.CommandDocumentationContent{
ShortDesc: "Remove a Dolt continuous integration workflow by name",
LongDesc: "Remove a Dolt continuous integration workflow by name",
ShortDesc: "Removes a Dolt continuous integration workflow by name",
LongDesc: "Removes a Dolt continuous integration workflow by name and creates a Dolt commit",
Synopsis: []string{
"{{.LessThan}}workflow name{{.GreaterThan}}",
},
Expand Down Expand Up @@ -59,7 +59,7 @@ func (cmd RemoveCmd) Docs() *cli.CommandDocumentation {

// Hidden should return true if this command should be hidden from the help text
func (cmd RemoveCmd) Hidden() bool {
return true
return false
}

// ArgParser implements cli.Command.
Expand Down
33 changes: 17 additions & 16 deletions go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,23 @@ type contextFactory func(ctx context.Context, session sql.Session) (*sql.Context
type SystemVariables map[string]interface{}

type SqlEngineConfig struct {
IsReadOnly bool
IsServerLocked bool
DoltCfgDirPath string
PrivFilePath string
BranchCtrlFilePath string
ServerUser string
ServerPass string
ServerHost string
Autocommit bool
DoltTransactionCommit bool
Bulk bool
JwksConfig []servercfg.JwksConfig
SystemVariables SystemVariables
ClusterController *cluster.Controller
BinlogReplicaController binlogreplication.BinlogReplicaController
EventSchedulerStatus eventscheduler.SchedulerStatus
IsReadOnly bool
IsServerLocked bool
DoltCfgDirPath string
PrivFilePath string
BranchCtrlFilePath string
ServerUser string
ServerPass string
ServerHost string
SkipRootUserInitialization bool
Autocommit bool
DoltTransactionCommit bool
Bulk bool
JwksConfig []servercfg.JwksConfig
SystemVariables SystemVariables
ClusterController *cluster.Controller
BinlogReplicaController binlogreplication.BinlogReplicaController
EventSchedulerStatus eventscheduler.SchedulerStatus
}

// NewSqlEngine returns a SqlEngine
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/dolt/commands/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ func constructInterpolatedDoltPullQuery(apr *argparser.ArgParseResults) (string,
if apr.Contains(cli.NoEditFlag) {
args = append(args, "'--no-edit'")
}
if apr.Contains(cli.PruneFlag) {
args = append(args, "'--prune'")
}
if user, hasUser := apr.GetValue(cli.UserFlag); hasUser {
args = append(args, "'--user'")
args = append(args, "?")
Expand Down
Loading

0 comments on commit f19df88

Please sign in to comment.