Skip to content

Commit

Permalink
docs(buildah): add github actions buildah docs
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeniy Frolov <[email protected]>
  • Loading branch information
Fral738 committed Nov 14, 2024
1 parent b9fd685 commit 7ddf1af
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 5 deletions.
26 changes: 25 additions & 1 deletion bin/configurator/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ combinations:
- name: "buildBackend"
value: "docker"

# github actions simple
# GitHub actions host docker
- tabs:
- name: "project"
includePath: "/configurator/tab/ci/github-actions/simple/host-runner/linux/docker/project.md.liquid"
Expand All @@ -122,6 +122,30 @@ combinations:
- name: "repoType"
value: "application"

# GitHub Actions host buildah
- tabs:
- name: "infra"
includePath: "/configurator/tab/ci/github-actions/simple/host-runner/linux/buildah/infra.md.liquid"
- name: "project"
includePath: "/configurator/tab/ci/github-actions/simple/host-runner/linux/buildah/project.md.liquid"
options:
- name: "usage"
value: "ci"
- name: "ci"
value: "githubActions"
- name: "runnerType"
value: "hostRunner"
- name: "os"
value: "linux"
- name: "buildBackend"
value: "buildah"
- name: "projectType"
value: "simplified"
- name: "sharedCICD"
value: "no"
- name: "repoType"
value: "application"

# gitlab ci cd simple
- tabs:
- name: "infra"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Requirements

- GitHub;

- Host to run GitHub Runner

### Installing the GitHub Runner

Follow [official instructions](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners) to install the GitHub Runner on your dedicated host.

{% include configurator/partials/ci/buildah_install.md.liquid %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Configuring CI/CD of the project

This is how the repository that uses werf for build and deploy might look:

{% tree_file_viewer '/examples/configurator/ci-cd/simple/github-actions/host-runner/linux/buildah' default_file='.github/workflows/prod.yml' %}

Extras:
* Add authorization options for `werf cleanup` in the container registry by following [instructions]({{ "/docs/v2/usage/cleanup/cr_cleanup.html#features-of-working-with-different-container-registries" | relative_url }}).
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Save the kubeconfig file to access the Kubernetes cluster as a `KUBECONFIG_BASE6

This is how the repository that uses werf for build and deploy might look:

{% tree_file_viewer '/examples/configurator/ci-cd/simple/github-actions/host-runner/linux/buildah' default_file='.github/workflows/prod.yml' %}
{% tree_file_viewer '/examples/configurator/ci-cd/simple/github-actions/host-runner/linux/docker' default_file='.github/workflows/prod.yml' %}

Extras:
* Add authorization options for `werf cleanup` in the container registry by following [instructions]({{ "/docs/v2/usage/cleanup/cr_cleanup.html#features-of-working-with-different-container-registries" | relative_url }}).
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Требования

* GitHub Actions;

* Linux-хост для установки GitHub Runner

### Установка GitHub Runner

Установите GitHub Runner на выделенный для него хост, следуя [официальным инструкциям](https://docs.github.com/ru/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners).

{% include configurator/partials/ci/buildah_install.md.liquid %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Конфигурация CI/CD проекта

Так может выглядеть репозиторий, использующий werf для сборки и развертывания:

{% tree_file_viewer '/examples/configurator/ci-cd/simple/github-actions/host-runner/linux/buildah' default_file='.github/workflows/prod.yml' %}

{% capture registry_guide_url %}/docs/v2/usage/cleanup/cr_cleanup.html#%D0%BE%D1%81%D0%BE%D0%B1%D0%B5%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D1%8B-%D1%81-%D1%80%D0%B0%D0%B7%D0%BB%D0%B8%D1%87%D0%BD%D1%8B%D0%BC%D0%B8-container-registries{% endcapture %}
Дополнительно:
* Добавьте для `werf cleanup` опции авторизации в container registry, следуя [инструкциям]({{ registry_guide_url | relative_url }}).
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

Так может выглядеть репозиторий, использующий werf для сборки и развертывания:

{% tree_file_viewer '/examples/configurator/ci-cd/simple/github-actions/host-runner/linux/buildah' default_file='.github/workflows/prod.yml' %}
{% tree_file_viewer '/examples/configurator/ci-cd/simple/github-actions/host-runner/linux/docker' default_file='.github/workflows/prod.yml' %}

{% capture registry_guide_url %}/docs/v2/usage/cleanup/cr_cleanup.html#%D0%BE%D1%81%D0%BE%D0%B1%D0%B5%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D1%8B-%D1%81-%D1%80%D0%B0%D0%B7%D0%BB%D0%B8%D1%87%D0%BD%D1%8B%D0%BC%D0%B8-container-registries{% endcapture %}
Дополнительно:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
prod:
name: prod
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -20,4 +20,4 @@ jobs:
werf converge
env:
WERF_ENV: prod
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBECONFIG_BASE64 }}
WERF_BUILDAH_MODE: auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: cleanup
on:
schedule:
- cron: "0 3 * * *"

jobs:
cleanup:
name: cleanup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow

- uses: werf/actions/install@v2

- run: |
source "$(werf ci-env github --as-file)"
werf cleanup
env:
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBECONFIG_BASE64 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: prod
on:
push:
branches:
- main

jobs:
prod:
name: prod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: werf/actions/install@v2

- run: |
source "$(werf ci-env github --as-file)"
werf converge
env:
WERF_ENV: prod
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBECONFIG_BASE64 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
spec:
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: {{ .Values.werf.image.app }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: app
spec:
selector:
app: app
ports:
- name: app
port: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node

WORKDIR /app
COPY . .
RUN npm ci

CMD ["node", "server.js"]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "app",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"start": "node server.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const http = require('http');

const hostname = '127.0.0.1';
const port = 80;

const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
configVersion: 1
project: myproject
---
image: app
dockerfile: Dockerfile
context: ./app

0 comments on commit 7ddf1af

Please sign in to comment.