Skip to content

Commit

Permalink
Merge branch 'main' into update-baseos
Browse files Browse the repository at this point in the history
  • Loading branch information
trfore authored Jul 3, 2024
2 parents 99591e6 + 8f3be90 commit eafd0c1
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 61 deletions.
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"
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"
- "**.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 }}
42 changes: 37 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
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: always() && failure()
needs:
- cgroup-v1
- cgroup-v2
runs-on: ubuntu-latest
steps:
- run: >-
python -c "assert set([
'${{ needs.cgroup-v1.result }}',
'${{ 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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# docker
.cache

# environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# general extras
.DS_Store
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
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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
11 changes: 8 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# linted by yamllint
*.yaml
*.yml
# environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
81 changes: 41 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@

A minimal systemd enabled centos9 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-centos9-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-centos9-systemd.git`
Expand All @@ -26,45 +28,46 @@ 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-centos9-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-centos9-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-centos9-systemd:latest`
3. Run a container from the image:
- Install [docker]
- Build an image locally (see above) or pull from Docker Hub: `docker pull trfore/docker-centos9-systemd:latest`
- Run a container from the image:

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

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

```sh
docker exec -it centos9-systemd /bin/bash
```
```sh
docker exec -it centos9-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.
- 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 centos9-systemd docker.io/trfore/docker-centos9-systemd:latest
```
```sh
podman run -d -it --name centos9-systemd docker.io/trfore/docker-centos9-systemd:latest
```

## Additional Images

Expand All @@ -81,26 +84,24 @@ podman run -d -it --name centos9-systemd docker.io/trfore/docker-centos9-systemd

## 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

0 comments on commit eafd0c1

Please sign in to comment.