Docker deployment on Linux tentacle with settings file in tenanted and versioned folder

Hello support team,

we have the following deployment procedure:

  1. step: Store appsettings.json file in the correct folder which is run as a bash script step:
echo PackageFilePath: $(get_octopusvariable "Octopus.Tentacle.CurrentDeployment.PackageFilePath")
unzip $(get_octopusvariable "Octopus.Tentacle.CurrentDeployment.PackageFilePath")
echo Deleting zip file
rm -rf $(get_octopusvariable "Octopus.Tentacle.CurrentDeployment.PackageFilePath")

echo "Copying appsettings file..."
echo "/home/Octopus/Applications/$(get_octopusvariable "Octopus.Deployment.Tenant.Name")/$(get_octopusvariable "Octopus.Environment.Name")/$(get_octopusvariable "Octopus.Project.Name")/$(get_octopusvariable "Octopus.Action.Package[SomeProject].PackageVersion")"
mkdir -p "/home/Octopus/Applications/$(get_octopusvariable "Octopus.Deployment.Tenant.Name")/$(get_octopusvariable "Octopus.Environment.Name")/$(get_octopusvariable "Octopus.Project.Name")/$(get_octopusvariable "Octopus.Action.Package[SomeProject].PackageVersion")"
cp -rf "$(get_octopusvariable "Octopus.Action.Package[SomeProject].ExtractedPath")/appsettings.json" "/home/Octopus/Applications/$(get_octopusvariable "Octopus.Deployment.Tenant.Name")/$(get_octopusvariable "Octopus.Environment.Name")/$(get_octopusvariable "Octopus.Project.Name")/$(get_octopusvariable "Octopus.Action.Package[SomeProject].PackageVersion")"
  1. step: Substitute variables which is run as a bash script step that only echos some text and uses the Substitute Variables in Templates sub-step:

Target files: "/home/Octopus/Applications/#{Octopus.Deployment.Tenant.Name}/#{Octopus.Environment.Name}/#{Octopus.Project.Name}/#{Octopus.Action.Package[SomeProject].PackageVersion}/appsettings.json"
Encoding: utf-8.

  1. step: Run docker container step:

Docker image: someproject from our internal Docker repository.
Port mapping: #{Tenant.LocalApplicationPort}:#{Tenant.LocalApplicationPort} which is defined as variable for each tenant.
Volume mounting: Container: /app/appsettings.json, Host: "/home/Octopus/Applications/#{Octopus.Deployment.Tenant.Name}/#{Octopus.Environment.Name}/#{Octopus.Project.Name}/#{Octopus.Action.Package[SomeProject].PackageVersion}/appsettings.json"

There are now some problems that occur:

  1. Octopus.Action.Package[SomeProject].PackageVersion cannot be used in steps 2 and 3 (I don’t know why)?
  2. If #{Octopus.Action.Package.PackageVersion} is used, it is not filled, e.g. the path looks like /etc/octopus/#{Octopus.Action.Package.PackageVersion}, which is not what is intended, of course.
  3. Problem: The docker run step fails because it has some strange issue:
/etc/octopus/default/Work/20210329105822-386-241/Script.sh: Zeile 7: Dateiende beim Suchen nach `)' erreicht. 
March 29th 2021 12:58:38
Error
/etc/octopus/default/Work/20210329105822-386-241/Script.sh: Zeile 19: Syntax Fehler: Unerwartetes Dateiende. 
March 29th 2021 12:58:38
Fatal
The remote script failed with exit code 1 
March 29th 2021 12:58:38
Fatal
The action Run IVU.Portal as Docker container on lora-web-01 failed 

So, here are my questions:

  1. Is it possible to get the number of the current release in steps 2 and 3 somehow?
  2. What is the issue with the docker container here? If I let it run as bash script task like this docker run -d --name=test -p 5000:5000 -v "/home/Octopus/Applications/Customer1/Production/Some Project/0.20.124/appsettings.json:/app/appsettings.json" 192.168.2.2:8080/someproject:0.20.124, it works properly. (Target machine is a CentOs linux system).

EDIT: The paths I want to use as configuration paths for the docker containers should look like this: /home/Octopus/Applications/Customer1/Production/Some Project/0.20.124/appsettings.json

Best regards,
Tim

Hi Tim,

Thanks for getting in touch!

When using the #{Octopus.Action.Package.PackageVersion} system variable it will attempt to retrieve the version of any package used in the current step. You can modify it slightly to retrieve the version of a package from a different step e.g. write-host "Targeted:" $OctopusParameters["Octopus.Action[Deploy a Package].Package.PackageVersion"]

Using this format should fix the issues you’re seeing in steps 2 and 3.

Regards,
Paul

Hello @paul.calvert,

now I understand the problem. I have added the package to the step 2 now and set The package will not be aquired to true. This helped me already there.

For step 3, your solution works as desired.

Best regards,
Tim

1 Like