diff --git a/Dockerfile b/Dockerfile index c77e914..8216637 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/HOWTO.md b/HOWTO.md index bf0fc6a..bd5c254 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -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 diff --git a/bin/container-entrypoint.sh b/bin/container-entrypoint.sh index 5954d00..1c6367f 100755 --- a/bin/container-entrypoint.sh +++ b/bin/container-entrypoint.sh @@ -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 "$@" diff --git a/run b/run index 563ea57..27c461e 100755 --- a/run +++ b/run @@ -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 "$@" diff --git a/setup.py b/setup.py index 8ee4a4e..21a3027 100644 --- a/setup.py +++ b/setup.py @@ -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" ],