|
| 1 | +<# |
| 2 | + Copyright (c) 2023, Oracle and/or its affiliates. |
| 3 | + Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. |
| 4 | +
|
| 5 | + This script starts up a MySQL database in a container using the |
| 6 | + host's networking (to make it simpler). There is no persistence |
| 7 | + directory so any changes made to the data can be reset by simply |
| 8 | + restarting the container. |
| 9 | +#> |
| 10 | +$BASEDIR = $PSScriptRoot |
| 11 | +if (-not $env:WKTUI_QS_HOME) { |
| 12 | + $env:WKTUI_QS_HOME = (get-item $BASEDIR).parent.parent.FullName |
| 13 | +} |
| 14 | + |
| 15 | +if (-not $env:IMAGE_BUILDER_EXE) { |
| 16 | + Write-Error "IMAGE_BUILDER_EXE environment variable must be set. Please edit and run the ${env:WKTUI_QS_HOME}\setQuickstartEnv.sh file" |
| 17 | + exit 1 |
| 18 | +} |
| 19 | + |
| 20 | +if (-not $env:ORCL_SSO_USER) { |
| 21 | + $env:ORCL_SSO_USER = Read-Host "Please enter your Oracle SSO account username: " |
| 22 | + if (-not $env:ORCL_SSO_USER) { |
| 23 | + Write-Error "No Oracle SSO account username provided...exiting" |
| 24 | + exit 1 |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +if (-not $env:ORCL_SSO_PASS) { |
| 29 | + $ORCL_SSO_PASS = Read-Host "Please enter your Oracle SSO account password: " -AsSecureString |
| 30 | + if (-not $ORCL_SSO_PASS) { |
| 31 | + Write-Error "No Oracle SSO account password provided...exiting" |
| 32 | + exit 1 |
| 33 | + } |
| 34 | + $env:ORCL_SSO_PASS = [Runtime.InteropServices.Marshal]::PtrToStringAuto( |
| 35 | + [Runtime.InteropServices.Marshal]::SecureStringToBSTR($ORCL_SSO_PASS)) |
| 36 | +} |
| 37 | + |
| 38 | +$argList = "login container-registry.oracle.com -u `"$env:ORCL_SSO_USER`" -p `"$env:ORCL_SSO_PASS`"" |
| 39 | + |
| 40 | +$proc = Start-Process -NoNewWindow -FilePath "$env:IMAGE_BUILDER_EXE" -ArgumentList "$argList" -PassThru |
| 41 | +Wait-Process -InputObject $proc |
| 42 | +if ($proc.ExitCode -ne 0) { |
| 43 | + Write-Error "Failed to log in to the image registry container-registry.oracle.com" |
| 44 | + exit 1 |
| 45 | +} |
| 46 | + |
| 47 | +$argList = "run --name=mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=manager1 -e MYSQL_USER=weblogic -e MYSQL_PASSWORD=welcome1 -e MYSQL_DATABASE=tododb --mount type=bind,src=`"${env:WKTUI_QS_HOME}\sql\\`",dst=/docker-entrypoint-initdb.d/ -d container-registry.oracle.com/mysql/community-server:8.0.32" |
| 48 | +Write-Output "argList = $argList" |
| 49 | + |
| 50 | +$proc = Start-Process -NoNewWindow -FilePath "$env:IMAGE_BUILDER_EXE" -ArgumentList "$argList" -PassThru |
| 51 | +Wait-Process -InputObject $proc |
| 52 | +if ($proc.ExitCode -ne 0) { |
| 53 | + Write-Error "Failed to start MySQL database container...exiting" |
| 54 | + exit 1 |
| 55 | +} |
| 56 | + |
0 commit comments