Last active
December 5, 2019 17:02
-
-
Save bilardi/2e5a0df1d6bad56dccef02544316b0cd to your computer and use it in GitHub Desktop.
How to develop with serverless and AWS on docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Develop with the Serverless Framework and AWS on a Docker container | |
Don't you want to download all dependencies on your client? Use a docker container! | |
You can develop on your client and a *Dockerfile* with all dependencies that you need for your code. | |
Below you can find the steps for creating your work environment and an example of a *Dockerfile*. | |
## Usage | |
Build the docker image | |
``` | |
cd path/of/the/Dockerfile | |
docker build . -t my-serverless | |
``` | |
For Windows | |
``` | |
cd path\of\your\code | |
docker run -it --rm -v $HOME\.aws\credentials:/root/.aws/credentials:ro -v $PWD\:/code/ -v /var/run/docker.sock:/var/run/docker.sock -e HOST_PWD="$PWD" my-serverless bash | |
``` | |
For *nix | |
``` | |
cd path/of/your/code | |
docker run -it --rm -v $HOME/.aws/credentials:/root/.aws/credentials:ro -v $PWD/:/code/ -v /var/run/docker.sock:/var/run/docker.sock -e HOST_PWD="$PWD" my-serverless bash | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM docker:latest | |
# packages | |
RUN apk add --update --no-cache nodejs npm python3 python3-dev py3-pip less bash build-base g++ zip unzip | |
RUN apk add --no-cache postgresql-libs && apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev libffi libffi-dev | |
RUN pip3 install --upgrade awscli python-magic | |
#RUN apk --purge del .build-deps py3-pip | |
# serverless | |
#RUN npm install -g npm@specific.version | |
RUN npm install -g serverless | |
#RUN npm install -g serverless@specific.version | |
RUN npm install -g --ignore-scripts serverless-step-functions | |
RUN npm install -g serverless-latest-layer-version | |
#RUN npm install -g serverless-plugin-lambda-dead-letter | |
RUN npm install -g serverless-domain-manager | |
#RUN npm install -g serverless-aws-documentation | |
# environment | |
VOLUME /root/.aws | |
VOLUME /root/.config | |
VOLUME /project | |
WORKDIR /project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment