#.dockerbuild() doesn't seem to mount secrets

1 messages · Page 1 of 1 (latest)

tight locust
#

Using the js sdk. building uising my existing dockerfile

I passed secret to dockeBuild's secrets arg but in container /run exists but empty, doesn't include a secrets folder

however jsdoc claims that it should be mounted

    /**
     * Secrets to pass to the build.
     *
     * They will be mounted at /run/secrets/[secret-name].
     */
    secrets?: Secret[];

here's is the part of my build script;

connect(
  async daggerClient => {
    const envFile = await readFile('.env');
    const envFileSecret = daggerClient.setSecret('dotenv', envFile.toString());

    // get reference to the project directory
    const source = daggerClient
      .host()
      .directory('.', {
        exclude: [
          'node_modules/',
          'ci/',
          'npm-debug.log',
          'README.md',
          '.next',
          '.git',
          '.env',
          'gcp-dagger-service-account.json',
        ],
      })
      .dockerBuild({
        dockerfile: './apps/web/Dockerfile',
        secrets: [envFileSecret], // They will be mounted at /run/secrets/[secret-name].
      });

    // publish container to Google Container Registry
    const gcrContainerPublishResponse = await source.publish(
      GCR_PUBLISH_ADDRESS
    );

    // print ref
    console.log(`Published at: ${gcrContainerPublishResponse}`);
south jungle
#

@tight locust could you share log output & relevant contents of your dockerfile?

tight locust
#

Hi! I tried it by adding RUN ls -la /run to dockerfile
didn't log any files/folders under /run

unfortunately mofified my dockerfile quite a bit after that I'm now providing environtment variables with a different way.

austere pelican
#

were you using --mount in your Dockerfile RUN instruction?

tight locust
#

were you using --mount in your Dockerfile RUN instruction?
no :(

my bad didn't know how mount concept worked

thanks! this works as a great example!

austere pelican
south jungle
#

that jsdoc seems misleading

austere pelican
tight locust
#

thanks so much!

austere pelican