0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

test docker

Last updated at Posted at 2025-09-10
version: 0.2

env:
  variables:
    AWS_DEFAULT_REGION: ap-northeast-1
    ACCOUNT_ID: "123456789012"            # 改成你的
    REPOSITORY_NAME: "grand-stg-sm-batch" # 改成你的
  exported-variables: [IMAGE_TAG, REPOSITORY_URI]

phases:
  install:
    runtime-versions:
      docker: 20

  pre_build:
    commands:
      - set -euo pipefail
      - REPOSITORY_URI="${ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${REPOSITORY_NAME}"
      - IMAGE_TAG="$(echo ${CODEBUILD_RESOLVED_SOURCE_VERSION:-manual} | cut -c1-7)-${CODEBUILD_BUILD_NUMBER}"
      - echo "Repo: $REPOSITORY_URI"
      - echo "Tag : $IMAGE_TAG"
      - test -n "$REPOSITORY_URI" || (echo "❌ REPOSITORY_URI empty"; exit 2)
      - test -n "$IMAGE_TAG" || (echo "❌ IMAGE_TAG empty"; exit 2)
      - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI
      - cd "$CODEBUILD_SRC_DIR"
      - test -f aws/pipeline/build/Dockerfile || (echo "❌ Dockerfile not found"; ls -R; exit 3)
      - docker version || (echo "❌ Docker daemon not available. Enable Privileged."; exit 4)

  build:
    commands:
      - docker build --progress=plain -f aws/pipeline/build/Dockerfile -t "$REPOSITORY_URI:$IMAGE_TAG" .

  post_build:
    commands:
      - docker push "$REPOSITORY_URI:$IMAGE_TAG"
      - echo "✅ Pushed: $REPOSITORY_URI:$IMAGE_TAG"

artifacts:
  files: []
  discard-paths: yes
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?