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

update workflows #28

Merged
merged 4 commits into from
Jul 3, 2024
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
8 changes: 4 additions & 4 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
admin@trfore.dev.
<admin@trfore.com>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: 'weekly'
day: 'wednesday'
interval: "weekly"
day: "wednesday"
2 changes: 1 addition & 1 deletion .github/workflows/bot_auto_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-approve bot PR
run: gh pr review --approve "$PR_URL"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ on:
workflow_dispatch:
inputs:
manual_deploy:
description: 'deploy to docker hub'
description: "deploy to docker hub"
default: false
required: true
type: boolean
pull_request:
branches: [main]
types: [closed]
paths-ignore:
- 'LICENSE'
- 'README.md'
- "LICENSE"
- "README.md"

jobs:
deploy:
if: ${{ github.event.pull_request.merged == true || inputs.manual_deploy == true }}
uses: trfore/docker-image/.github/workflows/deploy_docker_hub.yml@main # remote repo
with:
PLATFORMS: 'linux/amd64'
PLATFORMS: "linux/amd64"
secrets:
USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
41 changes: 36 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
name: CI
on:
workflow_dispatch:
push:
branches: [main]
branches: ["*"]
paths:
- 'Dockerfile'
- "Dockerfile"
pull_request:
branches: ["*"]
paths-ignore:
- "**.md"
- "LICENSE"
workflow_dispatch:

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
test_build:
uses: trfore/docker-image/.github/workflows/test_systemd.yml@main # remote repo
cgroup-v1:
uses: trfore/docker-image/.github/workflows/test_systemd.yml@main
with:
continue-on-error: true
runner: ubuntu-20.04
volume-permission: ro

cgroup-v2:
uses: trfore/docker-image/.github/workflows/test_systemd.yml@main
with:
continue-on-error: false
runner: ubuntu-22.04
volume-permission: rw

check:
if: success() || failure()
needs:
- cgroup-v1
- cgroup-v2
runs-on: ubuntu-latest
steps:
- run: >-
python -c "assert set([
'${{ needs.cgroup-v2.result }}',
]) == {'success'}"
2 changes: 1 addition & 1 deletion .github/workflows/update_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Check & Update Base OS Digest
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * 1,3,5'
- cron: "0 2 * * 1,3,5"

jobs:
update:
Expand Down
6 changes: 6 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
default: true

MD013:
line_length: 120
code_blocks: false
tables: false
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ repos:
- id: check-symlinks
- id: check-json
- id: check-yaml
args: [--allow-multiple-documents]
- id: detect-private-key
- id: end-of-file-fixer
- id: no-commit-to-branch
args: [--branch, main]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.40.0
hooks:
- id: markdownlint
5 changes: 2 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# linted by yamllint
*.yaml
*.yml
# dev environments
.venv
91 changes: 45 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@

A minimal systemd enabled debian12 Docker image for testing Ansible roles with Molecule.

NOTE: This image does NOT contain Ansible tooling, e.g. `ansible-core` or `yamllint`. Thus, the use case is as target host for Ansible controllers or within the Molecule `create`/`converge`/`test` cycle.
NOTE: This image does NOT contain Ansible tooling, e.g. `ansible-core` or `yamllint`. Thus, the use case is as target
host for Ansible controllers or within the Molecule `create`/`converge`/`test` cycle.

**Docker Pull Command**
## Docker Pull Command

```sh
docker pull trfore/docker-debian12-systemd
```

## How to Build

This image is built on Docker Hub automatically any time the upstream OS image is rebuilt, and any time a commit is made or merged to the `main` branch. But if you need to build the image on your own locally, do the following:
This image is built on Docker Hub automatically any time the upstream OS image is rebuilt, and any time a commit is made
or merged to the `main` branch. But if you need to build the image on your own locally, do the following:

1. Install [docker]
2. Clone the repo, `git clone https://github.com/trfore/docker-debian12-systemd.git`
Expand All @@ -26,53 +28,52 @@ This image is built on Docker Hub automatically any time the upstream OS image i

### Within Molecule Scenario

1. Add the following code to your molecule scenario file, e.g. `molecule/default/molecule.yml`.

```yaml
platforms:
- name: instance
image: trfore/docker-debian12-systemd:latest
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
```
- Add the following code to your molecule scenario file, e.g. `molecule/default/molecule.yml`.

```yaml
platforms:
- name: instance
image: trfore/docker-debian12-systemd:latest
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
```

### Interactively Using Docker

