When I build a container on Google Cloud Build, I echo a secret from an environment variable into a cert file. The file is definitely there during the build process. I've echoed it after it was written and have done an ls
on the directory and it's all correct. However, the final container image doesn't have the file. My .dockerignore
ignores /tmp, /log and local dev DB files. Here is the dockerfile:
FROM alpine:3.14
ARG MASTER_KEY
ARG GCS_SECRET
RUN apk update && apk add --no-cache build-base libpq vips-dev postgresql-dev ruby-dev ruby-etc
RUN apk add nodejs
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && \
bundle config set --local deployment 'true' && \
bundle config set --local without 'development test' && \
bundle install
COPY . /app
ENV RAILS_ENV=production \
LANG=C.UTF-8 \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3 \
RAILS_SERVE_STATIC_FILES=true \
RAILS_LOG_TO_STDOUT=true
ENV RAILS_MASTER_KEY=$MASTER_KEY
RUN bundle exec rake assets:precompile
RUN echo "$GCS_SECRET" > config/gcs_secret.json
RUN ls config
EXPOSE 8080
CMD ["bin/rails", "server", "-b", "0.0.0.0", "-p", "8080"]
The file in question is the config/gcs_secret
. I tried copying it to /
and again, it's not there in the image.