Skip to content

Commit

Permalink
Support for docker login when using ACI on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach committed Jul 4, 2024
1 parent 09e7f1f commit 1c3e714
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@ steps:
connection-string-name: <my connection string name>
tag: <my tag>
init-script: /path/to/init-oracle.sql
registry-login-server: index.docker.io
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}}}
```
`connection-string-name` and `tag` are required. `init-script` is optional.

For logging into a container registry when running on Windows:

* `registry-login-server` defaults to `index.docker.io` and is not required if logging into Docker Hub.
* `registry-username` and `registry-password` are optional and will result in pulling the container anonymously if omitted.

## License

The scripts and documentation in this project are released under the [MIT License](LICENSE).
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ inputs:
init-script:
description: The path to a script to execute in SQL Plus when the database is available. The script is executed by system user and may be used to initialize the database with additional users, permissions and more.
required: false
registry-login-server:
description: The container registry to log in to, if required
required: false
default: index.docker.io
registry-username:
description: The username to log in to the container registry. Will not attempt login if not provided.
required: false
registry-password:
description: The password to log in to the container registry. Will not attempt login if not provided.
required: false
runs:
using: node20
main: dist/index.js
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4126,6 +4126,9 @@ core.saveState('IsPost', true);
let connectionStringName = core.getInput('connection-string-name');
let tag = core.getInput('tag');
let initScript = core.getInput('init-script');
let registryLoginServer = core.getInput('registry-login-server');
let registryUser = core.getInput('registry-username');
let registryPass = core.getInput('registry-password');

async function run() {

Expand Down Expand Up @@ -4153,7 +4156,10 @@ async function run() {
'-StorageName', storageName,
'-ConnectionStringName', connectionStringName,
'-InitScript', initScript,
'-Tag', tag
'-Tag', tag,
'-RegistryLoginServer', registryLoginServer,
'-RegistryUser', registryUser,
'-RegistryPass', registryPass
]);

} else { // Cleanup
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ core.saveState('IsPost', true);
let connectionStringName = core.getInput('connection-string-name');
let tag = core.getInput('tag');
let initScript = core.getInput('init-script');
let registryLoginServer = core.getInput('registry-login-server');
let registryUser = core.getInput('registry-username');
let registryPass = core.getInput('registry-password');

async function run() {

Expand Down Expand Up @@ -43,7 +46,10 @@ async function run() {
'-StorageName', storageName,
'-ConnectionStringName', connectionStringName,
'-InitScript', initScript,
'-Tag', tag
'-Tag', tag,
'-RegistryLoginServer', registryLoginServer,
'-RegistryUser', registryUser,
'-RegistryPass', registryPass
]);

} else { // Cleanup
Expand Down
15 changes: 13 additions & 2 deletions setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ param (
[string]$StorageName,
[string]$ConnectionStringName,
[string]$Tag,
[string]$InitScript = ""
[string]$InitScript = "",
[string]$RegistryLoginServer = "index.docker.io",
[string]$RegistryUser,
[string]$RegistryPass
)

$dockerImage = "gvenzl/oracle-xe:21-slim"
Expand Down Expand Up @@ -57,8 +60,16 @@ elseif ($runnerOs -eq "Windows") {
Write-Output "Creating the file share"
az storage share create --account-name $StorageName --name $StorageName --account-key $storageAccountKey | Out-Null

$azureContainerCreate = "az container create --image $dockerImage --name $ContainerName --location $region --resource-group $resourceGroup --cpu 4 --memory 8 --ports $port --ip-address public --environment-variables ORACLE_PASSWORD=$oraclePassword --azure-file-volume-share-name $StorageName --azure-file-volume-account-name $StorageName --azure-file-volume-account-key $storageAccountKey --azure-file-volume-mount-path $mountPath"
if ($registryUser -and $registryPass) {
echo "Creating container with login to $RegistryLoginServer"
$azureContainerCreate = "$azureContainerCreate --registry-login-server $RegistryLoginServer --registry-username $RegistryUser --registry-password $RegistryPass"
} else {
echo "Creating container with anonymous credentials"
}

Write-Output "Creating container $ContainerName in $region (this can take a while)"
$containerJson = az container create --image $dockerImage --name $ContainerName --location $region --resource-group $resourceGroup --cpu 4 --memory 8 --ports $port --ip-address public --environment-variables ORACLE_PASSWORD=$oraclePassword --azure-file-volume-share-name $StorageName --azure-file-volume-account-name $StorageName --azure-file-volume-account-key $storageAccountKey --azure-file-volume-mount-path $mountPath
$containerJson = Invoke-Expression $azureContainerCreate

if (!$containerJson) {
Write-Output "Failed to create container $ContainerName in $region"
Expand Down

0 comments on commit 1c3e714

Please sign in to comment.