I’ve got this most pressing issue where the script below runs on my Octopus cloud instance and deploys my app using an AWS tool called Copilot (it basically builds a docker image and pushes to AWS ECR/ECS). The issue I have is that even though my Dockerfile accepts all ARGs below, for whatever reason it is not able to “see” them. This script runs on a worker with pre-installed software.
What am I doing wrong? Any help is greatly appreciated as this is blocking our deployments at this stage.
export REACT_APP_API_KEY=$(get_octopusvariable "REACT_APP_API_KEY")
export REACT_APP_ENV=$(get_octopusvariable "REACT_APP_ENV")
ENV_NAME=$(get_octopusvariable "Octopus.Environment.Name")
SVC_NAME=app
DOCKER_TAG=$(get_octopusvariable "Octopus.Action.Package[xxx.web].PackageVersion")
INSTALL_DIR=$(get_octopusvariable "Octopus.Action.Package[xxx.web].ExtractedPath")
# make sure env name is lower case
ENV_NAME="$(tr [A-Z] [a-z] <<< "$ENV_NAME")"
pushd ${INSTALL_DIR}
copilot svc deploy -e ${ENV_NAME} -n ${SVC_NAME} --tag ${DOCKER_TAG} 2>&1 > /dev/null
# Check for error
if [[ $? -ne 0 ]]
then
fail_step "AWS Copilot failed"
fi
Hi Andre,
Thanks for contacting the team here at Support.
I think the best place to start is to get a copy of the logs for the deployment. Please send through the Raw Task log for now to see if there is any obvious errors showing.
If you have done some diagnosis already, let us know how far you got and if any error showed in the Docker or CoPilot implementation.
Hey there @paraic.oceallaigh there are no errors actually which is quite weird. The docker image gets built successfully. The build process builds a single page app and uses env variables to access process.env.STUFF. As these are not present, it fails to run the app in our live environments.
Is there a secure way to send you the logs, I think there will be some confidential info in there.
Yes, will test that now. What is even more mind-twisting is the fact that Copilot has a built in protection and it checks whether env variables are present or not. If I run the deploy command on my local env without setting env variables, this is what I get:
interpolate environment variables for app manifest: environment variable “REACT_APP_API_KEY” is not defined
Hi Andre,
I got the logs - thanks.
As you say they don’t show any errors or warnings of any use and to all intents, it was a successful deploy from Octopus’ point of view.
I will wait for your tests and see if anything comes from it. I wonder as well if the REACT API key is being mapped as type sensitive by Octopus and it may be encrypted or unusable. Trying to mark it as an ordinary variable might work better if you can allow that in your script.
This (in theory) tells me the those env variables are available in the shell environment which should be available to copilot which in turns build a docker image that contains my single page app.
Would you be able to confirm the other options to see if copilot is actually getting what it needs. The reason I ask is that the REACT API Key is printing out the masked value in your test. If you can can you test by trying to leave the KEY unmasked with the actual value and see if copilot picks it up?
Also can you confirm you have the latest co-pilot version which has the bug fix mentioned before i.e. > 1.12.0? The GH issue seems to a be close match for the error you are getting with co-pilot. Having said that, that error might be expected if you provide empty variables.
I asked our Solutions team and unfortunately they haven’t had direct experience with copilot or building a one-page npm app.
Let me know how you get on with those items and we can try to move it forward.
Is there a way for you to remove Octopus from the pipeline and run it in docker directly, with setting the vars manually? Trying to narrow down where the process is flaking out.