SFDX revolutionizes the development process for Salesforce, but a few steps are necessary if you want to use it with Docker. I keep my dev environment in a Docker container, and I haven’t figured out how to get that container to open URL’s on my machine, so I need to use headless authentication. Fortunately, that’s working pretty well, but the docs aren’t quite fully fleshed out. Here are a few guidelines.
- Follow the instructions on https://developer.salesforce.com/docs/atlas.en-us.210.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_jwt_flow.htm to get authentication working between your docker command line and your dev hub-enabled Salesforce org. At the end of this, you should be able to run the sfdx force:auth:jwt:grant command and get a successful authentication. Here’s an example of one of my auth commands:
sfdx force:auth:jwt:grant -i 3MVG9SemV5D80oBfzS3G0K4.t5Sifyb7VXmlLeO1OmKYa632CSnEvgOwIXpzbIBqCKGMAFKejKqUm1Cq0dUP2 -u email@example.com -f ~/dev/certificates/flowbolt/server.key — setdefaultdevhubusername
Successfully authorized firstname.lastname@example.org with org ID 00DB0000000LRppMAG
2. Next you want to be able to create and open up the scratch org so you can use the results of any source pushes you do, and also make changes using Salesforce UI that you can then source pull down into your local project. This is a little opaque currently. Creation is straightforward, now that you’re authenticated. But when you try to open, following the instructions at the bottom of https://developer.salesforce.com/docs/atlas.en-us.210.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_create.htm, you may just get a hang. There is probably a solution for this involving virtual X terminals but I haven’t figured it out yet, and it’s useful in any case to know the workaround, which is to use the “-r” flag to get the URL:
sfdx force:org:open -r
Access org 00D9A000000D1UhUAK as user email@example.com with the following URL: https://saas-computing-55-dev-ed.cs46.my.salesforce.com/secur/frontdoor.jsp?sid=00D9A000000D1Uh!AQ8AQHH98dOHdq2ylIaNFZEh6WSp9ogFKGDxAKwcnwPmAGZT8.xoH7qu7DuB1c.hSBNAHnG_nqBqxFWapn8xf7maoQUbx5KI
This returns a link that you can pop into your browser to immediately load up your scratch org. You’ll see any objects that you’ve source pushed.