I'm trying to run my backend app on ec2 instance with ssh-run pipe.
Pipeline is executing successfully but 'run_app.sh' has never been executed.
Here is my yml definition:
image: atlassian/default-image:3
pipelines:
branches:
development:
- step:
name: "Build and push to Development environment"
deployment: Development
script:
- envsubst < run_app.sh > run_app.sh
- pipe: atlassian/ssh-run:0.8.0
variables:
SSH_USER: 'ec2-user'
SERVER: $HOST_SERVER_IP
SSH_KEY: $AWS_EC2_SSH_KEY
MODE: 'script'
COMMAND: 'run_app.sh'
ENV_VARS: >-
AWS_ECR_HOST=${AWS_ECR_HOST}
AWS_ECR_IMAGE_NAME=${AWS_ECR_IMAGE_NAME}
ENVIRONMENT=${ENVIRONMENT};
MONGO_URI=${MONGO_URI};
FRONTEND_CORE_BASE_URL=${FRONTEND_CORE_BASE_URL};
BACKEND_CORE_BASE_URL=${BACKEND_CORE_BASE_URL};
services:
- docker
My run_app.sh looks like this:
#!/bin/bash
echo "Logging to ECR"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ECR_HOST
docker rm -f $(docker ps -a -q)
docker rmi -f $(docker images -aq)
echo "Pulling the latest image"
docker pull $AWS_ECR_HOST/$AWS_ECR_IMAGE_NAME:latest
echo "Running the container"
docker container run -d --publish 80:80 \
--name $AWS_ECR_IMAGE_NAME \n
-e ENVIRONMENT=$ENVIRONMENT \n
-e MONGO_URI=$MONGO_URI \n
-e FRONTEND_CORE_BASE_URL=$FRONTEND_CORE_BASE_URL \n
-e BACKEND_CORE_BASE_URL=$BACKEND_CORE_BASE_URL \n
$AWS_ECR_HOST/architect_core_api_dev
But nothing happens.
In logs I have following logs:
Status: Downloaded newer image for bitbucketpipelines/ssh-run:0.8.0
INFO: Executing the pipe...
INFO: Using passed SSH_KEY