This repository contains a Dockerfile for setting up a development environment for AWS Cloud Development Kit (CDK) using Python 3.9 on Debian Bullseye (11). The image includes Node.js, AWS CLI, and other necessary tools to work with AWS CDK.
- Base Image: Debian Bullseye (11) with Python 3.9.
- Node.js: Installed via nvm (Node Version Manager) to manage different Node.js versions.
- AWS CLI v2: Installed and configured based on system architecture (amd64/arm64).
- AWS CDK: Globally installed for infrastructure as code using Python and AWS.
- Python Packages: Python development packages such as pip, venv, setuptools, and wheel are pre-installed.
- Non-root User: The image runs as a non-root user (
developer
) for better security. - Microsoft DevContainer: Prepared for usage in the Microsoft DevContainer in Visual Studio Code.
- Docker installed on your local machine.
- A copy of this repository.
- DevContainer Extension installed (If you use the Dockerfile in Microsoft DevContainer)
To build the Docker image, navigate to the directory containing the Dockerfile and run the following command:
docker build -t aws-cdk-python3.9 .
This command will create a Docker image named aws-cdk-python3.9
.
Once the image is built, you can start a container using:
docker run -it --rm -v $(pwd):/workspaces aws-cdk-python3.9
This command runs the container in interactive mode (-it
), removes it after exit (--rm
), and mounts the current directory into the container's /workspaces
directory.
Install the Microsoft DevContainers extension from the VS Code marketplace.
Make a local clone of your Github Repository.
Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS) to open the Command Palette.
Enter the command "Dev Containers: Open Folder in Container" in the VSCode Command Palette.
VSCode will open a new window in the Container. You see the new active container environment on the left lower corner.
Once the container is up, you can start coding in your fully configured environment.
The project directory on your Host will be automatically mounted inside the container, so all your changes are saved locally.
Enter the command "Dev Containers: Clone Repository in Container Volume" in the VSCode Command Palette.
Select the GitHub Repository and the branch you want to load into the Container.
VSCode will open a new window in the Container. You see the new active container environment on the left lower corner.
Once the container is up, you can start coding in your fully configured environment.
The project directory of your GitHub repository will be automatically mounted inside the container, so all your changes are saved locally.
- Working Directory: The container's default working directory is
/workspaces
. Any files you work on will be synced with your host machine's directory. - Python: Use
python3
to run Python scripts. - AWS CDK: Use
cdk
commands for AWS CDK operations. - AWS CLI: Use
aws
to interact with AWS services.
You can modify the requirements.txt
and requirements_dev.txt
files to include additional Python packages. The Dockerfile is set up to automatically install these dependencies when building the image.
- aws-cdk-lib
- constructs
- boto3
- pytest
If you encounter issues, consider the following steps:
- Rebuild the Image: Sometimes changes might not reflect due to caching. Rebuild the image with the
--no-cache
option:docker build --no-cache -t aws-cdk-python3.9 .
- Check Logs: Use the
docker logs <container_id>
command to view container logs if it fails to start.
Feel free to open issues or pull requests if you have any suggestions or improvements.
This project is licensed under the MIT License. See the LICENSE file for more details.