{"id":917,"date":"2020-12-04T23:07:00","date_gmt":"2020-12-04T14:07:00","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/?p=917"},"modified":"2022-10-29T22:16:56","modified_gmt":"2022-10-29T13:16:56","slug":"aws_lambda_container_image_support_cicd_pipeline","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/12\/04\/aws_lambda_container_image_support_cicd_pipeline\/","title":{"rendered":"AWS\u65b0\u6a5f\u80fd\u300cAWS Lambda Container Image Support\u300d\u5229\u7528\u6642\u306eCI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9"},"content":{"rendered":"

\u306f\u3058\u3081\u306b<\/h2>\n

2020\u5e7411\u670830\u65e5\u304b\u3089\u958b\u50ac\u3055\u308c\u3066\u3044\u308bAWS\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u30ab\u30f3\u30d5\u30a1\u30ec\u30f3\u30b9AWS re:Invent 2020<\/a> \u306b\u3066\u3001\u300cAWS Lambda Container Image Support<\/a>\u300d \u3068\u3044\u3046\u65b0\u30b5\u30fc\u30d3\u30b9\u304c\u767a\u8868\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n

AWS Lambda Container Image Support\u306f\u3001AWS\u306e\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u30b3\u30f3\u30d4\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u300cAWS Lambda\u300d\u306b\u3066\u3001\u4eee\u60f3\u30b3\u30f3\u30c6\u30ca\u6280\u8853\u3092\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u753b\u671f\u7684\u306a\u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002<\/p>\n

\u672c\u691c\u8a3c\u3067\u306f\u3001AWS Lambda Container Image Support\u3092\u4f7f\u3044\u3001\u4efb\u610f\u306eDocker\u30a4\u30e1\u30fc\u30b8\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u307e\u3067\u306eContinuous Integration(CI) \/ Continuous Delivery(CD)\u306e\u5b9f\u88c5\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n

\u691c\u8a3c\u306e\u80cc\u666f\u3068\u76ee\u7684<\/h2>\n

MMM\u3067\u306f\u904b\u7528\u3057\u3066\u3044\u308bLambda\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u3067 wget<\/code> \u304a\u3088\u3073 awscli<\/code> \u3092\u5229\u7528\u3057\u3066\u3044\u308b\u30b1\u30fc\u30b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u3057\u304b\u3057\u3001Lambda\u5b9f\u884c\u74b0\u5883\u306b\u306f wget<\/code> \u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u304a\u3089\u3059\u3001\u3053\u308c\u307e\u3067\u306f\u30d3\u30eb\u30c9\u3057\u305f wget<\/code> \u30d0\u30a4\u30ca\u30ea\u3092\u8ffd\u52a0\u3057\u3066\u5229\u7528\u3059\u308b\u3068\u3044\u3046\u624b\u6cd5\u3092\u53d6\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u30d3\u30eb\u30c9\u306e\u5b9f\u884c\u74b0\u5883\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u308b\u30d0\u30a4\u30ca\u30ea\u306f\u7570\u306a\u308b\u305f\u3081\u3001\u4eca\u5f8c\u306eLambda\u74b0\u5883\u306e\u5909\u66f4\u306b\u3088\u308a\u3001\u30d0\u30a4\u30ca\u30ea\u304c\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308b\u3068\u3044\u3046\u30ea\u30b9\u30af\u304c\u5185\u5305\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n

\u307e\u305f\u3001AWS\u30b3\u30de\u30f3\u30c9\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u3066\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001Lambda\u5185\u3067 awscli<\/code> \u3092\u5229\u7528\u3057 aws s3 sync<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306eAWS Lambda Container Image Support\u306e\u6d3b\u7528\u306b\u3088\u308a\u3001wget<\/code> \u305d\u3057\u3066 awscli<\/code> \u3092Docker\u30d3\u30eb\u30c9\u30d7\u30ed\u30bb\u30b9\u306e\u4e2d\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u69cb\u6210\u306e\u7c21\u7565\u5316\u53ca\u3073\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306e\u5b89\u5b9a\u6027\u3092\u9ad8\u3081\u308b\u3053\u3068\u3092\u76ee\u7684\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u691c\u8a3c\u306e\u6d41\u308c<\/h2>\n
    \n
  1. python:3.9-alpine3.12<\/code>\u3092\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u3068\u3057awscli<\/code>\u3092pip<\/code> wget<\/code>\u3092apk add<\/code>\u3067\u305d\u308c\u305e\u308c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n
  2. Amazon ECR\u306b\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210<\/li>\n
  3. \u30d3\u30eb\u30c9\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u3092Amazon ECR\u306b\u30d7\u30c3\u30b7\u30e5<\/li>\n
  4. \u30d7\u30c3\u30b7\u30e5\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u304b\u3089Lambda\u95a2\u6570\u3092\u4f5c\u6210<\/li>\n
  5. \u4e0a\u8a181-4\u3092\u81ea\u52d5\u5316\u3059\u308bCI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u5b9f\u88c5<\/li>\n<\/ol>\n

    \u5bfe\u8c61\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306e\u6982\u5ff5\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n

    \"\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u30a4\u30e1\u30fc\u30b8\u56f3\"<\/p>\n

    1. python:3.9-alpine3.12<\/code>\u30d9\u30fc\u30b9\u306eDocker\u30a4\u30e1\u30fc\u30b8\u30d3\u30eb\u30c9<\/h3>\n

    \u4eca\u56de\u306fpython:3.9-alpine3.12<\/code>\u3092\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u4f7f\u7528\u3057\u3001\u3053\u306e\u30a4\u30e1\u30fc\u30b8\u306b\u5bfe\u3057\u3066 wget<\/code>\u3068awscli<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

    \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306bDocker\u3092\u5229\u7528\u3059\u308b\u524d\u5f8c\u3067\u3001\u4e0b\u8a18\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u306b\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

    Docker\u5229\u7528\u524d<\/strong><\/p>\n

    .\n\u251c\u2500\u2500 aws\n\u251c\u2500\u2500 bin\n\u2502   \u2514\u2500\u2500 wget\n\u251c\u2500\u2500 main.py\n\u2514\u2500\u2500 rename.sh<\/code><\/pre>\n

    Docker\u5229\u7528\u5f8c<\/strong><\/p>\n

    .\n\u251c\u2500\u2500 .circleci\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 config.yml\n\u251c\u2500\u2500 Dockerfile\n\u251c\u2500\u2500 app\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 main.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 rename.sh\n\u2514\u2500\u2500 scripts\n \u00a0\u00a0 \u251c\u2500\u2500 circleci_lambda.sh\n \u00a0\u00a0 \u251c\u2500\u2500 create_envfile.sh\n \u00a0\u00a0 \u2514\u2500\u2500 docker-build.sh<\/code><\/pre>\n

    \u672c\u691c\u8a3c\u3067\u306f\u4e0b\u8a18Dockerfile\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n

    # Define global args\nARG FUNCTION_DIR="\/home\/app\/"\n\n# Stage 1 - bundle base image + runtime\n# Grab a fresh copy of the image and install GCC\nFROM python:3.9-alpine3.12 AS python-alpine\n# Install GCC (Alpine uses musl but we compile and link dependencies with GCC)\nRUN apk add --no-cache \\\n    libstdc++\n\n# Stage 2 - build function and dependencies\n\n# Install aws-lambda-cpp build dependencies\nRUN apk add --no-cache \\\n    build-base \\\n    libtool \\\n    autoconf \\\n    automake \\\n    libexecinfo-dev \\\n    make \\\n    cmake \\\n    libcurl \\\n    wget \\\n    bash \\\n    which \\\n    groff\n\n# Install AWS CLI\nRUN pip install awscli\n\nFROM python-alpine AS build-image\n\n# Authenticating with AWS CLI\nARG AWS_ACCESS_KEY_ID\nARG AWS_SECRET_ACCESS_KEY\nENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}\nENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}\n\n# Include global args in this stage of the build\n# Create function directory\nRUN mkdir -p \/home\/app\/\n# Copy handler function\nCOPY app\/* \/home\/app\/\n\nRUN ls -la \/home\/app\/\n\nRUN chmod 755 \/home\/app\/rename.sh\n\nRUN ls -la \/home\/app\/\n\n# Install the function's dependencies\nRUN aws s3 cp s3:\/\/aws-lambda-runtime-clients\/python\/awslambdaruntimeclient-0.0.1.tar.gz awslambdaruntimeclient.tar.gz && \\\n    python3.9 -m pip install \\\n    awslambdaruntimeclient.tar.gz \\\n    --target \/home\/app\/\n\n# Stage 3 - final runtime image\n# Grab a fresh copy of the Python image\nFROM python-alpine\n\n# Set working directory to function root directory\nWORKDIR \/home\/app\/\n# Copy in the built dependencies\nCOPY --from=build-image \/home\/app\/ \/home\/app\/\n\nRUN ls -la \/home\/app\/\n\nRUN ls -la \/usr\/local\/bin\n\nRUN ls -la \/usr\/bin\n\nENTRYPOINT [ "\/usr\/local\/bin\/python", "-m", "awslambdaruntimeclient" ]\nCMD [ "main.lambda_handler" ]<\/code><\/pre>\n

    Dockerfile\u4f5c\u6210\u5f8c\u3001\u30a4\u30e1\u30fc\u30b8\u30d3\u30eb\u30c9\u3092\u5b9f\u65bd\u3057\u307e\u3059\u3002<\/p>\n

    $ docker build . \\\n-f Dockerfile \\\n-t lambda\/python:3.9-alpine3.12 \\\n--build-arg AWS_ACCESS_KEY_ID="$(aws configure get mmm-test-env.aws_access_key_id)" \\\n--build-arg AWS_SECRET_ACCESS_KEY="$(aws configure get mmm-test-env.aws_secret_access_key)"<\/code><\/pre>\n

    \u30d3\u30eb\u30c9\u304c\u6210\u529f\u3057\u3001wget<\/code>\u3084awscli<\/code>\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n

    2. Amazon ECR\u306b\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210<\/h3>\n

    \u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u304c\u7528\u610f\u3067\u304d\u305f\u3089\u3001\u6b21\u306f\u30a4\u30e1\u30fc\u30b8\u3092\u30d7\u30c3\u30b7\u30e5\u3059\u308bAmazon Elastic Container Registry(ECR)\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n

    \u4eca\u56de\u306fdocker-lambda<\/code>\u3068\u3044\u3046\u540d\u524d\u3067\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n

    \"ECR\"<\/p>\n

    3. \u30d3\u30eb\u30c9\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u3092Amazon ECR\u306b\u30d7\u30c3\u30b7\u30e5\u3059\u308b<\/h3>\n

    \u30d3\u30eb\u30c9\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u306b\u30bf\u30b0\u4ed8\u3051\u3092\u884c\u3044\u3001\u5148\u307b\u3069\u4f5c\u6210\u3057\u305fECR\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30d7\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002<\/p>\n

    $ docker tag lambda\/python:3.9-alpine3.12 000000000000.dkr.ecr.sa-east-1.amazonaws.com\/docker-lambda:v1.0.0\n\n$ export AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID>\n$ export AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY>\n$(aws ecr get-login --region sa-east-1 --no-include-email)\n\n$ docker push 000000000000.dkr.ecr.sa-east-1.amazonaws.com\/docker-lambda:v1.0.0<\/code><\/pre>\n

    AWS\u30b3\u30f3\u30bd\u30fc\u30eb\u3067ECR\u3092\u958b\u304f\u3068\u3001\u5148\u7a0b\u30d7\u30c3\u30b7\u30e5\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u304c\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n

    \"Image\"<\/p>\n

    4. \u30d7\u30c3\u30b7\u30e5\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u304b\u3089Lambda\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n

    \u30a4\u30e1\u30fc\u30b8\u30d7\u30c3\u30b7\u30e5\u304c\u5b8c\u4e86\u3067\u304d\u305f\u3089\u3001\u65e9\u901fLambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n

    \u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u306e\u3088\u3046\u306b--code ImageUri=<YOUR_IMAGE_URI><\/code>\u3067\u5148\u7a0b\u30d7\u30c3\u30b7\u30e5\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u306eURI\u3092\u6307\u5b9a\u3057\u3066\u3042\u3052\u307e\u3059\u3002<\/p>\n

    $ aws lambda --region sa-east-1 create-function \\\n--function-name docker-lambda-function --package-type Image \\\n--code ImageUri=<YOUR_IMAGE_URI> \\\n--role <YOUR_IAM_ROLE_ARN><\/code><\/pre>\n

    AWS\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089Lambda\u95a2\u6570\u304c\u4f5c\u6210\u3067\u304d\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002(\u4f5c\u6210\u5b8c\u4e86\u307e\u3067\u306b\u591a\u5c11\u6642\u9593\u304c\u304b\u304b\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059)<\/p>\n

    \"Lambda\"<\/p>\n

    \u95a2\u6570\u3092\u4f5c\u6210\u3067\u304d\u305f\u3089\u74b0\u5883\u5909\u6570\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\u4eca\u56de\u306fAmazon S3\u306b\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3068\u3044\u3046\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306e\u305f\u3081\u3001S3BUCKET<\/code>\u3068\u3044\u3046\u30ad\u30fc\u306b\u5bfe\u3057\u3066\u4efb\u610f\u306e\u30d0\u30b1\u30c3\u30c8\u540d\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n

    \"Lambda\"<\/p>\n

    \u307e\u305f\u3001Lambda\u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30bf\u30a4\u30e0\u30a2\u30a6\u30c83\u79d2\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u300160\u79d2\u7a0b\u5ea6\u306b\u5ef6\u9577\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n

    \u6b21\u306b\u95a2\u6570\u3092\u30c6\u30b9\u30c8\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

    \u4eca\u56de\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30c6\u30b9\u30c8\u30a4\u30d9\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n

    {\n  "url": "https:\/\/mmmcorp.co.jp\/"\n}<\/code><\/pre>\n

    \"Test\"<\/p>\n

    S3\u30d0\u30b1\u30c3\u30c8\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u304c\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u3066\u304a\u308a\u3001Docker\u30a4\u30e1\u30fc\u30b8\u304cLambda\u4e0a\u3067\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n

    \"S3Bucket\"<\/p>\n

    5. CI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u5b9f\u88c5<\/h3>\n

    \u6b21\u306b\u3001\u30a4\u30e1\u30fc\u30b8\u30d3\u30eb\u30c9\u3001ECR\u3078\u306e\u30a4\u30e1\u30fc\u30b8\u30d7\u30c3\u30b7\u30e5\u3001Lambda\u95a2\u6570\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306e\u4e00\u9023\u306e\u6d41\u308c\u3092\u3001master\u30d6\u30e9\u30f3\u30c1\u3078\u306ePush\u3092\u30c8\u30ea\u30ac\u30fc\u306b\u3001CI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3068\u3057\u3066\u5b9f\u88c5\u3057\u3066\u304d\u307e\u3059\u3002<\/p>\n

    CI\/CD\u306b\u306fCircleCI\u3092\u5229\u7528\u3057\u3001\u5b9f\u88c5\u30a4\u30e1\u30fc\u30b8\u306f\u4e0b\u8a18\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n

    master\u30d6\u30e9\u30f3\u30c1\u3078\u306ePush\u30fb\u30de\u30fc\u30b8\u3092\u8d77\u70b9\u3068\u3057\u3066\u3001Docker\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u30a4\u30e1\u30fc\u30b8\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\u3002\u30d3\u30eb\u30c9\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u3092ECR\u306b\u30d7\u30c3\u30b7\u30e5\u3057\u3001awscli\u3067Lambda\u95a2\u6570\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3059\u308b\u3068\u3044\u3046\u6d41\u308c\u3067\u3059\u3002<\/p>\n

    \"Pipeline\"<\/p>\n

    \u65e9\u901f\u3001.circleci\/config.yml<\/code>\u3068\u3001yml\u30d5\u30a1\u30a4\u30eb\u5185\u3067\u5b9f\u884c\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u6e96\u5099\u3057\u307e\u3059\u3002<\/p>\n

    defaults: &defaults\n    working_directory: ~\/app\n    machine:\n      image: ubuntu-1604:201903-01\n      docker_layer_caching: true\nversion: 2.1\njobs:\n  build:\n    <<: *defaults\n    steps:\n      - checkout\n      - run:\n          name: ls\n          command: ls\n      - run:\n          name: create .env file\n          command: .\/scripts\/create_envfile.sh\n      - persist_to_workspace:\n          root: ~\/app\n          paths:\n              - .\/*\n  deploy:\n    working_directory: ~\/app\n    docker:\n      - image: docker:19-git\n    steps:\n      - attach_workspace:\n          at: ~\/app\n      - setup_remote_docker\n      - run:\n          name: install python, pip, awscli\n          command: |\n            apk add --update python2 \\\n            jq \\\n            python2-dev \\\n            py-pip \\\n            build-base \\\n            gcc \\\n            abuild \\\n            binutils \\\n            binutils-doc \\\n            gcc-doc \\\n            bash \\\n            && pip install --no-cache-dir awscli\n      - run:\n          name: ls\n          command: ls\n      - run:\n          name: docker build\n          command: .\/scripts\/docker-build.sh\n      - run:\n          name: ECR login\n          command: $(aws ecr get-login --region sa-east-1 --no-include-email)\n      - run:\n          name: ECR deploy\n          no_output_timeout: 2400\n          command: .\/scripts\/circleci_lambda.sh\nworkflows:\n  version: 2\n  build_and_deploy:\n    jobs:\n      - build\n      - deploy:\n          requires:\n            - build\n          filters:\n            branches:\n              only:\n                - master<\/code><\/pre>\n

    \u4eca\u56de\u3001CircleCI\u306e\u30b8\u30e7\u30d6\u306e\u4e2d\u30673\u7a2e\u985e\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u547c\u3073\u51fa\u3057\u3066\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

    #!\/bin\/bash\n\nenv | sort | grep AWS_ > .env\ncat .env\n\nexit 0<\/code><\/pre>\n
    #!\/bin\/bash\n\ndocker build . -f Dockerfile --tag <YOUR_ECR_REPOSITORY_NAME>:<YOUR_TAG> --build-arg AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" --build-arg AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"<\/code><\/pre>\n
    #!\/bin\/bash\n\necho "Push Image to ECR..."\ndocker push <YOUR_ECR_REPOSITORY_NAME>:<YOUR_TAG>\n\necho "Download the model update from Amazon S3 to enable the AWS Lambda private beta feature..."\naws s3 cp s3:\/\/aws-lambda-image-beta-tooling\/cli\/lambda-2015-03-31.normal.json .\n\necho "Install the model..."\naws configure add-model --service-model file:\/\/lambda-2015-03-31.normal.json --service-name lambda\n\necho "build done and running lambda update..."\naws lambda update-function-code --region sa-east-1 --function-name <YOUR_LAMBDA_FUNCTION_NAME> --image-uri <YOUR_IMAGE_URI>\n\nRETURNCD=$?\nif [ ${RETURNCD} -ne 0 ]; then\n  echo\n  echo "Lambda Update FAILED"\n  echo\n  exit ${RETURNCD}\nfi\n\nexit 0<\/code><\/pre>\n

    \u691c\u8a3c\u306e\u632f\u308a\u8fd4\u308a<\/h2>\n

    \u4eca\u56de\u306e\u691c\u8a3c\u3067\u306fAWS Lambda Container Image Support\u3092\u6d3b\u7528\u3057\u3066\u3001\u65e2\u5b58\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306e\u6539\u5584\u3092\u56f3\u3063\u3066\u3044\u307e\u3059\u3002\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u30b3\u30f3\u30c6\u30ca\u3067\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3059\u308b\u3053\u3068\u3067\u3001Lambda\u57fa\u76e4\u306b\u4f9d\u5b58\u3057\u306a\u3044\u5f62\u3067\u306e\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u5b9f\u884c\u304c\u53ef\u80fd\u306b\u306a\u308a\u3001\u30ef\u30fc\u30af\u30ed\u30fc\u30c9\u306e\u5b89\u5b9a\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n

    AWS Lambda\u306e\u30d3\u30b8\u30cd\u30b9\u6d3b\u7528\u3092\u30b5\u30dd\u30fc\u30c8<\/h2>\n

    \u682a\u5f0f\u4f1a\u793eMMM\u306f \u3001AWS Lambda\u306e\u30d3\u30b8\u30cd\u30b9\u6d3b\u7528\u306b\u8c4a\u5bcc\u306a\u5b9f\u7e3e\u3092\u6301\u3063\u3066\u304a\u308a\u3001AWS Lambda\u306eAWS\u30b5\u30fc\u30d3\u30b9\u30c7\u30ea\u30d0\u30ea\u30fc\u30d1\u30fc\u30c8\u30ca\u30fc\u306b\u3082\u8a8d\u5b9a<\/a>\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n

    MMM\u306f\u3001\u591a\u7a2e\u591a\u69d8\u306aAWS\u30de\u30cd\u30fc\u30b8\u30c9\u30b5\u30fc\u30d3\u30b9\u3092\u30af\u30e9\u30a6\u30c9\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u6e96\u62e0\u3057\u305f\u5f62\u3067\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30af\u30e9\u30a6\u30c9\u306e\u771f\u306e\u65e8\u5473\u3067\u3042\u308b\u67d4\u8edf\u6027\u3084\u4fca\u654f\u6027\u3092\u304a\u5ba2\u69d8\u306e\u30d3\u30b8\u30cd\u30b9\u306b\u7d44\u307f\u8fbc\u3080\u3053\u3068\u3092\u5f97\u610f\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

    \u4eca\u56de\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305fAWS Lambda Container Image Support\u3082\u542b\u3081\u3001 \u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\uff08AWS Lambda\uff09<\/a> \u306e\u5c0e\u5165\u3084\u7121\u6599\u76f8\u8ac7\u306b\u95a2\u3057\u3066\u306f\u6b21\u306e\u30da\u30fc\u30b8\u3088\u308a\u304a\u6c17\u8efd\u306b\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002<\/p>\n