https://github.com/aligent/serverless-docker
Dockerised environment for serverless (https://www.serverless.com/framework/docs/getting-started/)
https://github.com/aligent/serverless-docker
serverless
Last synced: 9 months ago
JSON representation
Dockerised environment for serverless (https://www.serverless.com/framework/docs/getting-started/)
- Host: GitHub
- URL: https://github.com/aligent/serverless-docker
- Owner: aligent
- License: gpl-3.0
- Created: 2020-08-03T00:36:16.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T02:41:41.000Z (about 1 year ago)
- Last Synced: 2025-04-02T23:46:10.220Z (about 1 year ago)
- Topics: serverless
- Language: Shell
- Size: 1.12 MB
- Stars: 2
- Watchers: 9
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README


# Introduction
Docker image for running the serverless command without requiring it to be installed. It is available on docker
hub as [aligent/serverless](https://hub.docker.com/r/aligent/serverless).
## Installation
Add the following lines to your `~/.bashrc` or `~./.zshrc` file to be able to run it easily...
```
alias node-run='docker run --rm -it --volume ~/.aws:/home/node/.aws --volume ~/.azure:/home/node/.azure --volume ~/.npm:/home/node/.npm --volume "$PWD:/app" aligent/serverless'
alias serverless='node-run serverless'
```
You will then need to reload your bashrc/zshrc file, either by running `. ~/.bashrc` or starting a new terminal session.
## Usage
You can now run serverless normally.
To create a new project for example:
```
serverless create --template aws-nodejs --path test-service
```
## Automatic image switching
To automatically switch between different node versions based on your current directories `.nvmrc` file you can add the following function to your `~/.bashrc` or `~/.zshrc` and update the `node-run` alias as below.
```
determine_serverless_image() {
if [ -n "$ZSH_VERSION" ]; then
setopt local_options BASH_REMATCH # for ZSH compatiblity
setopt local_options KSH_ARRAYS # for ZSH compatiblity
fi
DEFAULT_IMAGE='aligent/serverless:latest'
NVM_RC=$(realpath .nvmrc)
if [ -s "$NVM_RC" ]; then
NODE_VERSION=$(<"$NVM_RC")
if [[ $NODE_VERSION =~ ^v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?$ ]]; then
echo "aligent/serverless:latest-node${BASH_REMATCH[1]}"
return 0
fi
fi
echo $DEFAULT_IMAGE
return 0
}
alias node-run='docker run --rm -it --volume ~/.aws:/home/node/.aws --volume ~/.azure:/home/node/.azure --volume ~/.npm:/home/node/.npm --volume $PWD:/app $(determine_serverless_image)'
```