https://github.com/KarmaComputing/minimalcd
Minimal viable Continuous delivery (CD) setup
https://github.com/KarmaComputing/minimalcd
devops dokku good-first-issue kubernetes learn-devops
Last synced: 6 months ago
JSON representation
Minimal viable Continuous delivery (CD) setup
- Host: GitHub
- URL: https://github.com/KarmaComputing/minimalcd
- Owner: KarmaComputing
- Created: 2022-04-12T18:55:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-01T23:41:09.000Z (over 2 years ago)
- Last Synced: 2025-04-03T04:29:56.773Z (6 months ago)
- Topics: devops, dokku, good-first-issue, kubernetes, learn-devops
- Language: Python
- Homepage:
- Size: 104 KB
- Stars: 62
- Watchers: 1
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Minimal Viable Continuous delivery (CD)
> Have you ever wanted to learn Devops, asked "What is Devops" or wanted to start learning DevOps?
This is a minimal viable example of many of the concepts in DevOps which might help you continue to uncover better ways of doing it and help others learn too.
Explore this repo, [ask questions](https://github.com/KarmaComputing/minimalcd/discussions/20) and learnThis is a minimal web application with state (database) which:
- [x] βοΈ Automatically generates releases based on semantic version for every merge into the `main` branch (using [intuit/auto](https://github.com/intuit/auto))
- [x] ποΈ Database migrations are [version controlled](https://github.com/KarmaComputing/minimalcd/tree/main/src/migrations/versions) and ran upon app startup
- This repository uses [alembic](https://alembic.sqlalchemy.org/en/latest/) (python) but you might use [alembic/doctrine](https://github.com/doctrine/migrations) (php), flyway/liquibase (java) - the concept is the same
- [x] π When a pull request is opened, a [preview application](https://github.com/KarmaComputing/minimalcd/actions/workflows/pr-preview.yml) is automatically built, with a url so people can view the proposed new version
- [x] π When a pull request gets merged into the main branch, the latest application is automatically deployed (using [Dokku](https://dokku.com/)). ([Pipeline Code](https://github.com/KarmaComputing/minimalcd/actions/workflows/deploy.yml) / [UI](https://github.com/KarmaComputing/minimalcd/actions/workflows/deploy.yml))
- You might use Kubernetes with ArgoCD (the underlying concepts are the same)
- [x] πΎ A backup/snapshot of any database is taken pre and post each release
- [x] π¨ Codebase is regularly automatically scanned for known security issues
- [x] βΈοΈ At each release a container is built and published to a container registry ([Pipeline Code](https://github.com/KarmaComputing/minimalcd/blob/main/.github/workflows/publish-container.yaml) / [UI](https://github.com/KarmaComputing/minimalcd/actions/workflows/publish-container.yaml))## Local Development
```
cd src
python3.9 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
```Env settings:
```
cp .env.example .env
```### Run locally
```
cd src
. venv/bin/activate
export FLASK_APP=minimalcd
export FLASK_DEBUG=1
flask run
```
http://127.0.0.1:5000## Build
```
podman build -t minimalcd -f src/Dockerfile
```## Run
```
podman run -p 8082:80 minimalcd
```# Day0
> (almost) Everything below this point are instructions if you wanted to set this up yourself from scratch
### Dokku
```
APP_NAME=
DOKKU_SERVER_IP=
DOKKU_USERNAME=
git remote add dokku $DOKKU_USERNAME@$DOKKU_SERVER_IP:$APP_NAME
git remote -v show
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku apps:create $APP_NAME
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku git:initialize $APP_NAME
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku builder:set minimalcd build-dir src
git push dokku main
```### Example:
```
APP_NAME=minimalcd
DOKKU_SERVER_IP=192.168.1.10
DOKKU_USERNAME=dokku
git remote add dokku $DOKKU_USERNAME@$DOKKU_SERVER_IP:$APP_NAME
git remote -v show
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku apps:create $APP_NAME
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku git:initialize $APP_NAME
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku builder-dockerfile:set $APP_NAME dockerfile-path src/Dockerfile
git push dokku main
```### Auto release using autoc
```
curl -L https://github.com/intuit/auto/releases/download/v10.36.5/auto-linux.gz > auto-linux.gz
gunzip auto-linux.gz
chmod +x auto-linux
./auto-linux init
# follow on-screen
./auto-linux create-labels
```# Destroy / Teardown everything
```
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku apps:destroy --force $APP_NAME
```#### Troubleshooting
Dokku by default expects your `Dockerfile` to be in the root directory, **and**
the default working directory is the root of the repo.For changing the name/location of the Dockerfile, you can use the `builder-dockerfile:set`:
```
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku builder-dockerfile:set $APP_NAME dockerfile-path Dockerfile
```
For changing the working directory of the `docker build` context, use:
```
ssh $DOKKU_USERNAME@$DOKKU_SERVER_IP -C dokku builder:set minimalcd build-dir src
```
See https://github.com/dokku/dokku/pull/4502 for more details.# Container Hosting Service
Container hosting service is a (you guessed it!) container hosting service, which automates all the automation above for your own pet projects π
Checkout [Container Hosting Service](https://container-hosting.anotherwebservice.com/?minimalcd)