Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark the git repo as a safe directory #33

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
},
"ghcr.io/devcontainers/features/aws-cli:1": {}
},
"postCreateCommand": [
"pip install --user -U pre-commit && pre-commit install-hooks",
"npm install -g [email protected]"
],
"postCreateCommand": "./tools/setup.sh",
tschaffter marked this conversation as resolved.
Show resolved Hide resolved
"shutdownAction": "stopContainer"
}
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,24 @@ That's it! You are now inside the dev container and have access to all the devel

# Development

The `cdk.json` file tells the CDK Toolkit how to execute your app.
All the development tools are provided when developing inside the dev container
(see above). These tools include Python, AWS CLI, AWS CDK CLI, etc. These tools
also include a Python virtual environment where all the Python packages needed
are already installed.

This project is set up like a standard Python project. The initialization
process also creates a virtualenv within this project, stored under the `.venv`
directory. To create the virtualenv it assumes that there is a `python3`
(or `python` for Windows) executable in your path with access to the `venv`
package. If for any reason the automatic creation of the virtualenv fails,
you can create the virtualenv manually.
If you decide the develop outside of the dev container, some of the development
tools can be installed by running:

To manually create a virtualenv on MacOS and Linux:

```
$ python3 -m venv .venv
```console
./tools/setup.sh
```

After the init process completes and the virtualenv is created, you can use the following
step to activate your virtualenv.
Development requires the activation of the Python virtual environment:

```
$ source .venv/bin/activate
```

If you are a Windows platform, you would activate the virtualenv like this:

```
% .venv\Scripts\activate.bat
```

Once the virtualenv is activated, you can install the required dependencies.

```
$ pip install -r requirements.txt -r requirements-dev.txt
```

At this point you can now synthesize the CloudFormation template for this code.
tschaffter marked this conversation as resolved.
Show resolved Hide resolved

```
Expand Down Expand Up @@ -240,3 +224,4 @@ Example to get an interactive shell run into a container:
```console
AWS_PROFILE=my-aws-profile aws ecs execute-command --cluster OpenChallengesEcs-ClusterEB0386A7-BygXkQgSvdjY --task a2916461f65747f390fd3e29f1b387d8 --container opcenchallenges-mariadb --command "/bin/sh" --interactive
```
test\n
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pre-commit~=3.8.0
pytest==6.2.5
17 changes: 17 additions & 0 deletions tools/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# Safer bash scripts
set -euxo pipefail

# Install Node.js dependencies
npm install -g [email protected]

# Install Python dependencies
pip install --upgrade pip
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt

# Install git hooks
git config --global --add safe.directory "$PWD"
pre-commit install --install-hooks
Loading