Skip to content

Commit

Permalink
docs: merge branch 'main' and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hillairet committed Oct 10, 2024
2 parents 02d74e3 + 8d8e7bc commit 4d1fec0
Show file tree
Hide file tree
Showing 109 changed files with 2,307 additions and 962 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/semantic-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 6 additions & 17 deletions .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ on:
branches:
- main

permissions:
contents: write
issues: write

jobs:
semantic-release:
runs-on: ubuntu-latest
environment: dev
steps:
- name: Prepare workaround
# Create a GitHub App token to authenticate as the workaround app.
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.CI_VERSION_WORKAROUND_APP_ID }}
private-key: ${{ secrets.CI_VERSION_WORKAROUND_APP_PRIVATE_KEY }}

- name: Checkout
# Use the workaround app-token to pull all history and tags for the repository.
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false

- name: Setup Node.js
Expand All @@ -38,12 +33,6 @@ jobs:
run: npm audit signatures

- name: Run Semantic Release
# Use the workaround app-token to authenticate as the workaround app in order to
# push tags to the protected branch.
run: npx semantic-release
env:
# Deprecated in favor of the app token.
#CI_VERSION_WORKAROUND_APP_ID: ${{ vars.CI_VERSION_WORKAROUND_APP_ID }}
#CI_VERSION_WORKAROUND_APP_PRIVATE_KEY: ${{ secrets.CI_VERSION_WORKAROUND_APP_PRIVATE_KEY }}
#GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} # I think this is deprecated in favor of the app token
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/setup-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
tags: sixfeetup/scaf:${{ github.sha }}
tags: |
sixfeetup/scaf:${{ github.sha }}
sixfeetup/scaf:latest
context: .
file: ./Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64

setup:
environment: dev
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ fabric.properties
# VcsDirectoryMappings
.idea/vcs.xml

.idea/cookiecutter-sixiedjango.iml
.idea/inspectionProfiles/profiles_settings.xml
.idea/misc.xml

Expand Down Expand Up @@ -385,3 +384,6 @@ dist
*.tfvars.json

.direnv

# scaf challenge
.scaf-challenge.json
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Changelog

## [1.17.0](https://github.com/sixfeetup/scaf/compare/v1.16.1...v1.17.0) (2024-10-05)

### Features

