Aws

Codecommit 에 Dockerfile을 위치하지 않고 Docker 배포하기

wngnl05 2024. 12. 27. 14:57
version: 0.2
phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - <ECR 로그인 명령어>
      - ECR_URL=""
      - COMMIT_ID=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
  build:
    commands:
      - |
        cat <<EOF > Dockerfile
        FROM python:3.12-alpine
        WORKDIR /app
        COPY . .
        RUN pip install -r requirements.txt
        RUN apk update
        RUN apk add curl
        CMD ["python3", "main.py"]
        EOF
      - docker build -t wsi-ecr .
      - docker tag wsi-ecr:latest $ECR_URL:$COMMIT_ID
  post_build:
    commands:
      - docker push $ECR_URL:$COMMIT_ID