Skip to content

Commit 53d91c5

Browse files
committed
first commit
0 parents  commit 53d91c5

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Original source from https://hub.docker.com/_/node/
2+
FROM node:lts-alpine
3+
LABEL maintainer="Xavier Portilla Edo <xavierportillaedo@gmail.com>"
4+
ARG ASK_CLI_VERSION=2.1.1
5+
6+
ENV CLI_VERSION @${ASK_CLI_VERSION}
7+
8+
# NPM_CONFIG_PREFIX: See below
9+
# PATH: Required for ask cli location
10+
ENV TZ="GMT" \
11+
NPM_CONFIG_PREFIX=/home/node/.npm-global \
12+
PATH="${PATH}:/home/node/.npm-global/bin/:/home/node/.local/bin/"
13+
14+
# Required pre-reqs for ask cli
15+
RUN apk add --update \
16+
python \
17+
make \
18+
bash \
19+
zip \
20+
git \
21+
py-pip
22+
23+
# See https://github.com/nodejs/docker-node/issues/603
24+
# ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
25+
WORKDIR /app
26+
USER node
27+
28+
# /home/node/.ask: For ask CLI configuration file
29+
# /home/node/.ask: Folder to map to for app development
30+
RUN npm install -g ask-cli${CLI_VERSION} bespoken-tools && \
31+
mkdir /home/node/.ask && \
32+
mkdir /home/node/.aws && \
33+
mkdir /home/node/app && \
34+
mkdir /home/node/.bst && \
35+
pip install awscli --upgrade --user
36+
37+
# Patch for https://github.com/martindsouza/docker-amazon-ask-cli/issues/1
38+
WORKDIR /$NPM_CONFIG_PREFIX/lib/node_modules/ask-cli
39+
RUN npm install simple-oauth2@1.5.0 --save-exact
40+
41+
# Default folder for developers to work in
42+
WORKDIR /home/node/app

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Martin Giffy D'Souza
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Docker image for ASK and AWS CLI
2+
3+
The purpose of this container is to be able to use the [Amazon ASK CLI (Alexa Skills Kit)](https://developer.amazon.com/docs/smapi/ask-cli-intro.html#alexa-skills-kit-command-line-interface-ask-cli) in a Docker container in Devops pipelines.
4+
5+
**NOTE:** This is a fork from [martindsouza](https://github.com/martindsouza/docker-amazon-ask-cli) image with these changes:
6+
1. Image base is the latest LTS version instead of the current version of Node.js.
7+
2. Added ASK_CLI_VERSION build argument in order to be able to work with different ASK CLI versions.
8+
3. Added git and zip packages that ASK CLI will use in its commands.
9+
4. Added Bespoken.
10+
5. Remove volumes. I think it is not necessary in a simple docker image that I will use in my devops pipelines. In addition, you can use '-v' argument in `docker run` command whenever you want.
11+
12+
## ASK Config
13+
14+
Before running this example ensure that you've registered for an [Alexa Developer](https://developer.amazon.com/alexa) account.
15+
16+
### ask configure
17+
18+
Running `ask configure` in v2 and `ask init` in v1 in the container will ask you a set of questions to create the Alexa credentials. Follow all the steps explained in the official documentation[https://developer.amazon.com/en-US/docs/alexa/smapi/manage-credentials-with-ask-cli.html].
19+
20+
In either case ensure that you pass in `-v $(pwd)/ask-config:/home/node/.ask \` (where `$(pwd)/ask-config` is a location on your host machine) as an option when running the container to preserve the ASK configuration.
21+
22+
### Setting credentials using environment variables
23+
24+
You can store Alexa credentials in environment variables instead of the Alexa credentials file. If the Alexa environment variables exist, ASK CLI uses them instead of the values in the Alexa credentials file. ASK CLI searches for the following Alexa environment variables:
25+
26+
You can use the ASK CLI environment variables in conjunction with or in addition to the ASK CLI configuration file. The following list describes the ASK CLI environment variables.
27+
28+
* `ASK_DEFAULT_PROFILE`: Use this environment variable in conjunction with the ASK CLI configuration file. When you set the value of this environment variable to one of the profiles in the configuration file, ASK CLI uses the credentials in that profile.
29+
* `ASK_ACCESS_TOKEN`: Use this environment variable to store an Amazon developer access token. When this environment variable exists, ASK CLI uses it instead of the credentials in the configuration file.
30+
* `ASK_REFRESH_TOKEN`: Use this environment variable to store an Amazon developer refresh token. When this environment variable exists, ASK CLI uses it instead of the credentials in the configuration file. When this environment variable and ASK_ACCESS_TOKEN both exist, ASK CLI uses this one.
31+
* `ASK_VENDOR_ID`: Use this environment variable to store an Amazon developer vendor ID. When this environment variable exists, ASK CLI uses it instead of the one it the configuration file.
32+
* `ASK_CLI_PROXY`: Use this environment variable to specify an HTTP proxy for requests made with the ASK CLI.
33+
34+
If you want to know how to get the `ASK_REFRESH_TOKEN` and `ASK_ACCESS_TOKEN`, see [this page](https://developer.amazon.com/en-US/docs/alexa/smapi/get-access-token-smapi.html) in the Alexa documentation.
35+
36+
If you want to know how to get the `ASK_VENDOR_ID`, you only have to enter to [this page](https://developer.amazon.com/settings/console/mycid).
37+
38+
If you are using Alexa environment variable you have to add a new profile called `__ENVIRONMENT_ASK_PROFILE__` in your `.ask/config` file
39+
40+
## AWS Config
41+
42+
If you plan to use [Lambda](https://aws.amazon.com/lambda/) you'll need to configure the AWS CLI. To simplify. You can configure it multiple ways.
43+
44+
In either case ensure that you pass in `-v $(pwd)/aws-config:/home/node/.aws \` (where `$(pwd)/aws-config` is a location on your host machine) as an option when running the container to preserve the AWS configuration.
45+
46+
### aws configure
47+
48+
Running `aws configure` in the container will ask you a set of questions to create the AWS credentials
49+
50+
### Setting credentials using environment variables
51+
52+
You can store AWS credentials in environment variables instead of the AWS credentials file. If the AWS environment variables exist, ASK CLI uses them instead of the values in the AWS credentials file. ASK CLI searches for the following AWS environment variables:
53+
54+
* `AWS_ACCESS_KEY_ID`
55+
* `AWS_SECRET_ACCESS_KEY`
56+
57+
For more information about the [AWS environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html), see Environment Variables in the AWS documentation.
58+
59+
60+
## Usage
61+
62+
Get the latest version of the container: `docker pull xavidop/alexa-ask-aws-cli`
63+
64+
```bash
65+
# Get image
66+
docker pull xavidop/alexa-ask-aws-cli
67+
```
68+
69+
They're two ways to use the `ask` cli for this container which are covered below.
70+
71+
### Run One Command
72+
73+
In this mode the container will start, you run your `ask` command, then the container is stopped and deleted. _Don't worry your Docker image is still kept._
74+
75+
```bash
76+
docker run -it --rm \
77+
-v $(pwd)/ask-config:/home/node/.ask \
78+
-v $(pwd)/hello-world:/home/node/app \
79+
xavidop/alexa-ask-aws-cli:latest \
80+
ask init -l
81+
```
82+
83+
### Run `bash`, then run `ask`
84+
85+
In this mode, the container will start, you can then run the container's bash, and the container will stop and delete only once you `exit`.
86+
87+
```bash
88+
docker run -it --rm \
89+
-v $(pwd)/ask-config:/home/node/.ask \
90+
-v $(pwd)/app/HelloWorld:/home/node/app \
91+
xavidop/alexa-ask-aws-cli:latest \
92+
bash
93+
94+
# You'll be prompted with:
95+
# bash-4.3$
96+
#
97+
# Type: exit to end and terminate the container
98+
```
99+
100+
## Developers
101+
102+
For ASK CLI v1:
103+
```bash
104+
docker build --build-arg ASK_CLI_VERSION=1.7.23 -t xavidop/alexa-ask-aws-cli:1.0 .
105+
106+
# Pushing to Docker Hub
107+
# Note: not required since I have a build hook linked to the repo
108+
docker login
109+
docker push xavidop/alexa-ask-aws-cli
110+
```
111+
112+
For ASK CLI v2:
113+
```bash
114+
docker build --build-arg ASK_CLI_VERSION=2.1.1 -t xavidop/alexa-ask-aws-cli:2.0 .
115+
116+
# Pushing to Docker Hub
117+
# Note: not required since I have a build hook linked to the repo
118+
docker login
119+
docker push xavidop/alexa-ask-aws-cli
120+
```
121+
122+
## Versions
123+
124+
Currently there are two versions available:
125+
* 1.0: this image is running the latest version of ASK CLI v1 (1.7.23)
126+
* 2.0: this image is running the latest version of ASK CLI v2 (2.1.1)
127+
128+
These versions are available in my [DockerHub profile](https://hub.docker.com/r/xavidop/alexa-ask-aws-cli/tags)
129+
130+
## Links:
131+
132+
- [ASK CLI Quickstart](https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html)
133+
- [ASK CLI Full Doc](https://developer.amazon.com/docs/smapi/ask-cli-intro.html#alexa-skills-kit-command-line-interface-ask-cli)
134+

0 commit comments

Comments
 (0)