An example of how to a build C++ application that uses AWS's SDK.
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-alpine"
$ git clone https://github.com/unfor19/aws-sdk-cpp-examples.git
$ cd aws-sdk-cpp-examples
$ docker build -t "$DOCKER_IMAGE" .
# For Alpine:
# docker build -t "$DOCKER_IMAGE" -f Dockerfile.alpine .
The executeable s3-demo
is copied /usr/local/bin
during the build time. The demo application consumes only one argument - region
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest-alpine"
# Using environment variables
$ docker run --rm -it \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN "$DOCKER_IMAGE" s3-demo eu-west-1
# Output: List of buckets ...
# Using configuration file in readonly mode (haven't tested it)
$ docker run --rm -it -v $HOME/.aws/:/root/.aws/:ro "$DOCKER_IMAGE" s3-demo eu-west-1
# Output: List of buckets ...
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest-dev" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp-examples:latest-alpine-dev"
$ git clone https://github.com/unfor19/aws-sdk-cpp-examples.git
$ cd aws-sdk-cpp-examples
$ docker build -t "$DOCKER_IMAGE" --target build-app --build-arg APP_MOUNT_VOLUME="true" .
# For Alpine:
# docker build -t "$DOCKER_IMAGE" --target build-app --build-arg APP_MOUNT_VOLUME="true" . -f Dockerfile.alpine
Mount this project to the container and then build the application.
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-dev" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-alpine-dev"
# Change something in src/s3-demo.cpp with local IDE and build the application while in the container
# Using environment variables
$ docker run --rm -it -v "$PWD"/:/code/ \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN "$DOCKER_IMAGE" bash
root@852c75b69bd4:/code/build# s3-demo eu-west-1
# Output: List of buckets ...
# Change something in src/s3-demo.cpp with local IDE and build the application while in the container
root@852c75b69bd4:/code/build# make
root@852c75b69bd4:/code/build# s3-demo eu-west-1
# Output: List of buckets ...
$ DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-sdk" # ubuntu
# For Alpine:
# DOCKER_IMAGE="unfor19/aws-sdk-cpp:latest-alpine-sdk"
$ docker build -t "$DOCKER_IMAGE" --target build-aws-sdk-cpp .
# For Alpine:
# docker build -t "$DOCKER_IMAGE" --target build-aws-sdk-cpp . -f Dockerfile.alpine
Created and maintained by Meir Gabay
This project is licensed under the MIT License - see the LICENSE file for details