Skip to content

Commit

Permalink
fix(run): update aws-cdk
Browse files Browse the repository at this point in the history
This updates the base image and the python lib versions.

I needed to do this because I encountered this bug in aws-cdk:

aws/aws-cdk#14738

Just doing the workaround inside a Dockerfile based on
`contino/aws-cdk` did not work for me.  But rebuilding the image
itself did.

Related PR: contino/docker-aws-cdk#6

**Don't merge before the above PR is merged and the new image released**
  • Loading branch information
thalesmg committed Dec 14, 2021
1 parent 35d2f2e commit e93b79b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 23 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# 63f74cd56d17
FROM contino/aws-cdk:latest
FROM contino/aws-cdk:1.134.0

RUN npm install -g aws-cdk
RUN python3 -m venv /venv
COPY requirements.txt /setup/requirements.txt
COPY setup.py /setup/setup.py
COPY README.md /setup/
COPY cdk_emqx_cluster /setup/cdk_emqx_cluster
RUN cd /setup/ && source /venv/bin/activate && pip install --upgrade pip && pip3 install -r requirements.txt
RUN cd /setup/ \
&& source /venv/bin/activate \
&& pip3 install --upgrade pip \
&& pip3 install -r requirements.txt
COPY bin/container-entrypoint.sh /container-entrypoint.sh
ENTRYPOINT ["/container-entrypoint.sh"]
16 changes: 14 additions & 2 deletions HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,23 @@ docker run --rm -it -v ~/.aws:/root/.aws -v $(pwd):/opt/app contino/aws-cdk bash

## Run cdk in docker

execute `./run` with all the cdk args passed to it.
execute `./run` to run cdk inside the container with args passed to it.
e.g.

```bash
./run synth CdkEmqxClusterStack
env CDK_EMQX_CLUSTERNAME=william ./run cdk synth CdkEmqxClusterStack
```

To have Docker debug output, use `DEBUG=1`:

```bash
env DEBUG=1 ./run cdk synth CdkEmqxClusterStack
```

If you want to enter bash inside the container for debugging purposes, just use:

```bash
./run bash
```

# Deploy
Expand Down
12 changes: 9 additions & 3 deletions bin/container-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

set -euo pipefail

if [ "$1" = 'cdk' ]; then
source /venv/bin/activate
fi
source /venv/bin/activate

# If you run into a similar problem to the following:
# This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version.
# (Cloud assembly schema version mismatch: Maximum schema version supported is 11.0.0, but found 15.0.0)
# run this workaround inside the container:
# npm uninstall -g aws-cdk
# npm install -g aws-cdk
# reference: https://github.com/aws/aws-cdk/issues/14738

exec "$@"
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ docker run -e CDK_EMQX_CLUSTERNAME=${CDK_EMQX_CLUSTERNAME} --rm -it \
-v ~/.aws:/root/.aws \
-v $(pwd):/opt/ \
-w /opt \
mycdk cdk "$@"
mycdk "$@"
28 changes: 14 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
packages=setuptools.find_packages(where="cdk_emqx_cluster"),

install_requires=[
"aws-cdk.aws-ec2==1.130.0",
"aws-cdk.core==1.130.0",
"aws-cdk.aws-ecs==1.130.0",
"aws-cdk.aws-ecs-patterns==1.130.0",
"aws-cdk.aws-elasticloadbalancingv2==1.130.0",
"aws-cdk.aws-elasticloadbalancingv2-targets==1.130.0",
"aws-cdk.aws-logs==1.130.0",
"aws-cdk.aws-route53==1.130.0",
"aws-cdk.aws-fis==1.130.0",
"aws-cdk.aws-iam==1.130.0",
"aws-cdk.aws-ssm==1.130.0",
"aws-cdk.aws-s3==1.130.0",
"aws-cdk.aws-efs==1.130.0",
"aws-cdk.aws-msk==1.130.0",
"aws-cdk.aws-ec2==1.134.0",
"aws-cdk.core==1.134.0",
"aws-cdk.aws-ecs==1.134.0",
"aws-cdk.aws-ecs-patterns==1.134.0",
"aws-cdk.aws-elasticloadbalancingv2==1.134.0",
"aws-cdk.aws-elasticloadbalancingv2-targets==1.134.0",
"aws-cdk.aws-logs==1.134.0",
"aws-cdk.aws-route53==1.134.0",
"aws-cdk.aws-fis==1.134.0",
"aws-cdk.aws-iam==1.134.0",
"aws-cdk.aws-ssm==1.134.0",
"aws-cdk.aws-s3==1.134.0",
"aws-cdk.aws-efs==1.134.0",
"aws-cdk.aws-msk==1.134.0",
"pyyaml"
],

Expand Down

0 comments on commit e93b79b

Please sign in to comment.