Learn R Programming

smdocker (version 0.1.4)

sm_build: Use AWS CodeBuild to build docker images and push them to Amazon ECR

Description

This function takes a directory containing a dockerfile, and builds it on AWS CodeBuild. The resulting image is then stored in AWS ECR for later use.

Usage

sm_build(
  repository = NULL,
  compute_type = c("BUILD_GENERAL1_SMALL", "BUILD_GENERAL1_MEDIUM",
    "BUILD_GENERAL1_LARGE", "BUILD_GENERAL1_2XLARGE"),
  role = NULL,
  dir = ".",
  bucket = NULL,
  vpc_id = NULL,
  subnet_ids = list(),
  security_group_ids = list(),
  log = TRUE,
  ...
)

Value

invisible character vector of AWS ECR image uri.

Arguments

repository

(character): The ECR repository:tag for the image (default: sagemaker-studio-${domain_id}:latest)

compute_type

(character): The CodeBuild compute type (default: BUILD_GENERAL1_SMALL)

role

(character): The IAM role name for CodeBuild to use (default: the Studio execution role).

dir

(character): Directory to build

bucket

(character): The S3 bucket to use for sending data to CodeBuild (if None, use the SageMaker SDK default bucket).

vpc_id

(character): The Id of the VPC that will host the CodeBuild Project (such as vpc-05c09f91d48831c8c).

subnet_ids

(list): List of subnet ids for the CodeBuild Project (such as subnet-0b31f1863e9d31a67)

security_group_ids

(list): List of security group ids for the CodeBuild Project (such as sg-0ce4ec0d0414d2ddc).

log

(logical): Show the logs of the running CodeBuild build

...

docker build parameters https://docs.docker.com/engine/reference/commandline/build/#options (NOTE: use "_" instead of "-" for example: docker optional parameter build-arg becomes build_arg)

Examples

Run this code
if (FALSE) {
# Execute on current directory.
sm_build()

# Execute on different directory.
sm_build(dir = "my-project")

# Add extra docker arguments
sm_build(
  file = "/path/to/Dockerfile",
  build_arg = "foo=bar"
)
}

Run the code above in your browser using DataLab