-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
38 lines (34 loc) · 1.13 KB
/
buildspec.yml
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
version: 0.2
phases:
install:
runtime-versions:
nodejs: 16
docker: 20
commands:
- echo "Installing dependencies..."
- npm install
pre_build:
commands:
- echo "Pre-build phase: Starting Docker daemon..."
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock &
- echo "Logging into Amazon ECR..."
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
build:
commands:
- echo "Building Docker image..."
- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
commands:
- echo "Pushing Docker image to Amazon ECR..."
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
artifacts:
files:
- appspec.yml
- scripts/**/*
env:
variables:
IMAGE_REPO_NAME: "your-image-repo-name"
IMAGE_TAG: "latest"
AWS_REGION: "your-region"
AWS_ACCOUNT_ID: "your-account-id"