Given the following step,
name: Deploy to staging
deployment: test
Where `deployment` is set to `test`, I'd like to have my dockerfile perform different actions that would go further in preparing a testing environment. This would require the `deployment` variable being passed into the docker runner as a run variable.
Is this possible? If not, is there another way to achieve this?
No, but there is a workaround for this - you can set an environment variable as per Deployment variables under https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html and let it have the name of the environment in it -
Great.
My bitbucket-pipelines file looks something like this:
- step:
name: Deploy to production
deployment: production
trigger: manual
script:
- apt-get update && apt-get install -y curl
- curl -O https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
- pip3 install awsebcli --upgrade
- eb init fun-app -r ap-southeast-2 -p docker
- eb deploy fun-app-env
How/where would I be passing in that variable as a Dockerfile argument?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure what you mean by "passing in that variable as a Dockerfile argument" - I'm going to assume you mean how would you be able to use that within your build script:
If you go to your repo->settings->Deployments->click on a environment (test)-> you can then add a variable, called, say "ENVIRONMENT" and set the value to "test" and then do the same for staging and production. Then in your script in the yml you'll be able to do:
- if [ "${ENVIRONMENT}" = "test" ]; then xyz; fi
Note also that we just released a feature called Bitbucket Pipes that has a Pipe for deploying to elastic beanstallk that you might want to use instead of what you're doing in your yml
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As in a docker build ARG that I could read and code against within the Dockerfile.
https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg
The idea here is to be able to pass additional context when building the container so that I can change what is actually being built.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, now I get you - I didn't follow that it was `eb init -p docker` - I don't know if there is a way to do this - you might need to ask in a awsebcli forum. A workaround would be to substitute the variable straight into your Dockerfile inside pipelines before calling `eb init` - e.g. `sed -e 's/<ENV>/${ENVIRONMENT}/' Dockerfile.in > Dockerfile` for example...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.