Skip to content

Commit

Permalink
add devbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrizio Cafolla committed Sep 18, 2024
1 parent 3dcef75 commit bbf3c25
Show file tree
Hide file tree
Showing 22 changed files with 3,858 additions and 2,051 deletions.
12 changes: 9 additions & 3 deletions .activate
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ if [ "${BASH_SOURCE-}" = "$0" ]; then
exit 33
fi

if [[ -f .venv/bin/activate ]]; then
source .venv/bin/activate
venv_filename="${VENV_DIR:-.venv}/bin/activate"

if [[ -f ${venv_filename} ]]; then
source "${venv_filename}"
else
echo "WARN No virtualenv found. Run 'make setup' to create one."
fi

if [[ -f .env ]]; then
source .env
source ".env"
fi

if [[ -f .env.doppler ]]; then
source ".env.doppler"
fi
6 changes: 4 additions & 2 deletions .github/workflows/actions/terraform-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ runs:
- name: Set Terraform 1.7
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.7"
terraform_version: "1.9"

- name: Terraform Plan
shell: bash
working-directory: infrastructure
env:
WORKSPACE: ${{ inputs.WORKSPACE }}
AWS_DEFAULT_REGION: ${{ inputs.AWS_DEFAULT_REGION }}
AWS_ACCOUNT_ID: ${{ inputs.AWS_ACCOUNT_ID }}
AWS_TERRAFORM_STATE_BUCKET: ${{ inputs.AWS_TERRAFORM_STATE_BUCKET }}
run: |
make setup-infrastructure
devbox shell
devbox run infra setup
36 changes: 10 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,20 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Python 3.12
uses: actions/setup-python@v5
- name: Install devbox
uses: jetify-com/[email protected]
with:
python-version: "3.12"
cache: "pip"
enable-cache: 'true'

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: "website/.nvmrc"
cache-dependency-path: website/yarn.lock
cache: "yarn"

- name: Terraform Init
id: terraform
uses: ./.github/workflows/actions/terraform-init
timeout-minutes: 5
with:
- name: Setup
timeout-minutes: 10
env:
WORKSPACE: ${{ env.WORKSPACE }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ROLE_NAME: ${{ secrets.AWS_ROLE_NAME }}

- name: Setup
timeout-minutes: 5
run: |
make setup-project VIRTUAL_ENV=false
make setup-website VIRTUAL_ENV=false
- name: Test
timeout-minutes: 5
run: |
make tests
devbox shell
devbox run setup
devbox run infra setup
devbox run tests
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ __pycache__
.venv
*.egg-info

.*.env
.env
.env*
.DS_Store
35 changes: 0 additions & 35 deletions Makefile

This file was deleted.

41 changes: 16 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,54 @@

### Requirements

|pkg|version|used in |
|pkg|version|install|
|---|---|---|
|node | v21.7.1| website/ |
|yarn | 1.22.22| website/ |
|python | >= 3.10 | website/ |
|terraform | >= 1.7 | infrastructure/ |
|tflint | >= 0.51.0 | infrastructure/ |
|devbox|`>=0.12.0`|[docs](https://www.jetify.com/devbox/docs/installing_devbox/#install-devbox)|

### Devmode

**Develop website in local:**

```bash
make setup-project setup-website
devbox shell

source .activate

make start
devbox run website start
```

If you want start website with italian lang run: `make start LOCALE=it`.
If you want start website with italian lang run: `devbox run website start LOCALE=it`.

If you want start website with multi-lang run: `make build && make serve`
If you want start website with multi-lang run: `devbox run website build serve`

**Develop infrastructure in local:**

With doppler access:

```bash
doppler login
devbox shell

make doppler
doppler login

echo 'export AWS_ACCESS_KEY_ID=...' >> .aws.env
echo 'export AWS_SECRET_ACCESS_KEY=...' >> .aws.env
devbox run doppler

source .env
# WARN: Before run `infra` cmd export AWS Credentials or Profile

make setup-infrastructure
devbox run infra setup

make plan
devbox run infra plan
```

Or set your env vars without doppler:

```bash
echo 'export WORKSPACE=...' > .env
echo 'export AWS_ACCOUNT_ID=...' >> .env
echo 'export AWS_DEFAULT_REGION=...' >> .env
echo 'export AWS_TERRAFORM_STATE_BUCKET=...' >> .env # (optional) If not set, use local backend by default

echo 'export AWS_ACCESS_KEY_ID=...' >> .env
echo 'export AWS_SECRET_ACCESS_KEY=...' >> .env
# WARN: Before run `infra` cmd export AWS Credentials or Profile

source .env
devbox shell

make setup-infrastructure
devbox run infra setup

make plan
devbox run infra plan
```
35 changes: 35 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
"packages": [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
],
"env": {},
"include": [],
"shell": {
"init_hook": [". .activate", "devbox run setup"],
"scripts": {
"infra": ["cd infrastructure && make $@ ; cd -"],
"website": ["cd website && make $@ ; cd -"],
"setup": [
"chmod +x scripts/*",
"pip3 install -r requirements.txt",
"pre-commit install",
"devbox run website setup"
],
"deploy": ["./scripts/deploy.sh"],
"doppler": ["./scripts/doppler.sh"],
"lint": ["pre-commit run --all-files"],
"tests": [
"devbox run lint",
"devbox run website pages-check",
"devbox run website build",
"devbox run infra plan"
]
}
}
}
Loading

0 comments on commit bbf3c25

Please sign in to comment.