* deploy apps with ArgoCD ([6938661](https://github.com/sixfeetup/scaf/commit/69386611ee96ec2e0278fbf57717db10bc484c7e))

## [1.16.1](https://github.com/sixfeetup/scaf/compare/v1.16.0...v1.16.1) (2024-09-25)

### Bug Fixes

* entrypoint.sh: Reorder commands so UID and GID checks work ([#395](https://github.com/sixfeetup/scaf/issues/395)) ([bd8e647](https://github.com/sixfeetup/scaf/commit/bd8e6470260a087ea639ad52eb735d7065fe6f88))

## [1.16.0](https://github.com/sixfeetup/scaf/compare/v1.15.1...v1.16.0) (2024-09-23)

### Features

* update text references to refer to Scaf instead of Sixie ([#393](https://github.com/sixfeetup/scaf/issues/393)) ([5288cf0](https://github.com/sixfeetup/scaf/commit/5288cf0ac843d7c474e6e16232b65795581f198f))

## [1.15.1](https://github.com/sixfeetup/scaf/compare/v1.15.0...v1.15.1) (2024-09-21)

### Bug Fixes

* check for python commands, fallback to python3 refs [#386](https://github.com/sixfeetup/scaf/issues/386) ([#389](https://github.com/sixfeetup/scaf/issues/389)) ([7510477](https://github.com/sixfeetup/scaf/commit/7510477414c60b35a517c1416137164e98e7a5d8))

## [1.15.0](https://github.com/sixfeetup/scaf/compare/v1.14.0...v1.15.0) (2024-09-21)

### Features

* added local registry support and improved setup (close [#353](https://github.com/sixfeetup/scaf/issues/353)) ([32de8c7](https://github.com/sixfeetup/scaf/commit/32de8c76b260f81774e087dc221c237767a0049a))
* Gfranxman/313 prefer dotlocalbin as install location ([#342](https://github.com/sixfeetup/scaf/issues/342)) ([dbb3556](https://github.com/sixfeetup/scaf/commit/dbb3556e7258a57e5105f80063f95f3222d3fd6a))
* implement s3 storage for static and media files on production ([#339](https://github.com/sixfeetup/scaf/issues/339)) ([76afd23](https://github.com/sixfeetup/scaf/commit/76afd23da1aa0867422249584a3156f43b7b974e))
* implement scaf challenge for session recording ([#379](https://github.com/sixfeetup/scaf/issues/379)) ([0c091af](https://github.com/sixfeetup/scaf/commit/0c091afbd574632350f2c4cdb43420fadb8eb317))
* **install.sh:** force re-download of Scaf on each install ([#338](https://github.com/sixfeetup/scaf/issues/338)) ([f7ef3e3](https://github.com/sixfeetup/scaf/commit/f7ef3e3ac0876c70f4c6f3e1f34a41386321e9a3))
* op inject secrets (close [#368](https://github.com/sixfeetup/scaf/issues/368)) ([58090b5](https://github.com/sixfeetup/scaf/commit/58090b56f65f35cb2c68258f0aa4f3aaf8509417))
* reorder environment variables in k8s django config ([#350](https://github.com/sixfeetup/scaf/issues/350)) ([f2cb234](https://github.com/sixfeetup/scaf/commit/f2cb2349666ecd46f24145c49b5f42bbc189c9b4))
* script to test cookiecutter part of Scaf ([952e276](https://github.com/sixfeetup/scaf/commit/952e276852afe84cdbfca062da65fcae6cad6bc8))

### Bug Fixes

* Fixes frontend tests ([#363](https://github.com/sixfeetup/scaf/issues/363)) ([4a2a5b2](https://github.com/sixfeetup/scaf/commit/4a2a5b254891fd4b1688499d17240aa93356ce81))
* mailhog port config (closes [#249](https://github.com/sixfeetup/scaf/issues/249)) ([cea1602](https://github.com/sixfeetup/scaf/commit/cea1602d99e5a03e63fc8cffcc842844bf648897))
* Specify the full container path, including the host. ([#309](https://github.com/sixfeetup/scaf/issues/309)) ([2fa7276](https://github.com/sixfeetup/scaf/commit/2fa727672fc6b8ab2a0c40550f63cf27ba3b859c)), closes [#308](https://github.com/sixfeetup/scaf/issues/308)
* Update logo ([#373](https://github.com/sixfeetup/scaf/issues/373)) ([afe2d84](https://github.com/sixfeetup/scaf/commit/afe2d849ad6db3ca05d812d1da12c02a9f127b96))
* use GitHub token for semantic release workflow ([b5eef60](https://github.com/sixfeetup/scaf/commit/b5eef607dbc4b7bad9a6037bb8bc30dd81c100d2))

### Documentation

* add disk space warning to README ([#385](https://github.com/sixfeetup/scaf/issues/385)) ([4262b2d](https://github.com/sixfeetup/scaf/commit/4262b2d0868edf3dd1b22a6aef5aac78ae203afb))
* update related to optional GraphQL ([#366](https://github.com/sixfeetup/scaf/issues/366)) ([92bfc8d](https://github.com/sixfeetup/scaf/commit/92bfc8d61f53d9845a3d7e952c96225b22e95a3d)), closes [#290](https://github.com/sixfeetup/scaf/issues/290)

## [1.14.0](https://github.com/sixfeetup/scaf/compare/v1.13.2...v1.14.0) (2024-09-04)

### Features
Expand Down
116 changes: 42 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
<p align="center">
<img src="https://github.com/sixfeetup/cookiecutter-sixiedjango/assets/784273/4e378983-c351-4656-95b9-b5c38d70991d" width="450px">
<img src="{{cookiecutter.project_slug}}/frontend/public/scaf-logo.png" width="250px">
</p>

**scaf** provides developers and DevOps engineers with a complete blueprint for
a new project and streamlines the development experience with Tilt.

**scaf** generates a new project structure with Kubernetes manifests in
three Kustomize layers for dev, sandbox, and production. A new project
three Kustomize layers for dev, sandbox, and production. A new project
contains the following:
* NextJS or React frontend
* Django backend
* Postgres database for local development
* CloudNativePG deployment for production
* Redis
* Mailhog
* ArgoCD
* Traefik
* Certmanger
* Certificates and Ingress Routes
* Kube Prometheus Stack
* Grafana Loki
* GitHub and Bitbucket pipelines to build and push images, run security,
formatting and linting checks
* Terraform config to set up a k3s cluster on AWS

- Django backend
- Celery (optional)
- Next.js frontend (optional)
- Strawberry GraphQL (if frontend is chosen)
- Apollo Client (if frontend is chosen)
- _TODO: REST alternative to GraphQL_
- Postgres database for local development
- CloudNativePG deployment for production
- Redis
- Mailhog
- ArgoCD
- Traefik
- Certmanger
- Certificates and Ingress Routes
- Kube Prometheus Stack
- Grafana Loki
- GitHub and Bitbucket pipelines to build and push images, run security,
formatting and linting checks
- Terraform config to set up a k3s cluster on AWS
- Sentry (optional)

## Installation

Installation is supported on Linux and macOS:

```
curl -sSL https://raw.githubusercontent.com/sixfeetup/scaf/main/install.sh | sh
```
Expand All @@ -36,6 +43,10 @@ be found on your system.

## Creating a new project using this repo

NB: Before you continue, make sure that you have at least 5 to 10 GB of free
space available to Docker. Note that Docker Desktop on MacOS has its own
resource limits separate from the host.

Run `scaf myproject`, answer all the questions, and you'll have your new project!

Inside `myproject/README.md`, you will have more
Expand All @@ -45,8 +56,9 @@ documentation explaining how to use and configure your newly created project.

To deploy your project using Terraform and AWS, you can follow the instructions in `terraform/README.md.`
Note that you will need:

- an AWS account where you have access to the `OrganizationAccountAccessRole`
- terraform, and AWS CLI installed and configured
- terraform, and AWS CLI installed and configured

## Development on Scaf

Expand All @@ -57,7 +69,7 @@ The Nix Flake ensures all developers are using the same versions of all packages
to develop on Scaf in an isolated environment.

Follow the instructions to install
[Nix](https://nixos.org/download/#download-nix) for your OS.
[Nix](https://nixos.org/download/#download-nix) for your OS.

Nix Flakes are a feature that comes with Nix, but they are considered
experimental and are not enabled by default in stable releases of Nix. To use
Expand Down Expand Up @@ -111,64 +123,20 @@ When making changes to scaf, keep the following in mind:
- update to the latest Python supported by Django. For Django 4.1, this is 3.8, 3.9, and 3.10.

### Testing
To test the cookiecutter portion of scaf, create virtual environment ad install black, isort and cookiecutter.
Create a test cookiecutter.yaml file with the following content:
```yaml
---
default_context:
author_name: Joe Sixie
aws_account_id: "000000000000"
aws_region: us-east-1
create_nextjs_frontend: y
debug: n
description: Behold My Awesome Project!
domain_name: sixfeetup.com
email: [email protected]
mail_service: Mailgun
project_dash: my-awesome-sixie-project
project_name: My Awesome Sixie Project
project_slug: my_awesome_sixie_project
repo_name: my_awesome_sixie_project
repo_url: [email protected]:sixfeetup/my_awesome_sixie_project.git
source_control_organization_slug: sixfeetup
source_control_provider: github.com
timezone: US/Eastern
use_celery: n
use_graphql: y
use_sentry: n
version: 0.1.0

```

Then create a helper script to run the tests:
```bash
#! /bin/bash
To test the cookiecutter portion of Scaf, run the `./test-scaf.sh` script.

SCAF_ROOT=/Users/gfranxman/sfu/ScafDev/scaf
OUTPUT_FOLDER=./scaf-test
TEST_CONFIG=./scaf-cookiecutter.yaml
If you are not using the Nix development environment, create a virtual environment and
install black, isort and cookiecutter before running `./test-scaf.sh`.

rm -rf $OUTPUT_FOLDER && cookiecutter $SCAF_ROOT --no-input --config-file $TEST_CONFIG -o $OUTPUT_FOLDER -v
Running `./test-scaf.sh -h` shows the usage instructions:

```shell
Usage: ./test-scaf.sh [-b <branch_name>] [-o <output_folder>] [-c <config_file>] [-h]
-b <branch_name> Optional: Specify the branch to test (default is local checkout)
-o <output_folder> Optional: Specify the output folder (default is /tmp/scaf-test)
-c <config_file> Optional: Specify the config file (default is ./test-configs/nextjs-django-github.yaml)
-h Show this help message
```

Run the script and check the output folder for the generated project.

To test run the project using your branch for scaf and the cookiecutter you have to tell it
which branch and repo to use. Here is an example script to do that:

(You will need to adjust the paths and branch name to match your setup):
```bash
#! /bin/bash

SCAF_ROOT=/Users/gfranxman/sfu/ScafDev/scaf
OUTPUT_FOLDER=./scaf-test
TEST_CONFIG=./scaf-cookiecutter.yaml

BRANCH_NAME=gfranxman/configure-git-remote
BASE_REPO=https://github.com/sixfeetup/scaf.git


rm -rf $OUTPUT_FOLDER && \
$SCAF_ROOT/scaf myproject --no-input --checkout $BRANCH_NAME ${BASE_REPO}
```
Feel free to add more useful test configurations to `./test-configs/`.
5 changes: 3 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"project_name": "My Awesome Sixie Project",
"project_name": "My Awesome Scaf Project",
"project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_')|replace('.', '_')|trim() }}",
"project_dash": "{{ cookiecutter.project_name.lower()|replace(' ', '-')|replace('_', '-')|replace('.', '-')|trim() }}",
"description": "Behold My Awesome Project!",
"author_name": "Joe Sixie",
"author_name": "Joe Scaf",
"domain_name": "sixfeetup.com",
"email": "{{ cookiecutter.author_name.lower()|replace(' ', '-') }}@{{ cookiecutter.domain_name }}",
"version": "0.1.0",
Expand All @@ -16,6 +16,7 @@
"Amazon SES",
"Other SMTP"
],
"_challenge": "n",
"use_celery": "n",
"use_sentry": "n",
"debug": "n",
Expand Down
8 changes: 4 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ fi

# Function to check if a group with the given GID already exists
group_exists_with_gid() {
echo "Checking if user with UID $1 exists..."
getent group | cut -d: -f3 | grep -q "^$1$"
echo "Checking if group with GID $1 exists..."
}

# Function to check if a user with the given UID already exists
user_exists_with_uid() {
getent passwd | cut -d: -f3 | grep -q "^$1$"
echo "Checking if user with UID $1 exists..."
getent passwd | cut -d: -f3 | grep -q "^$1$"
}

# Function to check if the scaf user already has the target UID
scaf_has_uid() {
[ "$(id -u scaf)" -eq "$1" ]
echo "Checking if scaf has UID $1..."
[ "$(id -u scaf)" -eq "$1" ]
}

# Function to check if the scaf group already has the target GID
scaf_has_gid() {
[ "$(getent group scaf | cut -d: -f3)" -eq "$1" ]
echo "Checking if scaf group has GID $1..."
[ "$(getent group scaf | cut -d: -f3)" -eq "$1" ]
}

# Modify the scaf user account to match the host user, adjusting for existing GID
Expand Down
Loading

0 comments on commit 4d1fec0

Please sign in to comment.