Environment files with Laravel and Docker

Options
matthiasnz
matthiasnz
Community Member

Hi there.

I am trying to load secrets in to the environment file with Laravel and Docker but am having some issues.
I don't think I'm quite understanding how it works / how to get it to work.

I have created the stores in 1pass and I can retrieve them successfully with op read
And in the env file I have them setup like so
DB_DATABASE = "op://valut/app/database"
DB_USERNAME = "op://valut/app/username"
DB_PASSWORD = "op://valut/app/password"

but from here I'm a little stuck at to how to actually run the application.
When I run the app it clearly fails as its trying to connect using op://vault/app/username instead of the actual username from the vault.

The docs state to run op run --env-file="./.env" -- aws
but it states
"[ERROR] 2023/05/23 11:45:07 error while starting process: exec: "aws": executable file not found in $PATH"

I have found another piece of code online that uses something in place of aws which I assume is actually meant to be a processor, and aws wasn't installed in order to run that. Its not running with aws anyway, so not sure on that one.

So I'm a little stuck as to how to actually get the Laravel app to inject use the vault variables.
Furthermore to this, I am unsure if it would work out fo the box inside the container, as I don't have the cli installed on the container.

Is this actually possible with this setup?


1Password Version: 8.10.6
Extension Version: 2.10.0
OS Version: macos 13.2.1
Browser:_ Chrome
Referrer: forum-search:environment files with laravel

Comments

  • Hey @matthiasnz , thank you for reaching out to us!

    "[ERROR] 2023/05/23 11:45:07 error while starting process: exec: "aws": executable file not found in $PATH"

    This looks like op cannot find the AWS executable. What is the output of which aws, in your terminal? Can you try running op run --env-file="./.env" -- $(which aws), trying to pass the full path of the executable?

    Is this actually possible with this setup?

    It should be! Instructions here should work well in Dockerfiles as well: https://developer.1password.com/docs/cli/install-server/

    Additionally, 1Password CLI has a Docker image too: https://hub.docker.com/r/1password/op

    Hope this helps. Would love to hear back from you!

    Best,
    Horia

This discussion has been closed.