Last active
April 30, 2020 01:08
-
-
Save dsolovay/314710ae7a947f1f933a23991b85fd78 to your computer and use it in GitHub Desktop.
Add Braintree settings to Commerce Engine image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG BASE_IMAGE | |
FROM $BASE_IMAGE | |
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] | |
ARG BRAINTREE_ENVIRONMENT | |
ARG BRAINTREE_MERCHANT_ID | |
ARG BRAINTREE_PUBLIC_KEY | |
ARG BRAINTREE_PRIVATE_KEY | |
RUN $json = Get-Content "C:\inetpub\wwwroot\wwwroot\data\Environments\PlugIn.Payments.Braintree.PolicySet-1.0.0.json" | ConvertFrom-Json; \ | |
$json.Policies.'$values'[0].Environment = $env:BRAINTREE_ENVIRONMENT; \ | |
$json.Policies.'$values'[0].MerchantId = $env:BRAINTREE_MERCHANT_ID; \ | |
$json.Policies.'$values'[0].PublicKey = $env:BRAINTREE_PUBLIC_KEY; \ | |
$json.Policies.'$values'[0].PrivateKey = $env:BRAINTREE_PRIVATE_KEY; \ | |
$json | ConvertTo-Json -Depth 32 | Set-Content "C:\inetpub\wwwroot\wwwroot\data\Environments\PlugIn.Payments.Braintree.PolicySet-1.0.0.json" |
Not yet working... Still working on proper syntax for the ARG values when referenced in Powershell. 😕
The gist works now. The original issue was the placement of the ARG commands, which go out of scope after the following command, as noted in the Dockerfile documentation:
An ARG instruction goes out of scope at the end of the build stage where it was defined. To use an arg in multiple stages, each stage must include the ARG instruction.
https://docs.docker.com/engine/reference/builder/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create an image with Braintree settings added.