File size: 1,426 Bytes
f8bb6ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55a8b5e
 
 
 
 
 
 
f745aee
f8bb6ab
 
 
55a8b5e
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
version: 0.2

phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - docker version
      - echo $AWS_REGION
      - aws configure list
      - aws --debug ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin 825765383758.dkr.ecr.$AWS_REGION.amazonaws.com

  build:
    commands:
      - echo Build started on `date`
      - echo $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $APP_ENV
      - echo Building the Docker image...
      - |
        docker build \
          -t $CONTAINER_NAME:$CODEBUILD_RESOLVED_SOURCE_VERSION \
          . \
          --build-arg AWS_ACCESS_KEY_ID \
          --build-arg AWS_SECRET_ACCESS_KEY \
          --build-arg APP_ENV
      - docker tag $CONTAINER_NAME:$CODEBUILD_RESOLVED_SOURCE_VERSION 825765383758.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:$CODEBUILD_RESOLVED_SOURCE_VERSION

  post_build:
    commands:
      - echo Pushing the Docker image to Amazon ECR...
      - |
        (
          docker push 825765383758.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:$CODEBUILD_RESOLVED_SOURCE_VERSION || true &
          wait
        )
      - echo Writing image tag...
      - echo $CODEBUILD_RESOLVED_SOURCE_VERSION > image-tag.txt
      # - cp appspec.yml appspec.yml

artifacts:
  files:
    - image-tag.txt
    - docker-compose.yaml
    - appspec.yml
    - deploy.sh
  discard-paths: yes