1. Install [docker]
2. Build an image locally (see above) or pull from Docker Hub: `docker pull trfore/docker-debian12-systemd:latest`
3. **On Docker with Cgroup V1 (e.g. Ubuntu 20.04)**, run a container from the image:
- Install [docker]
- Build an image locally (see above) or pull from Docker Hub: `docker pull trfore/docker-debian12-systemd:latest`
- **On Docker with Cgroup V1 (e.g. Ubuntu 20.04)**, run a container from the image:

```sh
docker run -d -it --name debian12-systemd --privileged --cgroupns=host --tmpfs=/run --tmpfs=/tmp --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro trfore/docker-debian12-systemd:latest
```
```sh
docker run -d -it --name debian12-systemd --privileged --cgroupns=host --tmpfs=/run --tmpfs=/tmp --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro trfore/docker-debian12-systemd:latest
```

3. **On Docker with Cgroup V2 (e.g. Ubuntu 22.04)**, run a container from the image:
- **On Docker with Cgroup V2 (e.g. Ubuntu 22.04)**, run a container from the image:

```sh
docker run -d -it --name debian12-systemd --privileged --cgroupns=host --tmpfs=/run --tmpfs=/tmp --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw trfore/docker-debian12-systemd:latest
```
```sh
docker run -d -it --name debian12-systemd --privileged --cgroupns=host --tmpfs=/run --tmpfs=/tmp --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw trfore/docker-debian12-systemd:latest
```

4. Use it, example:
- Use it, example:

```sh
docker exec -it debian12-systemd /bin/bash
```
```sh
docker exec -it debian12-systemd /bin/bash
```

### Using Podman

- Podman defaults to running containers in systemd mode, `--systemd=true`, and will mount the required tmpfs and cgroup filesystem. See [Podman Docs: Commands `run --systemd`] for details.

```sh
podman run -d -it --name debian12-systemd docker.io/trfore/docker-debian12-systemd:latest
```
- Podman defaults to running containers in systemd mode, `--systemd=true`, and will mount the required tmpfs and cgroup
filesystem. See [Podman Docs: Commands `run --systemd`] for details.

## Systemd with Cgroup V1 or V2
```sh
podman run -d -it --name debian12-systemd docker.io/trfore/docker-debian12-systemd:latest
```

## Additional Images

Expand All @@ -89,26 +90,24 @@ podman run -d -it --name debian12-systemd docker.io/trfore/docker-debian12-syste

## Maintainers

Taylor Fore (https://github.com/trfore)
Taylor Fore (<https://github.com/trfore>)

## Acknowledgements

Inspired by Jeff Geerling's ([@geerlingguy](https://github.com/geerlingguy)), CentOS 8, Debian 10/11, and Ubuntu 20/22 docker images for ansible, [geerlingguy/docker-\*-ansible](https://github.com/geerlingguy?tab=repositories&q=docker-ansible).
Inspired by Jeff Geerling's ([@geerlingguy](https://github.com/geerlingguy)), CentOS 8, Debian 10/11, and Ubuntu 20/22
docker images for ansible, [geerlingguy/docker-\*-ansible](https://github.com/geerlingguy?tab=repositories&q=docker-ansible).

## References

- https://molecule.readthedocs.io/en/stable/index.html
- https://molecule.readthedocs.io/en/stable/examples.html#systemd-container
- https://developers.redhat.com/blog/2016/09/13/running-systemd-in-a-non-privileged-container
- <https://molecule.readthedocs.io/en/stable/index.html>
- <https://molecule.readthedocs.io/en/stable/examples.html#systemd-container>
- <https://developers.redhat.com/blog/2016/09/13/running-systemd-in-a-non-privileged-container>
- [github runner - ubuntu 20.04] preinstalled software
- [github runner - ubuntu 22.04] preinstalled software

[alpine]: https://hub.docker.com/_/alpine/
[centos]: https://hub.docker.com/_/centos/
[centos-stream]: https://quay.io/repository/centos/centos?tab=tags
[debian]: https://hub.docker.com/_/debian/
[docker]: https://docs.docker.com/engine/installation/
[rocky]: https://hub.docker.com/r/rockylinux/
[ubuntu]: https://hub.docker.com/_/ubuntu/
[docker-centos8-systemd]: https://github.com/trfore/docker-centos8-systemd/blob/main/Dockerfile
[docker-centos9-systemd]: https://github.com/trfore/docker-centos9-systemd/blob/main/Dockerfile
Expand Down
Loading