Description:
Feature request from the Twitter thread. Publishing our own docker image for SAM CLI can help customers use it without installing separately on a CI/CD pipeline or locally. They can do docker run sam-cli-image deploy. Docker-in-Docker will be needed to enable sam local commands. But Docker images will certainly be another good distribution mechanism.
I use something like this:
FROM alpine:3.8
ENV LANG C.UTF-8
ENV HOME /tmp
RUN apk add --no-cache python py-pip && \
apk add --no-cache gcc python-dev musl-dev && \
pip --disable-pip-version-check install \
boto3 botocore awscli aws-sam-cli && \
apk -v --purge --no-cache del gcc python-dev musl-dev
RUN apk add --no-cache docker bash
sam init
docker run --rm -it \
-v $PWD:$PWD:Z \
-w $PWD \
-u=$UID:$(id -g) \
sam-cli-image sam init
sam local
docker run --rm -it \
-e "AWS_DEFAULT_REGION=us-east-1" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD:$PWD:ro,Z \
-w $PWD \
-p 3000:3000 \
sam-cli-image sam local start-api --host 0.0.0.0
P.S. If you use selinux you can add the z or Z options to modify the selinux label of the host file or directory being mounted into the container. This affects the file or directory on the host machine itself and can have consequences outside of the scope of Docker.
Considering that many (most? well, me at least...) folks will be using CodeBuild as their starting point for deploying apps with SAM, I think this would do a lot to smooth out onboarding with SAM.
could you also publish an image per language? most modern CI/CD systems run builds inside of containers so this would prevent the need for docker in docker- you could just get the right sam image for your language
I assume you already have an image per language because of the --use-container switch right? wouldnt you just have to add the sam cli to those images if its not in there already?
Most helpful comment
I use something like this: