Skip to content

Commit

Permalink
[BE] refactor: container port 문자열 출력 에러 해결 (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: EunJiJung <[email protected]>
  • Loading branch information
bianbbc87 committed Feb 9, 2025
1 parent 7cc2212 commit eb86ab4
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions .github/actions/ecr-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ runs:
docker push $FULL_ECR_PATH:$IMAGE_TAG
echo "Build & Push completed!"
- name: Debug AWS Credentials
shell: bash
run: aws sts get-caller-identity

- name: Manually Set AWS Credentials
shell: bash
run: |
export AWS_ACCESS_KEY_ID=${{ inputs.aws_access_key_id }}
export AWS_SECRET_ACCESS_KEY=${{ inputs.aws_secret_access_key }}
export AWS_REGION=${{ inputs.aws_region }}
aws sts get-caller-identity
- name: EC2에서 ECR에 로그인하기
uses: appleboy/ssh-action@master
Expand Down Expand Up @@ -149,6 +137,9 @@ runs:
script: |
sudo docker pull ${{ inputs.ecr_uri }}/${{ inputs.namespace }}/${{ inputs.ecr_repo }}:${{ github.sha }}
- name: Debugging container port
run: echo "Container Port: ${{ secrets.APIGATEWAY_PORT }}"

- name: ECR에서 불러온 이미지를 도커에서 실행
uses: appleboy/ssh-action@master
with:
Expand All @@ -158,9 +149,14 @@ runs:
script: |
sudo docker stop ${{ inputs.container_name }} || true
sudo docker rm ${{ inputs.container_name }} || true
if [ "$((inputs.container_port))" -eq 0 ]; then
sudo docker run -d --name ${{ inputs.container_name }} ${{ inputs.ECR_URI }}:${{ github.sha }}
else
sudo docker run -d --name ${{ inputs.container_name }} -p ${{ inputs.container_port }}:${{ inputs.container_port }} ${{ inputs.ECR_URI }}:${{ github.sha }}
# 컨테이너 포트 기본값 설정 (8080)
CONTAINER_PORT=${{ inputs.container_port }}
if [[ -z "$CONTAINER_PORT" || ! "$CONTAINER_PORT" =~ ^[0-9]+$ ]]; then
CONTAINER_PORT=8080
fi
echo "Using container port: $CONTAINER_PORT"
sudo docker run -d --name ${{ inputs.container_name }} -p $CONTAINER_PORT:$CONTAINER_PORT ${{ inputs.ecr_uri }}/${{ inputs.namespace }}/${{ inputs.ecr_repo }}:${{ github.sha }}

0 comments on commit eb86ab4

Please sign in to comment.