-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nikita Pushchin
committed
Apr 28, 2023
0 parents
commit 401b3b0
Showing
59 changed files
with
4,853 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
on: push | ||
|
||
permissions: { contents: read } | ||
|
||
jobs: | ||
flake8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-python@v3 | ||
- name: Installing dependencies | ||
run: | | ||
# installing dependencies | ||
python -m pip install --upgrade pip | ||
pip install --upgrade flake8 | ||
- uses: actions/checkout@v3 | ||
with: { path: snapshot } | ||
- name: Executing `flake8` | ||
run: | | ||
# executing `flake8` | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 ./snapshot --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 ./snapshot --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
util-linux: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.version.outputs.debian }} | ||
steps: | ||
- id: version | ||
run: | | ||
_upstream=2.38.1; _debian="${_upstream}-5" | ||
echo "debian=${_debian}" >> "$GITHUB_OUTPUT" | ||
echo "upstream=${_upstream}" >> "$GITHUB_OUTPUT" | ||
- id: cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: 3rd-party/util-linux/${{ steps.version.outputs.debian }} | ||
path: 3rd-party/util-linux | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
name: Installing dependencies | ||
run: | | ||
# installing dependencies | ||
export DEBIAN_FRONTEND=noninteractive | ||
sudo apt update --assume-yes | ||
sudo apt install --assume-yes devscripts dpkg-dev \ | ||
asciidoctor debhelper-compat dh-exec po-debconf socat \ | ||
libaudit-dev libcap-ng-dev libcryptsetup-dev libpam0g-dev libsystemd-dev libudev-dev | ||
sudo apt autoremove --assume-yes | ||
sudo apt purge --assume-yes '~c' | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
name: Building via debuild | ||
run: | | ||
# building via debuild | ||
mkdir --parents ./3rd-party/util-linux/build | ||
cd ./3rd-party/util-linux/build | ||
_debian_version="${{ steps.version.outputs.debian }}" | ||
_upstream_version="${{ steps.version.outputs.upstream }}" | ||
for _url in \ | ||
"http://deb.debian.org/debian/pool/main/u/util-linux/util-linux_${_upstream_version}.orig.tar.xz" \ | ||
"http://deb.debian.org/debian/pool/main/u/util-linux/util-linux_${_debian_version}.debian.tar.xz" \ | ||
; do curl --remote-name "${_url}"; done | ||
tar --extract --file="util-linux_${_upstream_version}.orig.tar.xz" | ||
tar --extract --file="util-linux_${_debian_version}.debian.tar.xz" --directory="util-linux-${_upstream_version}" | ||
(cd "./util-linux-${_upstream_version}" && debuild --no-sign) | ||
cd .. | ||
mv ./build/*.deb ./ | ||
rm --force --recursive ./build | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: util-linux | ||
path: 3rd-party/util-linux | ||
|
||
pytest: | ||
runs-on: ubuntu-latest | ||
needs: [util-linux] | ||
steps: | ||
- uses: actions/cache@v3 | ||
with: | ||
key: 3rd-party/util-linux/${{ needs.util-linux.outputs.version }} | ||
path: 3rd-party/util-linux | ||
fail-on-cache-miss: true | ||
- uses: actions/setup-python@v3 | ||
- name: Installing dependencies | ||
run: | | ||
# installing dependencies | ||
export DEBIAN_FRONTEND=noninteractive | ||
sudo apt update --assume-yes | ||
sudo apt purge --assume-yes moby-runc moby-containerd | ||
sudo apt autoremove --assume-yes | ||
sudo apt purge --assume-yes '~c' | ||
sudo apt install --assume-yes oci-image-tool | ||
sudo apt install --assume-yes buildah podman docker.io skopeo | ||
_util_linux_version="${{ needs.util-linux.outputs.version }}" | ||
(cd ./3rd-party/util-linux && sudo apt install --assume-yes \ | ||
"./util-linux_${_util_linux_version}_amd64.deb" "./util-linux-extra_${_util_linux_version}_amd64.deb" \ | ||
"./libmount1_${_util_linux_version}_amd64.deb" "./libsmartcols1_${_util_linux_version}_amd64.deb" \ | ||
) | ||
python -m pip install --upgrade pip | ||
pip install --upgrade pytest pyyaml | ||
- uses: actions/checkout@v3 | ||
with: { path: snapshot } | ||
- name: Installing this package | ||
run: pip install --upgrade ./snapshot | ||
- id: cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: oci/examples/nginx/${{ hashFiles('snapshot/examples/nginx') }} | ||
path: temporary/oci | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
name: Generating oci images | ||
run: | | ||
# generating oci images | ||
mkdir --parents temporary/oci | ||
docker build --pull --tag=example -- ./snapshot/examples/nginx/docker | ||
buildah build --pull --layers --tag=example -- ./snapshot/examples/nginx/docker | ||
buildah push localhost/example oci-archive:temporary/oci/buildah.tar | ||
podman image save --format=oci-archive -- localhost/example > temporary/oci/podman.tar | ||
skopeo copy docker-daemon:example:latest oci-archive:temporary/oci/docker.tar | ||
- name: Executing `pytest` | ||
run: | | ||
# executing `pytest` | ||
pytest -ra --basetemp=temporary/pytest \ | ||
--tests.examples.nginx-source=temporary/oci/docker.tar \ | ||
--tests.examples.nginx-source=temporary/oci/podman.tar \ | ||
--tests.examples.nginx-source=temporary/oci/buildah.tar \ | ||
./snapshot/tests | ||
- if: failure() | ||
run: sudo tar --create --directory=temporary -- . | xz > test-context.tar.xz | ||
- if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-context | ||
path: test-context.tar.xz |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
Creative Commons Legal Code | ||
|
||
CC0 1.0 Universal | ||
|
||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE | ||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN | ||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS | ||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES | ||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS | ||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM | ||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED | ||
HEREUNDER. | ||
|
||
Statement of Purpose | ||
|
||
The laws of most jurisdictions throughout the world automatically confer | ||
exclusive Copyright and Related Rights (defined below) upon the creator | ||
and subsequent owner(s) (each and all, an "owner") of an original work of | ||
authorship and/or a database (each, a "Work"). | ||
|
||
Certain owners wish to permanently relinquish those rights to a Work for | ||
the purpose of contributing to a commons of creative, cultural and | ||
scientific works ("Commons") that the public can reliably and without fear | ||
of later claims of infringement build upon, modify, incorporate in other | ||
works, reuse and redistribute as freely as possible in any form whatsoever | ||
and for any purposes, including without limitation commercial purposes. | ||
These owners may contribute to the Commons to promote the ideal of a free | ||
culture and the further production of creative, cultural and scientific | ||
works, or to gain reputation or greater distribution for their Work in | ||
part through the use and efforts of others. | ||
|
||
For these and/or other purposes and motivations, and without any | ||
expectation of additional consideration or compensation, the person | ||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she | ||
is an owner of Copyright and Related Rights in the Work, voluntarily | ||
elects to apply CC0 to the Work and publicly distribute the Work under its | ||
terms, with knowledge of his or her Copyright and Related Rights in the | ||
Work and the meaning and intended legal effect of CC0 on those rights. | ||
|
||
1. Copyright and Related Rights. A Work made available under CC0 may be | ||
protected by copyright and related or neighboring rights ("Copyright and | ||
Related Rights"). Copyright and Related Rights include, but are not | ||
limited to, the following: | ||
|
||
i. the right to reproduce, adapt, distribute, perform, display, | ||
communicate, and translate a Work; | ||
ii. moral rights retained by the original author(s) and/or performer(s); | ||
iii. publicity and privacy rights pertaining to a person's image or | ||
likeness depicted in a Work; | ||
iv. rights protecting against unfair competition in regards to a Work, | ||
subject to the limitations in paragraph 4(a), below; | ||
v. rights protecting the extraction, dissemination, use and reuse of data | ||
in a Work; | ||
vi. database rights (such as those arising under Directive 96/9/EC of the | ||
European Parliament and of the Council of 11 March 1996 on the legal | ||
protection of databases, and under any national implementation | ||
thereof, including any amended or successor version of such | ||
directive); and | ||
vii. other similar, equivalent or corresponding rights throughout the | ||
world based on applicable law or treaty, and any national | ||
implementations thereof. | ||
|
||
2. Waiver. To the greatest extent permitted by, but not in contravention | ||
of, applicable law, Affirmer hereby overtly, fully, permanently, | ||
irrevocably and unconditionally waives, abandons, and surrenders all of | ||
Affirmer's Copyright and Related Rights and associated claims and causes | ||
of action, whether now known or unknown (including existing as well as | ||
future claims and causes of action), in the Work (i) in all territories | ||
worldwide, (ii) for the maximum duration provided by applicable law or | ||
treaty (including future time extensions), (iii) in any current or future | ||
medium and for any number of copies, and (iv) for any purpose whatsoever, | ||
including without limitation commercial, advertising or promotional | ||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each | ||
member of the public at large and to the detriment of Affirmer's heirs and | ||
successors, fully intending that such Waiver shall not be subject to | ||
revocation, rescission, cancellation, termination, or any other legal or | ||
equitable action to disrupt the quiet enjoyment of the Work by the public | ||
as contemplated by Affirmer's express Statement of Purpose. | ||
|
||
3. Public License Fallback. Should any part of the Waiver for any reason | ||
be judged legally invalid or ineffective under applicable law, then the | ||
Waiver shall be preserved to the maximum extent permitted taking into | ||
account Affirmer's express Statement of Purpose. In addition, to the | ||
extent the Waiver is so judged Affirmer hereby grants to each affected | ||
person a royalty-free, non transferable, non sublicensable, non exclusive, | ||
irrevocable and unconditional license to exercise Affirmer's Copyright and | ||
Related Rights in the Work (i) in all territories worldwide, (ii) for the | ||
maximum duration provided by applicable law or treaty (including future | ||
time extensions), (iii) in any current or future medium and for any number | ||
of copies, and (iv) for any purpose whatsoever, including without | ||
limitation commercial, advertising or promotional purposes (the | ||
"License"). The License shall be deemed effective as of the date CC0 was | ||
applied by Affirmer to the Work. Should any part of the License for any | ||
reason be judged legally invalid or ineffective under applicable law, such | ||
partial invalidity or ineffectiveness shall not invalidate the remainder | ||
of the License, and in such case Affirmer hereby affirms that he or she | ||
will not (i) exercise any of his or her remaining Copyright and Related | ||
Rights in the Work or (ii) assert any associated claims and causes of | ||
action with respect to the Work, in either case contrary to Affirmer's | ||
express Statement of Purpose. | ||
|
||
4. Limitations and Disclaimers. | ||
|
||
a. No trademark or patent rights held by Affirmer are waived, abandoned, | ||
surrendered, licensed or otherwise affected by this document. | ||
b. Affirmer offers the Work as-is and makes no representations or | ||
warranties of any kind concerning the Work, express, implied, | ||
statutory or otherwise, including without limitation warranties of | ||
title, merchantability, fitness for a particular purpose, non | ||
infringement, or the absence of latent or other defects, accuracy, or | ||
the present or absence of errors, whether or not discoverable, all to | ||
the greatest extent permissible under applicable law. | ||
c. Affirmer disclaims responsibility for clearing rights of other persons | ||
that may apply to the Work or any use thereof, including without | ||
limitation any person's Copyright and Related Rights in the Work. | ||
Further, Affirmer disclaims responsibility for obtaining any necessary | ||
consents, permissions or other rights required for any use of the | ||
Work. | ||
d. Affirmer understands and acknowledges that Creative Commons is not a | ||
party to this document and has no duty or obligation with respect to | ||
this CC0 or use of the Work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# p5-python3-libvirt_lxc_helper | ||
python3 libvirt_lxc helper tool | ||
|
||
## Install | ||
- from source code directory: `cd path/to/source/code/directory && pip install .` | ||
- from source code archive file: `pip install path/to/source/code/archive/file` | ||
|
||
## Examples | ||
Located in [examples](examples) directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
### produce oci-image and generate rootfs tar archive | ||
``` | ||
podman build --tag=example -- examples/nginx/docker | ||
podman image save --format=oci-archive -- example | python -m p5.libvirt_lxc_helper make-rootfs --destination=rootfs.tar | ||
``` | ||
- For producing oci-image you can use `docker`, `podman`, `buildah`, etc ... | ||
- For more options check: `python -m p5.libvirt_lxc_helper --help` | ||
|
||
### helper script | ||
`Dockerfile` instructions do not always lead to the desired result. | ||
For example, it is not so easy to replace the contents of `/etc/hosts`. | ||
But you can use a special script (`yaml` or `json` config file) - in this example it named as [`.p5.libvirt_lxc_helper.script.yml`](docker/files/.p5.libvirt_lxc_helper.script.yml). | ||
It should be marked as `p5.libvirt_lxc_helper.script` `LABEL` in `Dockerfile` like this: | ||
``` | ||
LABEL p5.libvirt_lxc_helper.script=.p5.libvirt_lxc_helper.script.yml | ||
``` | ||
In this case `.p5.libvirt_lxc_helper.script.yml` is path (relative to container root) to script. | ||
Path will be normalized automatically - don't worry about `/`, `./`, etc... | ||
For example, there you can do something like this: | ||
``` | ||
- command: /bin/sh -xe | ||
input: | | ||
rm --force /etc/hostname && echo nginx > /etc/hostname | ||
rm --force /etc/resolv.conf && ln --symbolic /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf | ||
rm --force /etc/hosts && cat > /etc/hosts << EOF | ||
127.0.0.1 localhost | ||
# The following lines are desirable for IPv6 capable hosts | ||
::1 localhost ip6-localhost ip6-loopback | ||
ff02::1 ip6-allnodes | ||
ff02::2 ip6-allrouters | ||
::1 nginx | ||
127.0.0.1 nginx | ||
EOF | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
ARG base_image=debian:bullseye | ||
|
||
FROM ${base_image} | ||
|
||
ENV LC_ALL C | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# watch .p5.libvirt_lxc_helper.script.yml | ||
ENV EXAMPLE_A should be inherited | ||
ENV EXAMPLE_B should be inherited | ||
ENV EXAMPLE_C should be removed | ||
ENV EXAMPLE_D should be replaced | ||
|
||
RUN rm --force /etc/apt/sources.list | ||
COPY files/etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources | ||
RUN _packages=`apt-mark showmanual`; test -n "${_packages}" || exit 0; apt-mark auto ${_packages} | ||
RUN apt update --assume-yes && apt install --assume-yes apt-utils | ||
RUN apt update --assume-yes && apt full-upgrade --assume-yes | ||
|
||
RUN apt purge --assume-yes ifupdown iproute2 | ||
RUN rm --force --recursive /etc/network | ||
|
||
RUN apt update --assume-yes && apt install --assume-yes systemd systemd-sysv | ||
RUN apt update --assume-yes && apt install --assume-yes nginx | ||
|
||
RUN systemctl enable systemd-networkd.service systemd-resolved.service | ||
|
||
RUN rm --force /etc/*- | ||
|
||
RUN apt update --assume-yes && apt --assume-yes full-upgrade && apt autoremove --assume-yes && apt purge --assume-yes '~c' | ||
RUN apt clean --assume-yes && for _path in /tmp /var/tmp /var/lib/apt/lists; do \ | ||
find "${_path}" -mindepth 1 -maxdepth 1 -exec rm --recursive --force {} \;; \ | ||
done | ||
|
||
COPY files/.p5.libvirt_lxc_helper.script.yml .p5.libvirt_lxc_helper.script.yml | ||
LABEL p5.libvirt_lxc_helper.script=.p5.libvirt_lxc_helper.script.yml | ||
|
||
ENTRYPOINT ["/sbin/init"] |
Oops, something went wrong.