Closed dluo-sig closed 3 months ago
Might be related to the base image you are using 1password/op:2
: https://explore.ggcr.dev/?blob=1password/op@sha256:df5061b63df9f13ef4e7ec7033d4f3be14236f08790f6d5e60e72bed36359ebc&mt=application%2Fvnd.oci.image.config.v1%2Bjson&size=1577&manifest=1password/op@sha256:c093f74945920677a6e8c2808e6603afe97c5d7844791c08bd3b2b2c7628a93b which sets a specific user USER opuser
As this base image seems to just ship op
binary, can you try with the following dockerfile using another base to see if this is related?:
FROM debian:bookworm-slim
WORKDIR /opt/app
COPY . /opt/app
ARG ENVIRONMENT_NAME
RUN --mount=type=bind,from=1password/op:2,source=/usr/local/bin/op,target=/usr/bin/op \
--mount=type=secret,id=OP_SERVICE_ACCOUNT_TOKEN \
export OP_SERVICE_ACCOUNT_TOKEN=$(cat /run/secrets/OP_SERVICE_ACCOUNT_TOKEN) && \
op inject -i src/elt_projects/dbt/profiles.${ENVIRONMENT_NAME}.yml -o src/elt_projects/dbt/profiles.yml --force
You can also set uid
/ gid
attrs based on what we see in image config: https://explore.ggcr.dev/?blob=1password%2Fop%40sha256%3Adf5061b63df9f13ef4e7ec7033d4f3be14236f08790f6d5e60e72bed36359ebc&jq=.history%5B2%5D.created_by&manifest=1password%2Fop%40sha256%3Ac093f74945920677a6e8c2808e6603afe97c5d7844791c08bd3b2b2c7628a93b&mt=application%2Fvnd.oci.image.config.v1%2Bjson&render=created_by&size=1577
FROM 1password/op:2
WORKDIR /opt/app
COPY . /opt/app
ARG ENVIRONMENT_NAME
RUN --mount=type=secret,id=OP_SERVICE_ACCOUNT_TOKEN,uid=999,gid=999 \
export OP_SERVICE_ACCOUNT_TOKEN=$(cat /run/secrets/OP_SERVICE_ACCOUNT_TOKEN) && \
op inject -i src/elt_projects/dbt/profiles.${ENVIRONMENT_NAME}.yml -o src/elt_projects/dbt/profiles.yml --force
That was it! It works fine with a different image. Appreciate all the detail on this, learned a few new tricks as well.
Contributing guidelines
I've found a bug, and:
Description
I'm trying to pass secrets to use in the Dockerfile, but when setting it up based on some of the other examples that I've seen here, I'm getting a permission error.
Expected behaviour
I would expect that I can read my secret and export it into an env variable to use in the build session.
Actual behaviour
Permission denied error
Repository URL
No response
Workflow run URL
No response
YAML workflow
Dockerfile
Workflow logs