Utilizing the Secure File API in Containers Without Bash (Alpine Linux)
GitLab offers Project-level Secure Files through an easily integrated API. By
adding specific configurations to your .gitlab-ci.yml
, you can leverage this feature effectively:
test:
variables:
SECURE_FILES_DOWNLOAD_PATH: './where/files/should/go/'
script:
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
However, using the Terraform image based on Alpine Linux, which
does not include bash
, can present a challenge for this API integration due to its script requirements needing an
interactive shell environment:
Challenge with Alpine’s Docker Image and Secure File Downloading
GitLab | Bash Requirement (Alpine) | Script Needs Bash Interaction |
---|---|---|
Container without bash | Not present in default Alpine image | Necessary for the Secure File downloading script |
Solution: Incorporating bash
into Your CI Configuration (Alpine Docker Image)
To overcome this hurdle, you must introduce a way to install and use bash within your container environment. Here’s how
it can be done via .gitlab-ci.yml
:
test:
variables:
SECURE_FILES_DOWNLOAD_PATH: './where/files/should/go/'
before_script:
- apk add bash
script:
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
This adjusted CI configuration not only ensures that bash
is present in your Alpine container through the use of
package management (apk add
) but also incorporates it into a reliable workflow where Secure File API integration can
proceed seamlessly.